From 7ed871800207eea185defdc0dffadb16716da782 Mon Sep 17 00:00:00 2001 From: Dimiden Date: Thu, 14 Nov 2024 20:52:26 +0900 Subject: [PATCH] Organized source codes related to RTMP Provider --- .../modules/bitstream/aac/aac_adts.cpp | 57 +------------------ src/projects/modules/bitstream/aac/aac_adts.h | 1 - .../modules/bitstream/aac/aac_defines.cpp | 55 ++++++++++++++++++ .../modules/bitstream/aac/aac_defines.h | 1 + .../bitstream/aac/audio_specific_config.cpp | 2 +- src/projects/providers/rtmp/rtmp_stream.cpp | 25 ++++---- 6 files changed, 71 insertions(+), 70 deletions(-) diff --git a/src/projects/modules/bitstream/aac/aac_adts.cpp b/src/projects/modules/bitstream/aac/aac_adts.cpp index 686421132..edcd5680f 100755 --- a/src/projects/modules/bitstream/aac/aac_adts.cpp +++ b/src/projects/modules/bitstream/aac/aac_adts.cpp @@ -100,61 +100,6 @@ AudioObjectType AACAdts::ObjectType() return AudioObjectType::Null; } -#define OBJECT_TYPE_DESC_CASE(value, description) \ - case AudioObjectType::value: \ - return description - -ov::String AACAdts::ObjectTypeString() -{ - switch (ObjectType()) - { - OBJECT_TYPE_DESC_CASE(Null, "Null"); - OBJECT_TYPE_DESC_CASE(AacMain, "AAC main"); - OBJECT_TYPE_DESC_CASE(AacLc, "AAC LC"); - OBJECT_TYPE_DESC_CASE(AacSsr, "AAC SSR"); - OBJECT_TYPE_DESC_CASE(AacLtp, "AAC LTP"); - OBJECT_TYPE_DESC_CASE(Sbr, "SBR"); - OBJECT_TYPE_DESC_CASE(AacScalable, "AAC Scalable"); - OBJECT_TYPE_DESC_CASE(Twinvq, "TwinVQ"); - OBJECT_TYPE_DESC_CASE(Celp, "CELP"); - OBJECT_TYPE_DESC_CASE(Hvxc, "HVXC"); - OBJECT_TYPE_DESC_CASE(Reserved10, "(reserved-10)"); - OBJECT_TYPE_DESC_CASE(Reserved11, "(reserved-11)"); - OBJECT_TYPE_DESC_CASE(Ttsi, "TTSI"); - OBJECT_TYPE_DESC_CASE(MainSynthetic, "Main synthetic"); - OBJECT_TYPE_DESC_CASE(WavetableSynthesis, "Wavetable synthesis"); - OBJECT_TYPE_DESC_CASE(GeneralMidi, "General MIDI"); - OBJECT_TYPE_DESC_CASE(AlgorithmicSynthesisAndAudioFx, "Algorithmic Synthesis and Audio FX"); - OBJECT_TYPE_DESC_CASE(ErAacLc, "ER AAC LC"); - OBJECT_TYPE_DESC_CASE(Reserved18, "(reserved-18)"); - OBJECT_TYPE_DESC_CASE(ErAacLtp, "ER AAC LTP"); - OBJECT_TYPE_DESC_CASE(ErAacScalable, "ER AAC Scalable"); - OBJECT_TYPE_DESC_CASE(ErTwinvq, "ER TwinVQ"); - OBJECT_TYPE_DESC_CASE(ErBsac, "ER BSAC"); - OBJECT_TYPE_DESC_CASE(ErAacLd, "ER AAC LD"); - OBJECT_TYPE_DESC_CASE(ErCelp, "ER CELP"); - OBJECT_TYPE_DESC_CASE(ErHvxc, "ER HVXC"); - OBJECT_TYPE_DESC_CASE(ErHiln, "ER HILN"); - OBJECT_TYPE_DESC_CASE(ErParametric, "ER Parametric"); - OBJECT_TYPE_DESC_CASE(Ssc, "SSC"); - OBJECT_TYPE_DESC_CASE(Ps, "PS"); - OBJECT_TYPE_DESC_CASE(MpegSurround, "MPEG Surround"); - OBJECT_TYPE_DESC_CASE(Escape, "(escape)"); - OBJECT_TYPE_DESC_CASE(Layer1, "Layer-1"); - OBJECT_TYPE_DESC_CASE(Layer2, "Layer-2"); - OBJECT_TYPE_DESC_CASE(Layer3, "Layer-3"); - OBJECT_TYPE_DESC_CASE(Dst, "DST"); - OBJECT_TYPE_DESC_CASE(Als, "ALS"); - OBJECT_TYPE_DESC_CASE(Sls, "SLS"); - OBJECT_TYPE_DESC_CASE(SlsNonCore, "SLS non-core"); - OBJECT_TYPE_DESC_CASE(ErAacEld, "ER AAC ELD"); - OBJECT_TYPE_DESC_CASE(SmrSimple, "SMR Simple"); - OBJECT_TYPE_DESC_CASE(SmrMain, "SMR Main"); - } - - return "Unknown"; -} - AacSamplingFrequencies AACAdts::SamplingFrequencyIndex() { return _sampling_frequency_index; @@ -192,7 +137,7 @@ ov::String AACAdts::GetInfoString() out_str.AppendFormat("\tId(%d)\n", Id()); out_str.AppendFormat("\tLayer(%d)\n", Layer()); out_str.AppendFormat("\tProtectionAbsent(%s)\n", ProtectionAbsent() ? "true" : "false"); - out_str.AppendFormat("\tObjectType(%d/%s)\n", ObjectType(), ObjectTypeString().CStr()); + out_str.AppendFormat("\tObjectType(%d/%s)\n", ObjectType(), StringFromAudioObjectType(ObjectType())); out_str.AppendFormat("\tSamplerate(%d/%d)\n", SamplingFrequencyIndex(), Samplerate()); out_str.AppendFormat("\tChannelConfiguration(%d)\n", ChannelConfiguration()); out_str.AppendFormat("\tHome(%s)\n", Home() ? "true" : "false"); diff --git a/src/projects/modules/bitstream/aac/aac_adts.h b/src/projects/modules/bitstream/aac/aac_adts.h index d7d92c685..8a369fb4a 100755 --- a/src/projects/modules/bitstream/aac/aac_adts.h +++ b/src/projects/modules/bitstream/aac/aac_adts.h @@ -19,7 +19,6 @@ class AACAdts uint8_t Layer(); bool ProtectionAbsent(); AudioObjectType ObjectType(); - ov::String ObjectTypeString(); AacSamplingFrequencies SamplingFrequencyIndex(); uint32_t Samplerate(); uint8_t ChannelConfiguration(); diff --git a/src/projects/modules/bitstream/aac/aac_defines.cpp b/src/projects/modules/bitstream/aac/aac_defines.cpp index a7a3cbfd5..366b1a8f6 100644 --- a/src/projects/modules/bitstream/aac/aac_defines.cpp +++ b/src/projects/modules/bitstream/aac/aac_defines.cpp @@ -1,5 +1,60 @@ #include "aac_defines.h" +#define OBJECT_TYPE_DESC_CASE(value, description) \ + case AudioObjectType::value: \ + return description + +const char *StringFromAudioObjectType(AudioObjectType object_type) +{ + switch (object_type) + { + OBJECT_TYPE_DESC_CASE(Null, "Null"); + OBJECT_TYPE_DESC_CASE(AacMain, "AAC main"); + OBJECT_TYPE_DESC_CASE(AacLc, "AAC LC"); + OBJECT_TYPE_DESC_CASE(AacSsr, "AAC SSR"); + OBJECT_TYPE_DESC_CASE(AacLtp, "AAC LTP"); + OBJECT_TYPE_DESC_CASE(Sbr, "SBR"); + OBJECT_TYPE_DESC_CASE(AacScalable, "AAC Scalable"); + OBJECT_TYPE_DESC_CASE(Twinvq, "TwinVQ"); + OBJECT_TYPE_DESC_CASE(Celp, "CELP"); + OBJECT_TYPE_DESC_CASE(Hvxc, "HVXC"); + OBJECT_TYPE_DESC_CASE(Reserved10, "(reserved-10)"); + OBJECT_TYPE_DESC_CASE(Reserved11, "(reserved-11)"); + OBJECT_TYPE_DESC_CASE(Ttsi, "TTSI"); + OBJECT_TYPE_DESC_CASE(MainSynthetic, "Main synthetic"); + OBJECT_TYPE_DESC_CASE(WavetableSynthesis, "Wavetable synthesis"); + OBJECT_TYPE_DESC_CASE(GeneralMidi, "General MIDI"); + OBJECT_TYPE_DESC_CASE(AlgorithmicSynthesisAndAudioFx, "Algorithmic Synthesis and Audio FX"); + OBJECT_TYPE_DESC_CASE(ErAacLc, "ER AAC LC"); + OBJECT_TYPE_DESC_CASE(Reserved18, "(reserved-18)"); + OBJECT_TYPE_DESC_CASE(ErAacLtp, "ER AAC LTP"); + OBJECT_TYPE_DESC_CASE(ErAacScalable, "ER AAC Scalable"); + OBJECT_TYPE_DESC_CASE(ErTwinvq, "ER TwinVQ"); + OBJECT_TYPE_DESC_CASE(ErBsac, "ER BSAC"); + OBJECT_TYPE_DESC_CASE(ErAacLd, "ER AAC LD"); + OBJECT_TYPE_DESC_CASE(ErCelp, "ER CELP"); + OBJECT_TYPE_DESC_CASE(ErHvxc, "ER HVXC"); + OBJECT_TYPE_DESC_CASE(ErHiln, "ER HILN"); + OBJECT_TYPE_DESC_CASE(ErParametric, "ER Parametric"); + OBJECT_TYPE_DESC_CASE(Ssc, "SSC"); + OBJECT_TYPE_DESC_CASE(Ps, "PS"); + OBJECT_TYPE_DESC_CASE(MpegSurround, "MPEG Surround"); + OBJECT_TYPE_DESC_CASE(Escape, "(escape)"); + OBJECT_TYPE_DESC_CASE(Layer1, "Layer-1"); + OBJECT_TYPE_DESC_CASE(Layer2, "Layer-2"); + OBJECT_TYPE_DESC_CASE(Layer3, "Layer-3"); + OBJECT_TYPE_DESC_CASE(Dst, "DST"); + OBJECT_TYPE_DESC_CASE(Als, "ALS"); + OBJECT_TYPE_DESC_CASE(Sls, "SLS"); + OBJECT_TYPE_DESC_CASE(SlsNonCore, "SLS non-core"); + OBJECT_TYPE_DESC_CASE(ErAacEld, "ER AAC ELD"); + OBJECT_TYPE_DESC_CASE(SmrSimple, "SMR Simple"); + OBJECT_TYPE_DESC_CASE(SmrMain, "SMR Main"); + } + + return "Unknown"; +} + #define _SAMPLE_RATE_CASE(rate, value) \ case AacSamplingFrequencies::rate: \ return value; diff --git a/src/projects/modules/bitstream/aac/aac_defines.h b/src/projects/modules/bitstream/aac/aac_defines.h index f84369cc9..487c02178 100644 --- a/src/projects/modules/bitstream/aac/aac_defines.h +++ b/src/projects/modules/bitstream/aac/aac_defines.h @@ -49,6 +49,7 @@ enum class AudioObjectType : uint8_t SmrSimple = 40, // Symbolic Music Representation Simple SmrMain = 41, // Symbolic Music Representation Main }; +const char *StringFromAudioObjectType(AudioObjectType object_type); enum class AacProfile : uint8_t { diff --git a/src/projects/modules/bitstream/aac/audio_specific_config.cpp b/src/projects/modules/bitstream/aac/audio_specific_config.cpp index 89ba6aec1..5428273c1 100644 --- a/src/projects/modules/bitstream/aac/audio_specific_config.cpp +++ b/src/projects/modules/bitstream/aac/audio_specific_config.cpp @@ -497,7 +497,7 @@ ov::String AudioSpecificConfig::GetInfoString() const { ov::String out_str = ov::String::FormatString("\n[AudioSpecificConfig]\n"); - out_str.AppendFormat("\tObjectType(%d)\n", ObjectType()); + out_str.AppendFormat("\tObjectType(%d, %s)\n", ObjectType(), StringFromAudioObjectType(ObjectType())); out_str.AppendFormat("\tSamplingFrequency(%d)\n", SamplingFrequencyIndex()); out_str.AppendFormat("\tChannel(%d)\n", Channel()); diff --git a/src/projects/providers/rtmp/rtmp_stream.cpp b/src/projects/providers/rtmp/rtmp_stream.cpp index ec1f09f72..ad26138c3 100644 --- a/src/projects/providers/rtmp/rtmp_stream.cpp +++ b/src/projects/providers/rtmp/rtmp_stream.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -1800,6 +1799,19 @@ namespace pvd return false; } + auto data = std::make_shared(flv_audio.Payload(), flv_audio.PayloadLength()); + + cmn::PacketType packet_type = cmn::PacketType::Unknown; + + if (flv_audio.PacketType() == FlvAACPacketType::SEQUENCE_HEADER) + { + packet_type = cmn::PacketType::SEQUENCE_HEADER; + } + else if (flv_audio.PacketType() == FlvAACPacketType::RAW) + { + packet_type = cmn::PacketType::RAW; + } + int64_t dts = message->header->completed.timestamp; int64_t pts = dts; @@ -1821,17 +1833,6 @@ namespace pvd AdjustTimestamp(pts, dts); } - cmn::PacketType packet_type = cmn::PacketType::Unknown; - if (flv_audio.PacketType() == FlvAACPacketType::SEQUENCE_HEADER) - { - packet_type = cmn::PacketType::SEQUENCE_HEADER; - } - else if (flv_audio.PacketType() == FlvAACPacketType::RAW) - { - packet_type = cmn::PacketType::RAW; - } - - auto data = std::make_shared(flv_audio.Payload(), flv_audio.PayloadLength()); auto frame = std::make_shared(GetMsid(), cmn::MediaType::Audio, RTMP_AUDIO_TRACK_ID,