Skip to content

Commit

Permalink
Organized source codes related to RTMP Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dimiden committed Nov 14, 2024
1 parent 818b9b0 commit 7ed8718
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 70 deletions.
57 changes: 1 addition & 56 deletions src/projects/modules/bitstream/aac/aac_adts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion src/projects/modules/bitstream/aac/aac_adts.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AACAdts
uint8_t Layer();
bool ProtectionAbsent();
AudioObjectType ObjectType();
ov::String ObjectTypeString();
AacSamplingFrequencies SamplingFrequencyIndex();
uint32_t Samplerate();
uint8_t ChannelConfiguration();
Expand Down
55 changes: 55 additions & 0 deletions src/projects/modules/bitstream/aac/aac_defines.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/projects/modules/bitstream/aac/aac_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
25 changes: 13 additions & 12 deletions src/projects/providers/rtmp/rtmp_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <base/info/media_extradata.h>
#include <base/mediarouter/media_type.h>
#include <modules/bitstream/aac/audio_specific_config.h>
#include <modules/bitstream/h264/h264_decoder_configuration_record.h>
#include <modules/containers/flv/flv_parser.h>
#include <modules/id3v2/frames/id3v2_frames.h>
Expand Down Expand Up @@ -1800,6 +1799,19 @@ namespace pvd
return false;
}

auto data = std::make_shared<ov::Data>(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;

Expand All @@ -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<ov::Data>(flv_audio.Payload(), flv_audio.PayloadLength());
auto frame = std::make_shared<MediaPacket>(GetMsid(),
cmn::MediaType::Audio,
RTMP_AUDIO_TRACK_ID,
Expand Down

0 comments on commit 7ed8718

Please sign in to comment.