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) {} | |
44 | 43 |
45 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, | 44 VideoDecoderConfig::VideoDecoderConfig( |
46 VideoCodecProfile profile, | 45 VideoCodec codec, |
47 VideoPixelFormat format, | 46 VideoCodecProfile profile, |
48 ColorSpace color_space, | 47 VideoPixelFormat format, |
49 const gfx::Size& coded_size, | 48 ColorSpace color_space, |
50 const gfx::Rect& visible_rect, | 49 const gfx::Size& coded_size, |
51 const gfx::Size& natural_size, | 50 const gfx::Rect& visible_rect, |
52 const std::vector<uint8_t>& extra_data, | 51 const gfx::Size& natural_size, |
53 bool is_encrypted) { | 52 const std::vector<uint8_t>& extra_data, |
| 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, is_encrypted); | 55 natural_size, extra_data, encryption_scheme); |
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 bool is_encrypted) { | 71 const EncryptionScheme& encryption_scheme) { |
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 is_encrypted_ = is_encrypted; | 80 encryption_scheme_ = encryption_scheme; |
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()) && | 92 return ((codec() == config.codec()) && (format() == config.format()) && |
93 (format() == config.format()) && | |
94 (profile() == config.profile()) && | 93 (profile() == config.profile()) && |
95 (coded_size() == config.coded_size()) && | 94 (coded_size() == config.coded_size()) && |
96 (visible_rect() == config.visible_rect()) && | 95 (visible_rect() == config.visible_rect()) && |
97 (natural_size() == config.natural_size()) && | 96 (natural_size() == config.natural_size()) && |
98 (extra_data() == config.extra_data()) && | 97 (extra_data() == config.extra_data()) && |
99 (is_encrypted() == config.is_encrypted())); | 98 (encryption_scheme().Matches(config.encryption_scheme()))); |
100 } | 99 } |
101 | 100 |
102 std::string VideoDecoderConfig::AsHumanReadableString() const { | 101 std::string VideoDecoderConfig::AsHumanReadableString() const { |
103 std::ostringstream s; | 102 std::ostringstream s; |
104 s << "codec: " << GetCodecName(codec()) << " format: " << format() | 103 s << "codec: " << GetCodecName(codec()) << " format: " << format() |
105 << " profile: " << GetProfileName(profile()) << " coded size: [" | 104 << " profile: " << GetProfileName(profile()) << " coded size: [" |
106 << coded_size().width() << "," << coded_size().height() << "]" | 105 << coded_size().width() << "," << coded_size().height() << "]" |
107 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() | 106 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() |
108 << "," << visible_rect().width() << "," << visible_rect().height() << "]" | 107 << "," << visible_rect().width() << "," << visible_rect().height() << "]" |
109 << " natural size: [" << natural_size().width() << "," | 108 << " natural size: [" << natural_size().width() << "," |
110 << natural_size().height() << "]" | 109 << natural_size().height() << "]" |
111 << " has extra data? " << (extra_data().empty() ? "false" : "true") | 110 << " has extra data? " << (extra_data().empty() ? "false" : "true") |
112 << " encrypted? " << (is_encrypted() ? "true" : "false"); | 111 << " encrypted? " << (is_encrypted() ? "true" : "false"); |
113 return s.str(); | 112 return s.str(); |
114 } | 113 } |
115 | 114 |
116 } // namespace media | 115 } // namespace media |
OLD | NEW |