Index: media/ffmpeg/ffmpeg_common.cc |
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc |
index bf234304aa2b26fb7e0f729a4e75257099c00358..e8a44c7837b444319be7a694cb81ddb75621dcae 100644 |
--- a/media/ffmpeg/ffmpeg_common.cc |
+++ b/media/ffmpeg/ffmpeg_common.cc |
@@ -295,8 +295,9 @@ static ChannelLayout GuessChannelLayout(int channels) { |
return CHANNEL_LAYOUT_UNSUPPORTED; |
} |
-void AVCodecContextToAudioDecoderConfig( |
+static void AVCodecContextToAudioDecoderConfig( |
const AVCodecContext* codec_context, |
+ bool is_encrypted, |
AudioDecoderConfig* config) { |
DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); |
@@ -320,7 +321,7 @@ void AVCodecContextToAudioDecoderConfig( |
codec_context->sample_rate, |
codec_context->extradata, |
codec_context->extradata_size, |
- false, // Not encrypted. |
+ is_encrypted, |
true); |
if (codec != kCodecOpus) { |
DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
@@ -328,6 +329,17 @@ void AVCodecContextToAudioDecoderConfig( |
} |
} |
+void AVStreamToAudioDecoderConfig( |
+ const AVStream* stream, |
+ AudioDecoderConfig* config) { |
+ bool is_encrypted = false; |
+ AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); |
+ if (key) |
+ is_encrypted = true; |
+ return AVCodecContextToAudioDecoderConfig(stream->codec, |
+ is_encrypted, config); |
+} |
+ |
void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config, |
AVCodecContext* codec_context) { |
codec_context->codec_type = AVMEDIA_TYPE_AUDIO; |
@@ -391,12 +403,17 @@ void AVStreamToVideoDecoderConfig( |
coded_size = natural_size; |
} |
+ bool is_encrypted = false; |
+ AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); |
+ if (key) |
+ is_encrypted = true; |
+ |
config->Initialize(codec, |
profile, |
format, |
coded_size, visible_rect, natural_size, |
stream->codec->extradata, stream->codec->extradata_size, |
- false, // Not encrypted. |
+ is_encrypted, |
true); |
} |