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

Unified Diff: chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.cc

Issue 1490613005: media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more tweak in chromecast/common Created 5 years 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: 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

Powered by Google App Engine
This is Rietveld 408576698