diff --git a/nginx-pckg-module/src/media/codec_config.c b/nginx-pckg-module/src/media/codec_config.c index 27358472..aabb6ac9 100644 --- a/nginx-pckg-module/src/media/codec_config.c +++ b/nginx-pckg-module/src/media/codec_config.c @@ -10,6 +10,10 @@ #define AOT_ESCAPE (31) +#define AOT_SBR (5) + +#define AOT_PS (29) + #define HVCC_HEADER_SIZE (22) @@ -474,7 +478,8 @@ codec_config_mp4a_config_parse( vod_str_t* extra_data, mp4a_config_t* result) { - bit_reader_state_t reader; + bit_reader_state_t reader, temp_reader; + uint8_t ext_sample_rate_index; vod_log_buffer(VOD_LOG_DEBUG_LEVEL, log, 0, "codec_config_mp4a_config_parse: extra data ", extra_data->data, extra_data->len); @@ -492,12 +497,44 @@ codec_config_mp4a_config_parse( if (reader.stream.eof_reached) { - vod_log_error(VOD_LOG_ERR, log, 0, - "codec_config_mp4a_config_parse: failed to read all required audio extra data fields"); - return VOD_BAD_DATA; + goto error; + } + + temp_reader = reader; + if (result->object_type == AOT_SBR || (result->object_type == AOT_PS && + !(bit_read_stream_get(&temp_reader, 3) & 0x03 && !(bit_read_stream_get(&temp_reader, 9) & 0x3f)))) + { + ext_sample_rate_index = bit_read_stream_get(&reader, 4); + if (ext_sample_rate_index == 0x0f) + { + bit_read_stream_get(&reader, 24); + } + + if (reader.stream.eof_reached) + { + goto error; + } + + result->object_type = bit_read_stream_get(&reader, 5); + if (result->object_type == AOT_ESCAPE) + { + result->object_type = 32 + bit_read_stream_get(&reader, 6); + } + + if (reader.stream.eof_reached) + { + goto error; + } } return VOD_OK; + +error: + + vod_log_error(VOD_LOG_ERR, log, 0, + "codec_config_mp4a_config_parse: failed to read all required audio extra data fields"); + + return VOD_BAD_DATA; } uint32_t diff --git a/nginx-pckg-module/src/media/mpegts/adts_encoder_filter.c b/nginx-pckg-module/src/media/mpegts/adts_encoder_filter.c index 8fcf4f98..389710fb 100644 --- a/nginx-pckg-module/src/media/mpegts/adts_encoder_filter.c +++ b/nginx-pckg-module/src/media/mpegts/adts_encoder_filter.c @@ -42,6 +42,12 @@ adts_encoder_set_media_info( adts_frame_header_set_channel_configuration(state->header, codec_config->channel_config); adts_frame_header_set_adts_buffer_fullness(state->header, 0x7ff); + vod_log_debug3(VOD_LOG_DEBUG_LEVEL, context->request_context->log, 0, + "adts_encoder_set_media_info: mp4a object_type: %D sample_rate_index: %D channel_config: %D", + codec_config->object_type, + codec_config->sample_rate_index, + codec_config->channel_config); + return VOD_OK; }