OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 #include "base/logging.h" | |
9 #include "chromecast/media/cma/ipc/media_message.h" | |
10 | |
11 namespace chromecast { | |
12 namespace media { | |
13 | |
14 namespace { | |
15 | |
16 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
| |
17 public: | |
18 static void Write(const ::media::EncryptionScheme::PatternSpec& pattern, | |
19 MediaMessage* msg) { | |
20 CHECK(msg->WritePod(pattern.encrypt_blocks())); | |
21 CHECK(msg->WritePod(pattern.skip_blocks())); | |
22 } | |
23 | |
24 static ::media::EncryptionScheme::PatternSpec Read(MediaMessage* msg) { | |
25 uint32_t encrypt_blocks; | |
26 uint32_t skip_blocks; | |
27 CHECK(msg->ReadPod(&encrypt_blocks)); | |
28 CHECK(msg->ReadPod(&skip_blocks)); | |
29 return ::media::EncryptionScheme::PatternSpec(encrypt_blocks, skip_blocks); | |
30 } | |
31 }; | |
32 | |
33 } // namespace | |
34 | |
35 // static | |
36 void EncryptionSchemeMarshaller::Write( | |
37 const ::media::EncryptionScheme& encryption_scheme, | |
38 MediaMessage* msg) { | |
39 CHECK(msg->WritePod(encryption_scheme.mode())); | |
40 PatternSpecMarshaller::Write(encryption_scheme.pattern(), msg); | |
41 } | |
42 | |
43 // static | |
44 ::media::EncryptionScheme EncryptionSchemeMarshaller::Read(MediaMessage* msg) { | |
45 ::media::EncryptionScheme::CipherMode mode; | |
46 ::media::EncryptionScheme::PatternSpec pattern; | |
47 CHECK(msg->ReadPod(&mode)); | |
48 pattern = PatternSpecMarshaller::Read(msg); | |
49 return ::media::EncryptionScheme(mode, pattern); | |
50 } | |
51 | |
52 } // namespace media | |
53 } // namespace chromecast | |
OLD | NEW |