OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/base/video_decoder_config.h" | 5 #include "media/base/video_decoder_config.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 VideoDecoderConfig::VideoDecoderConfig() | 12 VideoDecoderConfig::VideoDecoderConfig() |
13 : codec_(kUnknownVideoCodec), | 13 : codec_(kUnknownVideoCodec), |
14 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), | 14 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), |
15 format_(VideoFrame::UNKNOWN), | 15 format_(VideoFrame::UNKNOWN), |
16 is_encrypted_(false) { | 16 is_encrypted_(false) { |
17 } | 17 } |
18 | 18 |
19 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, | 19 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, |
20 VideoCodecProfile profile, | 20 VideoCodecProfile profile, |
21 VideoFrame::Format format, | 21 VideoFrame::Format format, |
22 VideoFrame::ColorSpace color_space, | |
23 const gfx::Size& coded_size, | 22 const gfx::Size& coded_size, |
24 const gfx::Rect& visible_rect, | 23 const gfx::Rect& visible_rect, |
25 const gfx::Size& natural_size, | 24 const gfx::Size& natural_size, |
26 const uint8* extra_data, | 25 const uint8* extra_data, |
27 size_t extra_data_size, | 26 size_t extra_data_size, |
28 bool is_encrypted) { | 27 bool is_encrypted) { |
29 Initialize(codec, profile, format, color_space, | 28 Initialize(codec, profile, format, VideoFrame::COLOR_SPACE_UNSPECIFIED, |
30 coded_size, visible_rect, natural_size, extra_data, | 29 coded_size, visible_rect, natural_size, extra_data, |
31 extra_data_size, is_encrypted, true); | 30 extra_data_size, is_encrypted, true); |
32 } | 31 } |
33 | 32 |
34 VideoDecoderConfig::~VideoDecoderConfig() {} | 33 VideoDecoderConfig::~VideoDecoderConfig() {} |
35 | 34 |
36 // Some videos just want to watch the world burn, with a height of 0; cap the | 35 // Some videos just want to watch the world burn, with a height of 0; cap the |
37 // "infinite" aspect ratio resulting. | 36 // "infinite" aspect ratio resulting. |
38 static const int kInfiniteRatio = 99999; | 37 static const int kInfiniteRatio = 99999; |
39 | 38 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); | 80 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); |
82 UMA_HISTOGRAM_ENUMERATION("Media.VideoFramePixelFormat", format, | 81 UMA_HISTOGRAM_ENUMERATION("Media.VideoFramePixelFormat", format, |
83 VideoFrame::FORMAT_MAX + 1); | 82 VideoFrame::FORMAT_MAX + 1); |
84 UMA_HISTOGRAM_ENUMERATION("Media.VideoFrameColorSpace", color_space, | 83 UMA_HISTOGRAM_ENUMERATION("Media.VideoFrameColorSpace", color_space, |
85 VideoFrame::COLOR_SPACE_MAX + 1); | 84 VideoFrame::COLOR_SPACE_MAX + 1); |
86 } | 85 } |
87 | 86 |
88 codec_ = codec; | 87 codec_ = codec; |
89 profile_ = profile; | 88 profile_ = profile; |
90 format_ = format; | 89 format_ = format; |
91 color_space_ = color_space; | |
92 coded_size_ = coded_size; | 90 coded_size_ = coded_size; |
93 visible_rect_ = visible_rect; | 91 visible_rect_ = visible_rect; |
94 natural_size_ = natural_size; | 92 natural_size_ = natural_size; |
95 extra_data_.assign(extra_data, extra_data + extra_data_size); | 93 extra_data_.assign(extra_data, extra_data + extra_data_size); |
96 is_encrypted_ = is_encrypted; | 94 is_encrypted_ = is_encrypted; |
97 } | 95 } |
98 | 96 |
99 bool VideoDecoderConfig::IsValidConfig() const { | 97 bool VideoDecoderConfig::IsValidConfig() const { |
100 return codec_ != kUnknownVideoCodec && | 98 return codec_ != kUnknownVideoCodec && |
101 natural_size_.width() > 0 && | 99 natural_size_.width() > 0 && |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return "theora"; | 150 return "theora"; |
153 case kCodecVP8: | 151 case kCodecVP8: |
154 return "vp8"; | 152 return "vp8"; |
155 case kCodecVP9: | 153 case kCodecVP9: |
156 return "vp9"; | 154 return "vp9"; |
157 } | 155 } |
158 NOTREACHED(); | 156 NOTREACHED(); |
159 return ""; | 157 return ""; |
160 } | 158 } |
161 | 159 |
| 160 VideoCodec VideoDecoderConfig::codec() const { |
| 161 return codec_; |
| 162 } |
| 163 |
| 164 VideoCodecProfile VideoDecoderConfig::profile() const { |
| 165 return profile_; |
| 166 } |
| 167 |
| 168 VideoFrame::Format VideoDecoderConfig::format() const { |
| 169 return format_; |
| 170 } |
| 171 |
| 172 gfx::Size VideoDecoderConfig::coded_size() const { |
| 173 return coded_size_; |
| 174 } |
| 175 |
| 176 gfx::Rect VideoDecoderConfig::visible_rect() const { |
| 177 return visible_rect_; |
| 178 } |
| 179 |
| 180 gfx::Size VideoDecoderConfig::natural_size() const { |
| 181 return natural_size_; |
| 182 } |
| 183 |
162 const uint8* VideoDecoderConfig::extra_data() const { | 184 const uint8* VideoDecoderConfig::extra_data() const { |
163 if (extra_data_.empty()) | 185 if (extra_data_.empty()) |
164 return NULL; | 186 return NULL; |
165 return &extra_data_[0]; | 187 return &extra_data_[0]; |
166 } | 188 } |
167 | 189 |
| 190 size_t VideoDecoderConfig::extra_data_size() const { |
| 191 return extra_data_.size(); |
| 192 } |
| 193 |
| 194 bool VideoDecoderConfig::is_encrypted() const { |
| 195 return is_encrypted_; |
| 196 } |
| 197 |
168 } // namespace media | 198 } // namespace media |
OLD | NEW |