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

Side by Side Diff: chromecast/media/cma/ipc_streamer/video_decoder_config_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: more ddorwin comments Created 4 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.h" 5 #include "chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chromecast/media/cma/ipc/media_message.h" 13 #include "chromecast/media/cma/ipc/media_message.h"
14 #include "chromecast/media/cma/ipc_streamer/encryption_scheme_marshaller.h"
14 #include "media/base/video_decoder_config.h" 15 #include "media/base/video_decoder_config.h"
15 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 18
18 namespace chromecast { 19 namespace chromecast {
19 namespace media { 20 namespace media {
20 21
21 namespace { 22 namespace {
22 const size_t kMaxExtraDataSize = 16 * 1024; 23 const size_t kMaxExtraDataSize = 16 * 1024;
23 24
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // static 61 // static
61 void VideoDecoderConfigMarshaller::Write( 62 void VideoDecoderConfigMarshaller::Write(
62 const ::media::VideoDecoderConfig& config, MediaMessage* msg) { 63 const ::media::VideoDecoderConfig& config, MediaMessage* msg) {
63 CHECK(msg->WritePod(config.codec())); 64 CHECK(msg->WritePod(config.codec()));
64 CHECK(msg->WritePod(config.profile())); 65 CHECK(msg->WritePod(config.profile()));
65 CHECK(msg->WritePod(config.format())); 66 CHECK(msg->WritePod(config.format()));
66 CHECK(msg->WritePod(config.color_space())); 67 CHECK(msg->WritePod(config.color_space()));
67 SizeMarshaller::Write(config.coded_size(), msg); 68 SizeMarshaller::Write(config.coded_size(), msg);
68 RectMarshaller::Write(config.visible_rect(), msg); 69 RectMarshaller::Write(config.visible_rect(), msg);
69 SizeMarshaller::Write(config.natural_size(), msg); 70 SizeMarshaller::Write(config.natural_size(), msg);
70 CHECK(msg->WritePod(config.is_encrypted())); 71 EncryptionSchemeMarshaller::Write(config.encryption_scheme(), msg);
71 CHECK(msg->WritePod(config.extra_data().size())); 72 CHECK(msg->WritePod(config.extra_data().size()));
72 if (!config.extra_data().empty()) 73 if (!config.extra_data().empty())
73 CHECK(msg->WriteBuffer(&config.extra_data()[0], 74 CHECK(msg->WriteBuffer(&config.extra_data()[0],
74 config.extra_data().size())); 75 config.extra_data().size()));
75 } 76 }
76 77
77 // static 78 // static
78 ::media::VideoDecoderConfig VideoDecoderConfigMarshaller::Read( 79 ::media::VideoDecoderConfig VideoDecoderConfigMarshaller::Read(
79 MediaMessage* msg) { 80 MediaMessage* msg) {
80 ::media::VideoCodec codec; 81 ::media::VideoCodec codec;
81 ::media::VideoCodecProfile profile; 82 ::media::VideoCodecProfile profile;
82 ::media::VideoPixelFormat format; 83 ::media::VideoPixelFormat format;
83 ::media::ColorSpace color_space; 84 ::media::ColorSpace color_space;
84 gfx::Size coded_size; 85 gfx::Size coded_size;
85 gfx::Rect visible_rect; 86 gfx::Rect visible_rect;
86 gfx::Size natural_size; 87 gfx::Size natural_size;
87 bool is_encrypted;
88 size_t extra_data_size; 88 size_t extra_data_size;
89 ::media::EncryptionScheme encryption_scheme;
89 std::vector<uint8_t> extra_data; 90 std::vector<uint8_t> extra_data;
90 91
91 CHECK(msg->ReadPod(&codec)); 92 CHECK(msg->ReadPod(&codec));
92 CHECK(msg->ReadPod(&profile)); 93 CHECK(msg->ReadPod(&profile));
93 CHECK(msg->ReadPod(&format)); 94 CHECK(msg->ReadPod(&format));
94 CHECK(msg->ReadPod(&color_space)); 95 CHECK(msg->ReadPod(&color_space));
95 coded_size = SizeMarshaller::Read(msg); 96 coded_size = SizeMarshaller::Read(msg);
96 visible_rect = RectMarshaller::Read(msg); 97 visible_rect = RectMarshaller::Read(msg);
97 natural_size = SizeMarshaller::Read(msg); 98 natural_size = SizeMarshaller::Read(msg);
98 CHECK(msg->ReadPod(&is_encrypted)); 99 encryption_scheme = EncryptionSchemeMarshaller::Read(msg);
99 CHECK(msg->ReadPod(&extra_data_size)); 100 CHECK(msg->ReadPod(&extra_data_size));
100 101
101 CHECK_GE(codec, ::media::kUnknownVideoCodec); 102 CHECK_GE(codec, ::media::kUnknownVideoCodec);
102 CHECK_LE(codec, ::media::kVideoCodecMax); 103 CHECK_LE(codec, ::media::kVideoCodecMax);
103 CHECK_GE(profile, ::media::VIDEO_CODEC_PROFILE_UNKNOWN); 104 CHECK_GE(profile, ::media::VIDEO_CODEC_PROFILE_UNKNOWN);
104 CHECK_LE(profile, ::media::VIDEO_CODEC_PROFILE_MAX); 105 CHECK_LE(profile, ::media::VIDEO_CODEC_PROFILE_MAX);
105 CHECK_GE(format, ::media::PIXEL_FORMAT_UNKNOWN); 106 CHECK_GE(format, ::media::PIXEL_FORMAT_UNKNOWN);
106 CHECK_LE(format, ::media::PIXEL_FORMAT_MAX); 107 CHECK_LE(format, ::media::PIXEL_FORMAT_MAX);
107 CHECK_GE(color_space, ::media::COLOR_SPACE_UNSPECIFIED); 108 CHECK_GE(color_space, ::media::COLOR_SPACE_UNSPECIFIED);
108 CHECK_LE(color_space, ::media::COLOR_SPACE_MAX); 109 CHECK_LE(color_space, ::media::COLOR_SPACE_MAX);
109 CHECK_LT(extra_data_size, kMaxExtraDataSize); 110 CHECK_LT(extra_data_size, kMaxExtraDataSize);
110 if (extra_data_size > 0) { 111 if (extra_data_size > 0) {
111 extra_data.resize(extra_data_size); 112 extra_data.resize(extra_data_size);
112 CHECK(msg->ReadBuffer(&extra_data[0], extra_data.size())); 113 CHECK(msg->ReadBuffer(&extra_data[0], extra_data.size()));
113 } 114 }
114 115
115 return ::media::VideoDecoderConfig( 116 return ::media::VideoDecoderConfig(
116 codec, profile, format, color_space, 117 codec, profile, format, color_space,
117 coded_size, visible_rect, natural_size, 118 coded_size, visible_rect, natural_size,
118 extra_data, is_encrypted); 119 extra_data, encryption_scheme);
119 } 120 }
120 121
121 } // namespace media 122 } // namespace media
122 } // namespace chromecast 123 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698