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

Side by Side Diff: media/base/video_decoder_config.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 (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 22 matching lines...) Expand all
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 encryption_scheme_() {}
xhwang 2016/03/03 22:33:01 This is not necessary.
dougsteed 2016/03/04 19:07:30 Done.
44 44
45 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, 45 VideoDecoderConfig::VideoDecoderConfig(
46 VideoCodecProfile profile, 46 VideoCodec codec,
47 VideoPixelFormat format, 47 VideoCodecProfile profile,
48 ColorSpace color_space, 48 VideoPixelFormat format,
49 const gfx::Size& coded_size, 49 ColorSpace color_space,
50 const gfx::Rect& visible_rect, 50 const gfx::Size& coded_size,
51 const gfx::Size& natural_size, 51 const gfx::Rect& visible_rect,
52 const std::vector<uint8_t>& extra_data, 52 const gfx::Size& natural_size,
53 bool is_encrypted) { 53 const std::vector<uint8_t>& extra_data,
54 const EncryptionScheme& encryption_scheme) {
54 Initialize(codec, profile, format, color_space, coded_size, visible_rect, 55 Initialize(codec, profile, format, color_space, coded_size, visible_rect,
55 natural_size, extra_data, is_encrypted); 56 natural_size, extra_data, encryption_scheme);
56 } 57 }
57 58
58 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) = 59 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) =
59 default; 60 default;
60 61
61 VideoDecoderConfig::~VideoDecoderConfig() {} 62 VideoDecoderConfig::~VideoDecoderConfig() {}
62 63
63 void VideoDecoderConfig::Initialize(VideoCodec codec, 64 void VideoDecoderConfig::Initialize(VideoCodec codec,
64 VideoCodecProfile profile, 65 VideoCodecProfile profile,
65 VideoPixelFormat format, 66 VideoPixelFormat format,
66 ColorSpace color_space, 67 ColorSpace color_space,
67 const gfx::Size& coded_size, 68 const gfx::Size& coded_size,
68 const gfx::Rect& visible_rect, 69 const gfx::Rect& visible_rect,
69 const gfx::Size& natural_size, 70 const gfx::Size& natural_size,
70 const std::vector<uint8_t>& extra_data, 71 const std::vector<uint8_t>& extra_data,
71 bool is_encrypted) { 72 const EncryptionScheme& encryption_scheme) {
72 codec_ = codec; 73 codec_ = codec;
73 profile_ = profile; 74 profile_ = profile;
74 format_ = format; 75 format_ = format;
75 color_space_ = color_space; 76 color_space_ = color_space;
76 coded_size_ = coded_size; 77 coded_size_ = coded_size;
77 visible_rect_ = visible_rect; 78 visible_rect_ = visible_rect;
78 natural_size_ = natural_size; 79 natural_size_ = natural_size;
79 extra_data_ = extra_data; 80 extra_data_ = extra_data;
80 is_encrypted_ = is_encrypted; 81 encryption_scheme_ = encryption_scheme;
81 } 82 }
82 83
83 bool VideoDecoderConfig::IsValidConfig() const { 84 bool VideoDecoderConfig::IsValidConfig() const {
84 return codec_ != kUnknownVideoCodec && 85 return codec_ != kUnknownVideoCodec &&
85 natural_size_.width() > 0 && 86 natural_size_.width() > 0 &&
86 natural_size_.height() > 0 && 87 natural_size_.height() > 0 &&
87 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, 88 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY,
88 coded_size_, visible_rect_, natural_size_); 89 coded_size_, visible_rect_, natural_size_);
89 } 90 }
90 91
91 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const { 92 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const {
92 return ((codec() == config.codec()) && 93 return ((codec() == config.codec()) && (format() == config.format()) &&
93 (format() == config.format()) &&
94 (profile() == config.profile()) && 94 (profile() == config.profile()) &&
95 (coded_size() == config.coded_size()) && 95 (coded_size() == config.coded_size()) &&
96 (visible_rect() == config.visible_rect()) && 96 (visible_rect() == config.visible_rect()) &&
97 (natural_size() == config.natural_size()) && 97 (natural_size() == config.natural_size()) &&
98 (extra_data() == config.extra_data()) && 98 (extra_data() == config.extra_data()) &&
99 (is_encrypted() == config.is_encrypted())); 99 (encryption_scheme().Matches(config.encryption_scheme())));
100 } 100 }
101 101
102 std::string VideoDecoderConfig::AsHumanReadableString() const { 102 std::string VideoDecoderConfig::AsHumanReadableString() const {
103 std::ostringstream s; 103 std::ostringstream s;
104 s << "codec: " << GetCodecName(codec()) << " format: " << format() 104 s << "codec: " << GetCodecName(codec()) << " format: " << format()
105 << " profile: " << GetProfileName(profile()) << " coded size: [" 105 << " profile: " << GetProfileName(profile()) << " coded size: ["
106 << coded_size().width() << "," << coded_size().height() << "]" 106 << coded_size().width() << "," << coded_size().height() << "]"
107 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() 107 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y()
108 << "," << visible_rect().width() << "," << visible_rect().height() << "]" 108 << "," << visible_rect().width() << "," << visible_rect().height() << "]"
109 << " natural size: [" << natural_size().width() << "," 109 << " natural size: [" << natural_size().width() << ","
110 << natural_size().height() << "]" 110 << natural_size().height() << "]"
111 << " has extra data? " << (extra_data().empty() ? "false" : "true") 111 << " has extra data? " << (extra_data().empty() ? "false" : "true")
112 << " encrypted? " << (is_encrypted() ? "true" : "false"); 112 << " encrypted? " << (is_encrypted() ? "true" : "false");
113 return s.str(); 113 return s.str();
114 } 114 }
115 115
116 bool VideoDecoderConfig::is_encrypted() const {
117 return encryption_scheme_.is_encrypted();
118 }
xhwang 2016/03/03 22:33:01 nit: this can be inlined in the header file
dougsteed 2016/03/04 19:07:30 Done.
119
116 } // namespace media 120 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698