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

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: samples_per_second 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
« no previous file with comments | « media/base/audio_decoder_config.h ('k') | media/base/demuxer_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
14 bits_per_channel_(0),
15 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED),
16 samples_per_second_(0),
17 extra_data_size_(0) {
18 }
19
20 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec,
21 int bits_per_channel,
22 ChannelLayout channel_layout,
23 int samples_per_second,
24 const uint8* extra_data,
25 size_t extra_data_size) {
26 Initialize(codec, bits_per_channel, channel_layout, samples_per_second,
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 samples_per_second,
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 samples_per_second_ = samples_per_second;
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 samples_per_second_ > 0 &&
60 samples_per_second_ <= 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::samples_per_second() const {
76 return samples_per_second_;
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
« no previous file with comments | « media/base/audio_decoder_config.h ('k') | media/base/demuxer_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698