7 #include "packager/media/codecs/hls_audio_util.h" 9 #include "packager/media/base/buffer_writer.h" 10 #include "packager/media/base/fourccs.h" 11 #include "packager/media/codecs/aac_audio_specific_config.h" 16 bool WriteAudioSetupInformation(Codec codec,
17 const uint8_t* audio_specific_config,
18 size_t audio_specific_config_size,
19 BufferWriter* audio_setup_information) {
20 uint32_t audio_type = FOURCC_NULL;
23 AACAudioSpecificConfig config;
24 const bool result = config.Parse(std::vector<uint8_t>(
25 audio_specific_config,
26 audio_specific_config + audio_specific_config_size));
28 AACAudioSpecificConfig::AudioObjectType audio_object_type;
30 LOG(WARNING) <<
"Failed to parse config. Assuming AAC-LC.";
31 audio_object_type = AACAudioSpecificConfig::AOT_AAC_LC;
33 audio_object_type = config.GetAudioObjectType();
36 switch (audio_object_type) {
37 case AACAudioSpecificConfig::AOT_AAC_LC:
38 audio_type = FOURCC_zaac;
40 case AACAudioSpecificConfig::AOT_SBR:
41 audio_type = FOURCC_zach;
43 case AACAudioSpecificConfig::AOT_PS:
44 audio_type = FOURCC_zacp;
47 LOG(ERROR) <<
"Unknown object type for aac " << audio_object_type;
52 audio_type = FOURCC_zac3;
55 audio_type = FOURCC_zec3;
58 LOG(ERROR) <<
"Codec " << codec <<
" is not supported in encrypted TS.";
62 DCHECK_NE(audio_type, FOURCC_NULL);
63 audio_setup_information->AppendInt(audio_type);
65 audio_setup_information->AppendInt(static_cast<uint16_t>(0x0000));
67 audio_setup_information->AppendInt(static_cast<uint8_t>(0x01));
70 if (audio_specific_config_size > 0xFF) {
71 LOG(ERROR) <<
"Audio specific config should not be larger than one byte " 72 << audio_specific_config_size;
75 audio_setup_information->AppendInt(
76 static_cast<uint8_t>(audio_specific_config_size));
78 audio_setup_information->AppendArray(audio_specific_config,
79 audio_specific_config_size);
All the methods that are virtual are virtual for mocking.