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

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: Created 5 years 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_(false) {}
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() {} 59 VideoDecoderConfig::~VideoDecoderConfig() {}
59 60
60 void VideoDecoderConfig::Initialize(VideoCodec codec, 61 void VideoDecoderConfig::Initialize(VideoCodec codec,
61 VideoCodecProfile profile, 62 VideoCodecProfile profile,
62 VideoPixelFormat format, 63 VideoPixelFormat format,
63 ColorSpace color_space, 64 ColorSpace color_space,
64 const gfx::Size& coded_size, 65 const gfx::Size& coded_size,
65 const gfx::Rect& visible_rect, 66 const gfx::Rect& visible_rect,
66 const gfx::Size& natural_size, 67 const gfx::Size& natural_size,
67 const std::vector<uint8_t>& extra_data, 68 const std::vector<uint8_t>& extra_data,
68 bool is_encrypted) { 69 const EncryptionScheme& encryption_scheme) {
69 codec_ = codec; 70 codec_ = codec;
70 profile_ = profile; 71 profile_ = profile;
71 format_ = format; 72 format_ = format;
72 color_space_ = color_space; 73 color_space_ = color_space;
73 coded_size_ = coded_size; 74 coded_size_ = coded_size;
74 visible_rect_ = visible_rect; 75 visible_rect_ = visible_rect;
75 natural_size_ = natural_size; 76 natural_size_ = natural_size;
76 extra_data_ = extra_data; 77 extra_data_ = extra_data;
77 is_encrypted_ = is_encrypted; 78 encryption_scheme_ = encryption_scheme;
78 } 79 }
79 80
80 bool VideoDecoderConfig::IsValidConfig() const { 81 bool VideoDecoderConfig::IsValidConfig() const {
81 return codec_ != kUnknownVideoCodec && 82 return codec_ != kUnknownVideoCodec &&
82 natural_size_.width() > 0 && 83 natural_size_.width() > 0 &&
83 natural_size_.height() > 0 && 84 natural_size_.height() > 0 &&
84 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, 85 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY,
85 coded_size_, visible_rect_, natural_size_); 86 coded_size_, visible_rect_, natural_size_);
86 } 87 }
87 88
88 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const { 89 bool VideoDecoderConfig::Matches(const VideoDecoderConfig& config) const {
89 return ((codec() == config.codec()) && 90 return ((codec() == config.codec()) && (format() == config.format()) &&
90 (format() == config.format()) &&
91 (profile() == config.profile()) && 91 (profile() == config.profile()) &&
92 (coded_size() == config.coded_size()) && 92 (coded_size() == config.coded_size()) &&
93 (visible_rect() == config.visible_rect()) && 93 (visible_rect() == config.visible_rect()) &&
94 (natural_size() == config.natural_size()) && 94 (natural_size() == config.natural_size()) &&
95 (extra_data() == config.extra_data()) && 95 (extra_data() == config.extra_data()) &&
96 (is_encrypted() == config.is_encrypted())); 96 (encryption_scheme().Matches(config.encryption_scheme())));
97 } 97 }
98 98
99 std::string VideoDecoderConfig::AsHumanReadableString() const { 99 std::string VideoDecoderConfig::AsHumanReadableString() const {
100 std::ostringstream s; 100 std::ostringstream s;
101 s << "codec: " << GetHumanReadableCodecName() 101 s << "codec: " << GetHumanReadableCodecName()
102 << " format: " << format() 102 << " format: " << format()
103 << " profile: " << profile() 103 << " profile: " << profile()
104 << " coded size: [" << coded_size().width() 104 << " coded size: [" << coded_size().width()
105 << "," << coded_size().height() << "]" 105 << "," << coded_size().height() << "]"
106 << " visible rect: [" << visible_rect().x() 106 << " visible rect: [" << visible_rect().x()
(...skipping 27 matching lines...) Expand all
134 case kCodecVP8: 134 case kCodecVP8:
135 return "vp8"; 135 return "vp8";
136 case kCodecVP9: 136 case kCodecVP9:
137 return "vp9"; 137 return "vp9";
138 } 138 }
139 NOTREACHED(); 139 NOTREACHED();
140 return ""; 140 return "";
141 } 141 }
142 142
143 } // namespace media 143 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698