Chromium Code Reviews| Index: chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc |
| 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 0000000000000000000000000000000000000000..68299b282564b3a403aab65b7a7f2c5cce3ce727 |
| --- /dev/null |
| +++ b/chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
halliwell
2016/01/13 03:29:41
nit: 2014
dougsteed
2016/02/09 22:58:53
Done.
|
| +// 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 "base/basictypes.h" |
| +#include "base/logging.h" |
| +#include "chromecast/media/cma/ipc/media_message.h" |
| + |
| +namespace chromecast { |
| +namespace media { |
| + |
| +namespace { |
| + |
| +class PatternSpecMarshaller { |
|
halliwell
2016/01/13 03:29:41
I don't understand the point of this class? Why n
dougsteed
2016/02/09 22:58:53
For the same reason that PatternSpec is a nested s
|
| + public: |
| + static void Write(const ::media::EncryptionScheme::PatternSpec& pattern, |
| + MediaMessage* msg) { |
| + CHECK(msg->WritePod(pattern.encrypt_blocks())); |
| + CHECK(msg->WritePod(pattern.skip_blocks())); |
| + } |
| + |
| + static ::media::EncryptionScheme::PatternSpec Read(MediaMessage* msg) { |
| + uint32_t encrypt_blocks; |
| + uint32_t skip_blocks; |
| + CHECK(msg->ReadPod(&encrypt_blocks)); |
| + CHECK(msg->ReadPod(&skip_blocks)); |
| + return ::media::EncryptionScheme::PatternSpec(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::PatternSpec pattern; |
| + CHECK(msg->ReadPod(&mode)); |
| + pattern = PatternSpecMarshaller::Read(msg); |
| + return ::media::EncryptionScheme(mode, pattern); |
| +} |
| + |
| +} // namespace media |
| +} // namespace chromecast |