Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 1490613005: media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed a couple comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/ffmpeg/ffmpeg_common.cc
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index 51e8884fedb1b35fab80b24e13abda6ae4c8f688..eb46e8ff851276f61f4e19deed39f4181c322812 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -13,12 +13,24 @@
#include "build/build_config.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/decoder_buffer.h"
+#include "media/base/encryption_scheme.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_util.h"
#include "media/media_features.h"
namespace media {
+namespace {
+
+EncryptionScheme GetEncryptionScheme(const AVStream* stream) {
+ AVDictionaryEntry* key =
+ av_dict_get(stream->metadata, "enc_key_id", nullptr, 0);
+ return EncryptionScheme(key ? EncryptionScheme::kCipherModeAesCtr
+ : EncryptionScheme::kCipherModeUnencrypted);
+}
+
+} // namespace
+
// Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
// padded. Check here to ensure FFmpeg only receives data padded to its
// specifications.
@@ -303,9 +315,10 @@ static AVSampleFormat SampleFormatToAVSampleFormat(SampleFormat sample_format) {
return AV_SAMPLE_FMT_NONE;
}
-bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
- bool is_encrypted,
- AudioDecoderConfig* config) {
+bool AVCodecContextToAudioDecoderConfig(
+ const AVCodecContext* codec_context,
+ const EncryptionScheme& encryption_scheme,
+ AudioDecoderConfig* config) {
DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO);
AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id);
@@ -371,13 +384,9 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
extra_data.assign(codec_context->extradata,
codec_context->extradata + codec_context->extradata_size);
}
- config->Initialize(codec,
- sample_format,
- channel_layout,
- sample_rate,
- extra_data,
- is_encrypted,
- seek_preroll,
+
+ config->Initialize(codec, sample_format, channel_layout, sample_rate,
+ extra_data, encryption_scheme, seek_preroll,
codec_context->delay);
// Verify that AudioConfig.bits_per_channel was calculated correctly for
@@ -400,13 +409,8 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
bool AVStreamToAudioDecoderConfig(const AVStream* stream,
AudioDecoderConfig* config) {
- bool is_encrypted = false;
- AVDictionaryEntry* key =
- av_dict_get(stream->metadata, "enc_key_id", nullptr, 0);
- if (key)
- is_encrypted = true;
- return AVCodecContextToAudioDecoderConfig(stream->codec, is_encrypted,
- config);
+ return AVCodecContextToAudioDecoderConfig(
+ stream->codec, GetEncryptionScheme(stream), config);
}
void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
@@ -497,12 +501,6 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
coded_size.set_height((coded_size.height() + 1) / 2 * 2);
}
- bool is_encrypted = false;
- AVDictionaryEntry* key =
- av_dict_get(stream->metadata, "enc_key_id", nullptr, 0);
- if (key)
- is_encrypted = true;
-
AVDictionaryEntry* webm_alpha =
av_dict_get(stream->metadata, "alpha_mode", nullptr, 0);
if (webm_alpha && !strcmp(webm_alpha->value, "1")) {
@@ -535,7 +533,8 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
stream->codec->extradata + stream->codec->extradata_size);
}
config->Initialize(codec, profile, format, color_space, coded_size,
- visible_rect, natural_size, extra_data, is_encrypted);
+ visible_rect, natural_size, extra_data,
+ GetEncryptionScheme(stream));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698