diff options
Diffstat (limited to 'chromecast/media/cma/ipc_streamer')
5 files changed, 93 insertions, 8 deletions
diff --git a/chromecast/media/cma/ipc_streamer/BUILD.gn b/chromecast/media/cma/ipc_streamer/BUILD.gn index a3429d6..7d25f45 100644 --- a/chromecast/media/cma/ipc_streamer/BUILD.gn +++ b/chromecast/media/cma/ipc_streamer/BUILD.gn @@ -14,6 +14,8 @@ source_set("ipc_streamer") { "decoder_buffer_base_marshaller.h", "decrypt_config_marshaller.cc", "decrypt_config_marshaller.h", + "encryption_scheme_marshaller.cc", + "encryption_scheme_marshaller.h", "video_decoder_config_marshaller.cc", "video_decoder_config_marshaller.h", ] diff --git a/chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.cc b/chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.cc index 2798c6b..031571a 100644 --- a/chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.cc +++ b/chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "chromecast/media/cma/ipc/media_message.h" +#include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h" #include "media/base/audio_decoder_config.h" namespace chromecast { @@ -27,7 +28,7 @@ void AudioDecoderConfigMarshaller::Write( CHECK(msg->WritePod(config.channel_layout())); CHECK(msg->WritePod(config.samples_per_second())); CHECK(msg->WritePod(config.sample_format())); - CHECK(msg->WritePod(config.is_encrypted())); + EncryptionSchemeMarshaller::Write(config.encryption_scheme(), msg); CHECK(msg->WritePod(config.extra_data().size())); if (!config.extra_data().empty()) CHECK(msg->WriteBuffer(&config.extra_data()[0], @@ -41,15 +42,15 @@ void AudioDecoderConfigMarshaller::Write( ::media::SampleFormat sample_format; ::media::ChannelLayout channel_layout; int samples_per_second; - bool is_encrypted; size_t extra_data_size; std::vector<uint8_t> extra_data; + ::media::EncryptionScheme encryption_scheme; CHECK(msg->ReadPod(&codec)); CHECK(msg->ReadPod(&channel_layout)); CHECK(msg->ReadPod(&samples_per_second)); CHECK(msg->ReadPod(&sample_format)); - CHECK(msg->ReadPod(&is_encrypted)); + encryption_scheme = EncryptionSchemeMarshaller::Read(msg); CHECK(msg->ReadPod(&extra_data_size)); CHECK_GE(codec, ::media::kUnknownAudioCodec); @@ -67,7 +68,7 @@ void AudioDecoderConfigMarshaller::Write( return ::media::AudioDecoderConfig( codec, sample_format, channel_layout, samples_per_second, - extra_data, is_encrypted); + extra_data, encryption_scheme); } } // namespace media diff --git a/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc b/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc new file mode 100644 index 0000000..a88cfc5 --- /dev/null +++ b/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc @@ -0,0 +1,54 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h" + +#include <stdint.h> + +#include "base/logging.h" +#include "chromecast/media/cma/ipc/media_message.h" + +namespace chromecast { +namespace media { + +namespace { + +class PatternSpecMarshaller { + public: + static void Write(const ::media::EncryptionScheme::Pattern& pattern, + MediaMessage* msg) { + CHECK(msg->WritePod(pattern.encrypt_blocks())); + CHECK(msg->WritePod(pattern.skip_blocks())); + } + + static ::media::EncryptionScheme::Pattern Read(MediaMessage* msg) { + uint32_t encrypt_blocks; + uint32_t skip_blocks; + CHECK(msg->ReadPod(&encrypt_blocks)); + CHECK(msg->ReadPod(&skip_blocks)); + return ::media::EncryptionScheme::Pattern(encrypt_blocks, skip_blocks); + } +}; + +} // namespace + +// static +void EncryptionSchemeMarshaller::Write( + const ::media::EncryptionScheme& encryption_scheme, + MediaMessage* msg) { + CHECK(msg->WritePod(encryption_scheme.mode())); + PatternSpecMarshaller::Write(encryption_scheme.pattern(), msg); +} + +// static +::media::EncryptionScheme EncryptionSchemeMarshaller::Read(MediaMessage* msg) { + ::media::EncryptionScheme::CipherMode mode; + ::media::EncryptionScheme::Pattern pattern; + CHECK(msg->ReadPod(&mode)); + pattern = PatternSpecMarshaller::Read(msg); + return ::media::EncryptionScheme(mode, pattern); +} + +} // namespace media +} // namespace chromecast diff --git a/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h b/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h new file mode 100644 index 0000000..0b3371b --- /dev/null +++ b/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h @@ -0,0 +1,27 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMECAST_MEDIA_CMA_IPC_STREAMER_ENCRYPTION_SCHEME_MARSHALLER_H_ +#define CHROMECAST_MEDIA_CMA_IPC_STREAMER_ENCRYPTION_SCHEME_MARSHALLER_H_ + +#include "media/base/encryption_scheme.h" + +namespace chromecast { +namespace media { +class MediaMessage; + +class EncryptionSchemeMarshaller { + public: + // Writes the serialized structure of |encryption_scheme| into |msg|. + static void Write( + const ::media::EncryptionScheme& encryption_scheme, MediaMessage* msg); + + // Returns an EncryptionScheme from its serialized structure. + static ::media::EncryptionScheme Read(MediaMessage* msg); +}; + +} // namespace media +} // namespace chromecast + +#endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_ENCRYPTION_SCHEME_MARSHALLER_H_ diff --git a/chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.cc b/chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.cc index b2e9aaa..a471eb6 100644 --- a/chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.cc +++ b/chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "chromecast/media/cma/ipc/media_message.h" +#include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h" #include "media/base/video_decoder_config.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" @@ -67,7 +68,7 @@ void VideoDecoderConfigMarshaller::Write( SizeMarshaller::Write(config.coded_size(), msg); RectMarshaller::Write(config.visible_rect(), msg); SizeMarshaller::Write(config.natural_size(), msg); - CHECK(msg->WritePod(config.is_encrypted())); + EncryptionSchemeMarshaller::Write(config.encryption_scheme(), msg); CHECK(msg->WritePod(config.extra_data().size())); if (!config.extra_data().empty()) CHECK(msg->WriteBuffer(&config.extra_data()[0], @@ -84,8 +85,8 @@ void VideoDecoderConfigMarshaller::Write( gfx::Size coded_size; gfx::Rect visible_rect; gfx::Size natural_size; - bool is_encrypted; size_t extra_data_size; + ::media::EncryptionScheme encryption_scheme; std::vector<uint8_t> extra_data; CHECK(msg->ReadPod(&codec)); @@ -95,7 +96,7 @@ void VideoDecoderConfigMarshaller::Write( coded_size = SizeMarshaller::Read(msg); visible_rect = RectMarshaller::Read(msg); natural_size = SizeMarshaller::Read(msg); - CHECK(msg->ReadPod(&is_encrypted)); + encryption_scheme = EncryptionSchemeMarshaller::Read(msg); CHECK(msg->ReadPod(&extra_data_size)); CHECK_GE(codec, ::media::kUnknownVideoCodec); @@ -115,7 +116,7 @@ void VideoDecoderConfigMarshaller::Write( return ::media::VideoDecoderConfig( codec, profile, format, color_space, coded_size, visible_rect, natural_size, - extra_data, is_encrypted); + extra_data, encryption_scheme); } } // namespace media |