OLD | NEW |
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chromecast/media/cma/ipc/media_message.h" | 9 #include "chromecast/media/cma/ipc/media_message.h" |
10 #include "media/base/video_decoder_config.h" | 10 #include "media/base/video_decoder_config.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 }; | 52 }; |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 // static | 56 // static |
57 void VideoDecoderConfigMarshaller::Write( | 57 void VideoDecoderConfigMarshaller::Write( |
58 const ::media::VideoDecoderConfig& config, MediaMessage* msg) { | 58 const ::media::VideoDecoderConfig& config, MediaMessage* msg) { |
59 CHECK(msg->WritePod(config.codec())); | 59 CHECK(msg->WritePod(config.codec())); |
60 CHECK(msg->WritePod(config.profile())); | 60 CHECK(msg->WritePod(config.profile())); |
61 CHECK(msg->WritePod(config.format())); | 61 CHECK(msg->WritePod(config.format())); |
62 CHECK(msg->WritePod(config.color_space())); | |
63 SizeMarshaller::Write(config.coded_size(), msg); | 62 SizeMarshaller::Write(config.coded_size(), msg); |
64 RectMarshaller::Write(config.visible_rect(), msg); | 63 RectMarshaller::Write(config.visible_rect(), msg); |
65 SizeMarshaller::Write(config.natural_size(), msg); | 64 SizeMarshaller::Write(config.natural_size(), msg); |
66 CHECK(msg->WritePod(config.is_encrypted())); | 65 CHECK(msg->WritePod(config.is_encrypted())); |
67 CHECK(msg->WritePod(config.extra_data_size())); | 66 CHECK(msg->WritePod(config.extra_data_size())); |
68 if (config.extra_data_size() > 0) | 67 if (config.extra_data_size() > 0) |
69 CHECK(msg->WriteBuffer(config.extra_data(), config.extra_data_size())); | 68 CHECK(msg->WriteBuffer(config.extra_data(), config.extra_data_size())); |
70 } | 69 } |
71 | 70 |
72 // static | 71 // static |
73 ::media::VideoDecoderConfig VideoDecoderConfigMarshaller::Read( | 72 ::media::VideoDecoderConfig VideoDecoderConfigMarshaller::Read( |
74 MediaMessage* msg) { | 73 MediaMessage* msg) { |
75 ::media::VideoCodec codec; | 74 ::media::VideoCodec codec; |
76 ::media::VideoCodecProfile profile; | 75 ::media::VideoCodecProfile profile; |
77 ::media::VideoFrame::Format format; | 76 ::media::VideoFrame::Format format; |
78 ::media::VideoFrame::ColorSpace color_space; | |
79 gfx::Size coded_size; | 77 gfx::Size coded_size; |
80 gfx::Rect visible_rect; | 78 gfx::Rect visible_rect; |
81 gfx::Size natural_size; | 79 gfx::Size natural_size; |
82 bool is_encrypted; | 80 bool is_encrypted; |
83 size_t extra_data_size; | 81 size_t extra_data_size; |
84 scoped_ptr<uint8[]> extra_data; | 82 scoped_ptr<uint8[]> extra_data; |
85 | 83 |
86 CHECK(msg->ReadPod(&codec)); | 84 CHECK(msg->ReadPod(&codec)); |
87 CHECK(msg->ReadPod(&profile)); | 85 CHECK(msg->ReadPod(&profile)); |
88 CHECK(msg->ReadPod(&format)); | 86 CHECK(msg->ReadPod(&format)); |
89 CHECK(msg->ReadPod(&color_space)); | |
90 coded_size = SizeMarshaller::Read(msg); | 87 coded_size = SizeMarshaller::Read(msg); |
91 visible_rect = RectMarshaller::Read(msg); | 88 visible_rect = RectMarshaller::Read(msg); |
92 natural_size = SizeMarshaller::Read(msg); | 89 natural_size = SizeMarshaller::Read(msg); |
93 CHECK(msg->ReadPod(&is_encrypted)); | 90 CHECK(msg->ReadPod(&is_encrypted)); |
94 CHECK(msg->ReadPod(&extra_data_size)); | 91 CHECK(msg->ReadPod(&extra_data_size)); |
95 | 92 |
96 CHECK_GE(codec, ::media::kUnknownVideoCodec); | 93 CHECK_GE(codec, ::media::kUnknownVideoCodec); |
97 CHECK_LE(codec, ::media::kVideoCodecMax); | 94 CHECK_LE(codec, ::media::kVideoCodecMax); |
98 CHECK_GE(profile, ::media::VIDEO_CODEC_PROFILE_UNKNOWN); | 95 CHECK_GE(profile, ::media::VIDEO_CODEC_PROFILE_UNKNOWN); |
99 CHECK_LE(profile, ::media::VIDEO_CODEC_PROFILE_MAX); | 96 CHECK_LE(profile, ::media::VIDEO_CODEC_PROFILE_MAX); |
100 CHECK_GE(format, ::media::VideoFrame::UNKNOWN); | 97 CHECK_GE(format, ::media::VideoFrame::UNKNOWN); |
101 CHECK_LE(format, ::media::VideoFrame::FORMAT_MAX); | 98 CHECK_LE(format, ::media::VideoFrame::FORMAT_MAX); |
102 CHECK_GE(color_space, ::media::VideoFrame::COLOR_SPACE_UNSPECIFIED); | |
103 CHECK_LE(color_space, ::media::VideoFrame::COLOR_SPACE_MAX); | |
104 CHECK_LT(extra_data_size, kMaxExtraDataSize); | 99 CHECK_LT(extra_data_size, kMaxExtraDataSize); |
105 if (extra_data_size > 0) { | 100 if (extra_data_size > 0) { |
106 extra_data.reset(new uint8[extra_data_size]); | 101 extra_data.reset(new uint8[extra_data_size]); |
107 CHECK(msg->ReadBuffer(extra_data.get(), extra_data_size)); | 102 CHECK(msg->ReadBuffer(extra_data.get(), extra_data_size)); |
108 } | 103 } |
109 | 104 |
110 return ::media::VideoDecoderConfig( | 105 return ::media::VideoDecoderConfig( |
111 codec, profile, format, color_space, | 106 codec, profile, format, |
112 coded_size, visible_rect, natural_size, | 107 coded_size, visible_rect, natural_size, |
113 extra_data.get(), extra_data_size, | 108 extra_data.get(), extra_data_size, |
114 is_encrypted); | 109 is_encrypted); |
115 } | 110 } |
116 | 111 |
117 } // namespace media | 112 } // namespace media |
118 } // namespace chromecast | 113 } // namespace chromecast |
OLD | NEW |