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

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

Issue 7867051: Introduce AudioDecoderConfig to migrate away from GetAVStream(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blam Created 9 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/audio_decoder_config.h"
6
7 #include "base/logging.h"
8 #include "media/base/limits.h"
9
10 namespace media {
11
12 AudioDecoderConfig::AudioDecoderConfig()
13 : codec_(kUnknownAudioCodec),
Ami GONE FROM CHROMIUM 2011/09/20 20:34:50 Could also impl. as Initialize() call? I don't thi
scherkus (not reviewing) 2011/09/21 18:19:16 I'll leave as is -- I think it reads a bit easier
14 bits_per_channel_(0),
15 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED),
16 sample_rate_(0),
17 extra_data_size_(0) {
18 }
19
20 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec,
21 int bits_per_channel,
22 ChannelLayout channel_layout,
23 int sample_rate,
24 const uint8* extra_data,
25 size_t extra_data_size) {
26 Initialize(codec, bits_per_channel, channel_layout, sample_rate,
27 extra_data, extra_data_size);
28 }
29
30 void AudioDecoderConfig::Initialize(AudioCodec codec,
31 int bits_per_channel,
32 ChannelLayout channel_layout,
33 int sample_rate,
34 const uint8* extra_data,
35 size_t extra_data_size) {
36 CHECK((extra_data_size != 0) == (extra_data != NULL));
37
38 codec_ = codec;
39 bits_per_channel_ = bits_per_channel;
40 channel_layout_ = channel_layout;
41 sample_rate_ = sample_rate;
42 extra_data_size_ = extra_data_size;
43
44 if (extra_data_size_ > 0) {
45 extra_data_.reset(new uint8[extra_data_size_]);
46 memcpy(extra_data_.get(), extra_data, extra_data_size_);
47 } else {
48 extra_data_.reset();
49 }
50 }
51
52 AudioDecoderConfig::~AudioDecoderConfig() {}
53
54 bool AudioDecoderConfig::IsValidConfig() const {
55 return codec_ != kUnknownAudioCodec &&
56 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED &&
57 bits_per_channel_ > 0 &&
58 bits_per_channel_ <= Limits::kMaxBitsPerSample &&
59 sample_rate_ > 0 &&
60 sample_rate_ <= Limits::kMaxSampleRate;
61 }
62
63 AudioCodec AudioDecoderConfig::codec() const {
64 return codec_;
65 }
66
67 int AudioDecoderConfig::bits_per_channel() const {
68 return bits_per_channel_;
69 }
70
71 ChannelLayout AudioDecoderConfig::channel_layout() const {
72 return channel_layout_;
73 }
74
75 int AudioDecoderConfig::sample_rate() const {
76 return sample_rate_;
77 }
78
79 uint8* AudioDecoderConfig::extra_data() const {
80 return extra_data_.get();
81 }
82
83 size_t AudioDecoderConfig::extra_data_size() const {
84 return extra_data_size_;
85 }
86
87 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698