Chromium Code Reviews| Index: chromecast/common/media/cma_param_traits.cc |
| diff --git a/chromecast/common/media/cma_param_traits.cc b/chromecast/common/media/cma_param_traits.cc |
| index 2ae4fd917487465a2611330c5a6c6c10607cac1c..bf4b2983ea7719f5264487d067f2a8397dc32269 100644 |
| --- a/chromecast/common/media/cma_param_traits.cc |
| +++ b/chromecast/common/media/cma_param_traits.cc |
| @@ -10,6 +10,7 @@ |
| #include "content/public/common/common_param_traits.h" |
| #include "ipc/ipc_message_macros.h" |
| #include "media/base/audio_decoder_config.h" |
| +#include "media/base/encryption_scheme.h" |
| #include "media/base/video_decoder_config.h" |
| #include "ui/gfx/ipc/gfx_param_traits.h" |
| @@ -27,13 +28,22 @@ IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelFormat, media::PIXEL_FORMAT_MAX) |
| namespace IPC { |
| +template <> |
| +struct ParamTraits<media::EncryptionScheme::PatternSpec> { |
| + typedef media::EncryptionScheme::PatternSpec param_type; |
|
halliwell
2016/01/13 03:29:40
nit: 'using'
dougsteed
2016/02/09 22:58:53
See reply to comment on the .h file.
|
| + static void Write(Message* m, const param_type& p); |
| + static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); |
| + static void Log(const param_type& p, std::string* l); |
| +}; |
| + |
| + |
| void ParamTraits<media::AudioDecoderConfig>::Write( |
| Message* m, const media::AudioDecoderConfig& p) { |
| WriteParam(m, p.codec()); |
| WriteParam(m, p.sample_format()); |
| WriteParam(m, p.channel_layout()); |
| WriteParam(m, p.samples_per_second()); |
| - WriteParam(m, p.is_encrypted()); |
| + WriteParam(m, p.encryption_scheme()); |
| WriteParam(m, p.extra_data()); |
| } |
| @@ -45,15 +55,17 @@ bool ParamTraits<media::AudioDecoderConfig>::Read( |
| media::SampleFormat sample_format; |
| media::ChannelLayout channel_layout; |
| int samples_per_second; |
| - bool is_encrypted; |
| + media::EncryptionScheme encryption_scheme; |
| std::vector<uint8> extra_data; |
| if (!ReadParam(m, iter, &codec) || !ReadParam(m, iter, &sample_format) || |
| !ReadParam(m, iter, &channel_layout) || |
| !ReadParam(m, iter, &samples_per_second) || |
| - !ReadParam(m, iter, &is_encrypted) || !ReadParam(m, iter, &extra_data)) |
| + !ReadParam(m, iter, &encryption_scheme) || |
| + !ReadParam(m, iter, &extra_data)) |
| return false; |
| *r = media::AudioDecoderConfig(codec, sample_format, channel_layout, |
| - samples_per_second, extra_data, is_encrypted); |
| + samples_per_second, extra_data, |
| + encryption_scheme); |
| return true; |
| } |
| @@ -71,7 +83,7 @@ void ParamTraits<media::VideoDecoderConfig>::Write( |
| WriteParam(m, p.coded_size()); |
| WriteParam(m, p.visible_rect()); |
| WriteParam(m, p.natural_size()); |
| - WriteParam(m, p.is_encrypted()); |
| + WriteParam(m, p.encryption_scheme()); |
| WriteParam(m, p.extra_data()); |
| } |
| @@ -86,17 +98,18 @@ bool ParamTraits<media::VideoDecoderConfig>::Read( |
| gfx::Size coded_size; |
| gfx::Rect visible_rect; |
| gfx::Size natural_size; |
| - bool is_encrypted; |
| + media::EncryptionScheme encryption_scheme; |
| std::vector<uint8> extra_data; |
| if (!ReadParam(m, iter, &codec) || !ReadParam(m, iter, &profile) || |
| !ReadParam(m, iter, &format) || !ReadParam(m, iter, &color_space) || |
| !ReadParam(m, iter, &coded_size) || !ReadParam(m, iter, &visible_rect) || |
| !ReadParam(m, iter, &natural_size) || |
| - !ReadParam(m, iter, &is_encrypted) || !ReadParam(m, iter, &extra_data)) |
| + !ReadParam(m, iter, &encryption_scheme) || |
| + !ReadParam(m, iter, &extra_data)) |
| return false; |
| *r = media::VideoDecoderConfig(codec, profile, format, color_space, |
| coded_size, visible_rect, natural_size, |
| - extra_data, is_encrypted); |
| + extra_data, encryption_scheme); |
| return true; |
| } |
| @@ -105,4 +118,45 @@ void ParamTraits<media::VideoDecoderConfig>::Log( |
| l->append(base::StringPrintf("<VideoDecoderConfig>")); |
| } |
| +void ParamTraits<media::EncryptionScheme>::Write( |
| + Message* m, const param_type& p) { |
| + WriteParam(m, p.mode()); |
| + WriteParam(m, p.pattern()); |
| +} |
| + |
| +bool ParamTraits<media::EncryptionScheme>::Read( |
| + const Message* m, base::PickleIterator* iter, param_type* r) { |
| + media::EncryptionScheme::CipherMode mode; |
| + media::EncryptionScheme::PatternSpec pattern; |
| + if (!ReadParam(m, iter, &mode) || !ReadParam(m, iter, &pattern)) |
| + return false; |
| + *r = media::EncryptionScheme(mode, pattern); |
| + return true; |
| +} |
| + |
| +void ParamTraits<media::EncryptionScheme>::Log( |
| + const param_type& p, std::string* l) { |
| + l->append(base::StringPrintf("<EncryptionScheme>")); |
| +} |
| + |
| +void ParamTraits<media::EncryptionScheme::PatternSpec>::Write( |
| + Message* m, const param_type& p) { |
| + WriteParam(m, p.encrypt_blocks()); |
| + WriteParam(m, p.skip_blocks()); |
| +} |
| + |
| +bool ParamTraits<media::EncryptionScheme::PatternSpec>::Read( |
| + const Message* m, base::PickleIterator* iter, param_type* r) { |
| + uint32_t encrypt_blocks, skip_blocks; |
| + if (!ReadParam(m, iter, &encrypt_blocks) || !ReadParam(m, iter, &skip_blocks)) |
| + return false; |
| + *r = media::EncryptionScheme::PatternSpec(encrypt_blocks, skip_blocks); |
| + return true; |
| +} |
| + |
| +void ParamTraits<media::EncryptionScheme::PatternSpec>::Log( |
| + const param_type& p, std::string* l) { |
| + l->append(base::StringPrintf("<PatternSpec>")); |
| +} |
| + |
| } // namespace IPC |