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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 case VP9PROFILE_ANY: | 32 case VP9PROFILE_ANY: |
33 return kCodecVP9; | 33 return kCodecVP9; |
34 } | 34 } |
35 NOTREACHED(); | 35 NOTREACHED(); |
36 return kUnknownVideoCodec; | 36 return kUnknownVideoCodec; |
37 } | 37 } |
38 | 38 |
39 VideoDecoderConfig::VideoDecoderConfig() | 39 VideoDecoderConfig::VideoDecoderConfig() |
40 : codec_(kUnknownVideoCodec), | 40 : codec_(kUnknownVideoCodec), |
41 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), | 41 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), |
42 format_(PIXEL_FORMAT_UNKNOWN) {} | 42 format_(PIXEL_FORMAT_UNKNOWN), |
| 43 is_encrypted_(false) {} |
43 | 44 |
44 VideoDecoderConfig::VideoDecoderConfig( | 45 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, |
45 VideoCodec codec, | 46 VideoCodecProfile profile, |
46 VideoCodecProfile profile, | 47 VideoPixelFormat format, |
47 VideoPixelFormat format, | 48 ColorSpace color_space, |
48 ColorSpace color_space, | 49 const gfx::Size& coded_size, |
49 const gfx::Size& coded_size, | 50 const gfx::Rect& visible_rect, |
50 const gfx::Rect& visible_rect, | 51 const gfx::Size& natural_size, |
51 const gfx::Size& natural_size, | 52 const std::vector<uint8_t>& extra_data, |
52 const std::vector<uint8_t>& extra_data, | 53 bool is_encrypted) { |
53 const EncryptionScheme& encryption_scheme) { | |
54 Initialize(codec, profile, format, color_space, coded_size, visible_rect, | 54 Initialize(codec, profile, format, color_space, coded_size, visible_rect, |
55 natural_size, extra_data, encryption_scheme); | 55 natural_size, extra_data, is_encrypted); |
56 } | 56 } |
57 | 57 |
58 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) = | 58 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) = |
59 default; | 59 default; |
60 | 60 |
61 VideoDecoderConfig::~VideoDecoderConfig() {} | 61 VideoDecoderConfig::~VideoDecoderConfig() {} |
62 | 62 |
63 void VideoDecoderConfig::Initialize(VideoCodec codec, | 63 void VideoDecoderConfig::Initialize(VideoCodec codec, |
64 VideoCodecProfile profile, | 64 VideoCodecProfile profile, |
65 VideoPixelFormat format, | 65 VideoPixelFormat format, |
66 ColorSpace color_space, | 66 ColorSpace color_space, |
67 const gfx::Size& coded_size, | 67 const gfx::Size& coded_size, |
68 const gfx::Rect& visible_rect, | 68 const gfx::Rect& visible_rect, |
69 const gfx::Size& natural_size, | 69 const gfx::Size& natural_size, |
70 const std::vector<uint8_t>& extra_data, | 70 const std::vector<uint8_t>& extra_data, |
71 const EncryptionScheme& encryption_scheme) { | 71 bool is_encrypted) { |
72 codec_ = codec; | 72 codec_ = codec; |
73 profile_ = profile; | 73 profile_ = profile; |
74 format_ = format; | 74 format_ = format; |
75 color_space_ = color_space; | 75 color_space_ = color_space; |
76 coded_size_ = coded_size; | 76 coded_size_ = coded_size; |
77 visible_rect_ = visible_rect; | 77 visible_rect_ = visible_rect; |
78 natural_size_ = natural_size; | 78 natural_size_ = natural_size; |
79 extra_data_ = extra_data; | 79 extra_data_ = extra_data; |
80 encryption_scheme_ = encryption_scheme; | 80 is_encrypted_ = is_encrypted; |
81 } | 81 } |
82 | 82 |
83 bool VideoDecoderConfig::IsValidConfig() const { | 83 bool VideoDecoderConfig::IsValidConfig() const { |
84 return codec_ != kUnknownVideoCodec && | 84 return codec_ != kUnknownVideoCodec && |
85 natural_size_.width() > 0 && | 85 natural_size_.width() > 0 && |
86 natural_size_.height() > 0 && | 86 natural_size_.height() > 0 && |
87 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, | 87 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, |
88 coded_size_, visible_rect_, natural_size_); | 88 coded_size_, visible_rect_, natural_size_); |
89 } | 89 } |
90 | 90 |
91 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const { | 91 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const { |
92 return ((codec() == config.codec()) && (format() == config.format()) && | 92 return ((codec() == config.codec()) && |
| 93 (format() == config.format()) && |
93 (profile() == config.profile()) && | 94 (profile() == config.profile()) && |
94 (coded_size() == config.coded_size()) && | 95 (coded_size() == config.coded_size()) && |
95 (visible_rect() == config.visible_rect()) && | 96 (visible_rect() == config.visible_rect()) && |
96 (natural_size() == config.natural_size()) && | 97 (natural_size() == config.natural_size()) && |
97 (extra_data() == config.extra_data()) && | 98 (extra_data() == config.extra_data()) && |
98 (encryption_scheme().Matches(config.encryption_scheme()))); | 99 (is_encrypted() == config.is_encrypted())); |
99 } | 100 } |
100 | 101 |
101 std::string VideoDecoderConfig::AsHumanReadableString() const { | 102 std::string VideoDecoderConfig::AsHumanReadableString() const { |
102 std::ostringstream s; | 103 std::ostringstream s; |
103 s << "codec: " << GetCodecName(codec()) << " format: " << format() | 104 s << "codec: " << GetCodecName(codec()) << " format: " << format() |
104 << " profile: " << GetProfileName(profile()) << " coded size: [" | 105 << " profile: " << GetProfileName(profile()) << " coded size: [" |
105 << coded_size().width() << "," << coded_size().height() << "]" | 106 << coded_size().width() << "," << coded_size().height() << "]" |
106 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() | 107 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() |
107 << "," << visible_rect().width() << "," << visible_rect().height() << "]" | 108 << "," << visible_rect().width() << "," << visible_rect().height() << "]" |
108 << " natural size: [" << natural_size().width() << "," | 109 << " natural size: [" << natural_size().width() << "," |
109 << natural_size().height() << "]" | 110 << natural_size().height() << "]" |
110 << " has extra data? " << (extra_data().empty() ? "false" : "true") | 111 << " has extra data? " << (extra_data().empty() ? "false" : "true") |
111 << " encrypted? " << (is_encrypted() ? "true" : "false"); | 112 << " encrypted? " << (is_encrypted() ? "true" : "false"); |
112 return s.str(); | 113 return s.str(); |
113 } | 114 } |
114 | 115 |
115 } // namespace media | 116 } // namespace media |
OLD | NEW |