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

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

Issue 242203006: Revert 264763 "Wire up codec_delay() to MP3StreamParser and FFmp..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/media/base/audio_decoder_config.h ('k') | trunk/src/media/ffmpeg/ffmpeg_common.cc » ('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 "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/audio/sample_rates.h" 10 #include "media/audio/sample_rates.h"
11 #include "media/base/limits.h" 11 #include "media/base/limits.h"
12 #include "media/base/sample_format.h" 12 #include "media/base/sample_format.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 AudioDecoderConfig::AudioDecoderConfig() 16 AudioDecoderConfig::AudioDecoderConfig()
17 : codec_(kUnknownAudioCodec), 17 : codec_(kUnknownAudioCodec),
18 sample_format_(kUnknownSampleFormat), 18 sample_format_(kUnknownSampleFormat),
19 bytes_per_channel_(0), 19 bytes_per_channel_(0),
20 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED), 20 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED),
21 samples_per_second_(0), 21 samples_per_second_(0),
22 bytes_per_frame_(0), 22 bytes_per_frame_(0),
23 is_encrypted_(false), 23 is_encrypted_(false) {
24 codec_delay_(0) {
25 } 24 }
26 25
27 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec, 26 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec,
28 SampleFormat sample_format, 27 SampleFormat sample_format,
29 ChannelLayout channel_layout, 28 ChannelLayout channel_layout,
30 int samples_per_second, 29 int samples_per_second,
31 const uint8* extra_data, 30 const uint8* extra_data,
32 size_t extra_data_size, 31 size_t extra_data_size,
33 bool is_encrypted) { 32 bool is_encrypted) {
34 Initialize(codec, sample_format, channel_layout, samples_per_second, 33 Initialize(codec, sample_format, channel_layout, samples_per_second,
35 extra_data, extra_data_size, is_encrypted, true, 34 extra_data, extra_data_size, is_encrypted, true,
36 base::TimeDelta(), 0); 35 base::TimeDelta(), base::TimeDelta());
37 } 36 }
38 37
39 void AudioDecoderConfig::Initialize(AudioCodec codec, 38 void AudioDecoderConfig::Initialize(AudioCodec codec,
40 SampleFormat sample_format, 39 SampleFormat sample_format,
41 ChannelLayout channel_layout, 40 ChannelLayout channel_layout,
42 int samples_per_second, 41 int samples_per_second,
43 const uint8* extra_data, 42 const uint8* extra_data,
44 size_t extra_data_size, 43 size_t extra_data_size,
45 bool is_encrypted, 44 bool is_encrypted,
46 bool record_stats, 45 bool record_stats,
47 base::TimeDelta seek_preroll, 46 base::TimeDelta seek_preroll,
48 int codec_delay) { 47 base::TimeDelta codec_delay) {
49 CHECK((extra_data_size != 0) == (extra_data != NULL)); 48 CHECK((extra_data_size != 0) == (extra_data != NULL));
50 49
51 if (record_stats) { 50 if (record_stats) {
52 UMA_HISTOGRAM_ENUMERATION("Media.AudioCodec", codec, kAudioCodecMax + 1); 51 UMA_HISTOGRAM_ENUMERATION("Media.AudioCodec", codec, kAudioCodecMax + 1);
53 UMA_HISTOGRAM_ENUMERATION("Media.AudioSampleFormat", sample_format, 52 UMA_HISTOGRAM_ENUMERATION("Media.AudioSampleFormat", sample_format,
54 kSampleFormatMax + 1); 53 kSampleFormatMax + 1);
55 UMA_HISTOGRAM_ENUMERATION("Media.AudioChannelLayout", channel_layout, 54 UMA_HISTOGRAM_ENUMERATION("Media.AudioChannelLayout", channel_layout,
56 CHANNEL_LAYOUT_MAX + 1); 55 CHANNEL_LAYOUT_MAX + 1);
57 AudioSampleRate asr; 56 AudioSampleRate asr;
58 if (ToAudioSampleRate(samples_per_second, &asr)) { 57 if (ToAudioSampleRate(samples_per_second, &asr)) {
(...skipping 23 matching lines...) Expand all
82 81
83 bool AudioDecoderConfig::IsValidConfig() const { 82 bool AudioDecoderConfig::IsValidConfig() const {
84 return codec_ != kUnknownAudioCodec && 83 return codec_ != kUnknownAudioCodec &&
85 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && 84 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED &&
86 bytes_per_channel_ > 0 && 85 bytes_per_channel_ > 0 &&
87 bytes_per_channel_ <= limits::kMaxBytesPerSample && 86 bytes_per_channel_ <= limits::kMaxBytesPerSample &&
88 samples_per_second_ > 0 && 87 samples_per_second_ > 0 &&
89 samples_per_second_ <= limits::kMaxSampleRate && 88 samples_per_second_ <= limits::kMaxSampleRate &&
90 sample_format_ != kUnknownSampleFormat && 89 sample_format_ != kUnknownSampleFormat &&
91 seek_preroll_ >= base::TimeDelta() && 90 seek_preroll_ >= base::TimeDelta() &&
92 codec_delay_ >= 0; 91 codec_delay_ >= base::TimeDelta();
93 } 92 }
94 93
95 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const { 94 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const {
96 return ((codec() == config.codec()) && 95 return ((codec() == config.codec()) &&
97 (bytes_per_channel() == config.bytes_per_channel()) && 96 (bytes_per_channel() == config.bytes_per_channel()) &&
98 (channel_layout() == config.channel_layout()) && 97 (channel_layout() == config.channel_layout()) &&
99 (samples_per_second() == config.samples_per_second()) && 98 (samples_per_second() == config.samples_per_second()) &&
100 (extra_data_size() == config.extra_data_size()) && 99 (extra_data_size() == config.extra_data_size()) &&
101 (!extra_data() || !memcmp(extra_data(), config.extra_data(), 100 (!extra_data() || !memcmp(extra_data(), config.extra_data(),
102 extra_data_size())) && 101 extra_data_size())) &&
103 (is_encrypted() == config.is_encrypted()) && 102 (is_encrypted() == config.is_encrypted()) &&
104 (sample_format() == config.sample_format()) && 103 (sample_format() == config.sample_format()) &&
105 (seek_preroll() == config.seek_preroll()) && 104 (seek_preroll() == config.seek_preroll()) &&
106 (codec_delay() == config.codec_delay())); 105 (codec_delay() == config.codec_delay()));
107 } 106 }
108 107
109 std::string AudioDecoderConfig::AsHumanReadableString() const { 108 std::string AudioDecoderConfig::AsHumanReadableString() const {
110 std::ostringstream s; 109 std::ostringstream s;
111 s << "codec: " << codec() 110 s << "codec: " << codec()
112 << " bytes_per_channel: " << bytes_per_channel() 111 << " bytes_per_channel: " << bytes_per_channel()
113 << " channel_layout: " << channel_layout() 112 << " channel_layout: " << channel_layout()
114 << " samples_per_second: " << samples_per_second() 113 << " samples_per_second: " << samples_per_second()
115 << " sample_format: " << sample_format() 114 << " sample_format: " << sample_format()
116 << " bytes_per_frame: " << bytes_per_frame() 115 << " bytes_per_frame: " << bytes_per_frame()
117 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" 116 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms"
118 << " codec_delay: " << codec_delay() 117 << " codec_delay: " << codec_delay().InMilliseconds() << "ms"
119 << " has extra data? " << (extra_data() ? "true" : "false") 118 << " has extra data? " << (extra_data() ? "true" : "false")
120 << " encrypted? " << (is_encrypted() ? "true" : "false"); 119 << " encrypted? " << (is_encrypted() ? "true" : "false");
121 return s.str(); 120 return s.str();
122 } 121 }
123 122
124 } // namespace media 123 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/base/audio_decoder_config.h ('k') | trunk/src/media/ffmpeg/ffmpeg_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698