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

Side by Side Diff: media/base/audio_decoder_config.cc

Issue 1786733004: Revert of media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « media/base/audio_decoder_config.h ('k') | media/base/encryption_scheme.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/audio_decoder_config.h" 5 #include "media/base/audio_decoder_config.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/limits.h" 8 #include "media/base/limits.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 AudioDecoderConfig::AudioDecoderConfig() 12 AudioDecoderConfig::AudioDecoderConfig()
13 : codec_(kUnknownAudioCodec), 13 : codec_(kUnknownAudioCodec),
14 sample_format_(kUnknownSampleFormat), 14 sample_format_(kUnknownSampleFormat),
15 bytes_per_channel_(0), 15 bytes_per_channel_(0),
16 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED), 16 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED),
17 samples_per_second_(0), 17 samples_per_second_(0),
18 bytes_per_frame_(0), 18 bytes_per_frame_(0),
19 codec_delay_(0) {} 19 is_encrypted_(false),
20 codec_delay_(0) {
21 }
20 22
21 AudioDecoderConfig::AudioDecoderConfig( 23 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec,
22 AudioCodec codec, 24 SampleFormat sample_format,
23 SampleFormat sample_format, 25 ChannelLayout channel_layout,
24 ChannelLayout channel_layout, 26 int samples_per_second,
25 int samples_per_second, 27 const std::vector<uint8_t>& extra_data,
26 const std::vector<uint8_t>& extra_data, 28 bool is_encrypted) {
27 const EncryptionScheme& encryption_scheme) {
28 Initialize(codec, sample_format, channel_layout, samples_per_second, 29 Initialize(codec, sample_format, channel_layout, samples_per_second,
29 extra_data, encryption_scheme, base::TimeDelta(), 0); 30 extra_data, is_encrypted, base::TimeDelta(), 0);
30 } 31 }
31 32
32 AudioDecoderConfig::AudioDecoderConfig(const AudioDecoderConfig& other) = 33 AudioDecoderConfig::AudioDecoderConfig(const AudioDecoderConfig& other) =
33 default; 34 default;
34 35
35 void AudioDecoderConfig::Initialize(AudioCodec codec, 36 void AudioDecoderConfig::Initialize(AudioCodec codec,
36 SampleFormat sample_format, 37 SampleFormat sample_format,
37 ChannelLayout channel_layout, 38 ChannelLayout channel_layout,
38 int samples_per_second, 39 int samples_per_second,
39 const std::vector<uint8_t>& extra_data, 40 const std::vector<uint8_t>& extra_data,
40 const EncryptionScheme& encryption_scheme, 41 bool is_encrypted,
41 base::TimeDelta seek_preroll, 42 base::TimeDelta seek_preroll,
42 int codec_delay) { 43 int codec_delay) {
43 codec_ = codec; 44 codec_ = codec;
44 channel_layout_ = channel_layout; 45 channel_layout_ = channel_layout;
45 samples_per_second_ = samples_per_second; 46 samples_per_second_ = samples_per_second;
46 sample_format_ = sample_format; 47 sample_format_ = sample_format;
47 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format); 48 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format);
48 extra_data_ = extra_data; 49 extra_data_ = extra_data;
49 encryption_scheme_ = encryption_scheme; 50 is_encrypted_ = is_encrypted;
50 seek_preroll_ = seek_preroll; 51 seek_preroll_ = seek_preroll;
51 codec_delay_ = codec_delay; 52 codec_delay_ = codec_delay;
52 53
53 int channels = ChannelLayoutToChannelCount(channel_layout_); 54 int channels = ChannelLayoutToChannelCount(channel_layout_);
54 bytes_per_frame_ = channels * bytes_per_channel_; 55 bytes_per_frame_ = channels * bytes_per_channel_;
55 } 56 }
56 57
57 AudioDecoderConfig::~AudioDecoderConfig() {} 58 AudioDecoderConfig::~AudioDecoderConfig() {}
58 59
59 bool AudioDecoderConfig::IsValidConfig() const { 60 bool AudioDecoderConfig::IsValidConfig() const {
60 return codec_ != kUnknownAudioCodec && 61 return codec_ != kUnknownAudioCodec &&
61 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && 62 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED &&
62 bytes_per_channel_ > 0 && 63 bytes_per_channel_ > 0 &&
63 bytes_per_channel_ <= limits::kMaxBytesPerSample && 64 bytes_per_channel_ <= limits::kMaxBytesPerSample &&
64 samples_per_second_ > 0 && 65 samples_per_second_ > 0 &&
65 samples_per_second_ <= limits::kMaxSampleRate && 66 samples_per_second_ <= limits::kMaxSampleRate &&
66 sample_format_ != kUnknownSampleFormat && 67 sample_format_ != kUnknownSampleFormat &&
67 seek_preroll_ >= base::TimeDelta() && 68 seek_preroll_ >= base::TimeDelta() &&
68 codec_delay_ >= 0; 69 codec_delay_ >= 0;
69 } 70 }
70 71
71 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const { 72 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const {
72 return ((codec() == config.codec()) && 73 return ((codec() == config.codec()) &&
73 (bytes_per_channel() == config.bytes_per_channel()) && 74 (bytes_per_channel() == config.bytes_per_channel()) &&
74 (channel_layout() == config.channel_layout()) && 75 (channel_layout() == config.channel_layout()) &&
75 (samples_per_second() == config.samples_per_second()) && 76 (samples_per_second() == config.samples_per_second()) &&
76 (extra_data() == config.extra_data()) && 77 (extra_data() == config.extra_data()) &&
77 (encryption_scheme().Matches(config.encryption_scheme())) && 78 (is_encrypted() == config.is_encrypted()) &&
78 (sample_format() == config.sample_format()) && 79 (sample_format() == config.sample_format()) &&
79 (seek_preroll() == config.seek_preroll()) && 80 (seek_preroll() == config.seek_preroll()) &&
80 (codec_delay() == config.codec_delay())); 81 (codec_delay() == config.codec_delay()));
81 } 82 }
82 83
83 std::string AudioDecoderConfig::AsHumanReadableString() const { 84 std::string AudioDecoderConfig::AsHumanReadableString() const {
84 std::ostringstream s; 85 std::ostringstream s;
85 s << "codec: " << GetCodecName(codec()) 86 s << "codec: " << GetCodecName(codec())
86 << " bytes_per_channel: " << bytes_per_channel() 87 << " bytes_per_channel: " << bytes_per_channel()
87 << " channel_layout: " << channel_layout() 88 << " channel_layout: " << channel_layout()
88 << " samples_per_second: " << samples_per_second() 89 << " samples_per_second: " << samples_per_second()
89 << " sample_format: " << sample_format() 90 << " sample_format: " << sample_format()
90 << " bytes_per_frame: " << bytes_per_frame() 91 << " bytes_per_frame: " << bytes_per_frame()
91 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" 92 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms"
92 << " codec_delay: " << codec_delay() << " has extra data? " 93 << " codec_delay: " << codec_delay() << " has extra data? "
93 << (extra_data().empty() ? "false" : "true") << " encrypted? " 94 << (extra_data().empty() ? "false" : "true") << " encrypted? "
94 << (is_encrypted() ? "true" : "false"); 95 << (is_encrypted() ? "true" : "false");
95 return s.str(); 96 return s.str();
96 } 97 }
97 98
98 } // namespace media 99 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_decoder_config.h ('k') | media/base/encryption_scheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698