Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / media / base / audio_decoder_config.h
blob77d4fc28ade49e4b77c8de3c3a3cca93686824a5
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_AUDIO_DECODER_CONFIG_H_
6 #define MEDIA_BASE_AUDIO_DECODER_CONFIG_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/time/time.h"
12 #include "media/base/channel_layout.h"
13 #include "media/base/media_export.h"
14 #include "media/base/sample_format.h"
16 namespace media {
18 enum AudioCodec {
19 // These values are histogrammed over time; do not change their ordinal
20 // values. When deleting a codec replace it with a dummy value; when adding a
21 // codec, do so at the bottom before kAudioCodecMax.
22 kUnknownAudioCodec = 0,
23 kCodecAAC = 1,
24 kCodecMP3 = 2,
25 kCodecPCM = 3,
26 kCodecVorbis = 4,
27 kCodecFLAC = 5,
28 kCodecAMR_NB = 6,
29 kCodecAMR_WB = 7,
30 kCodecPCM_MULAW = 8,
31 kCodecGSM_MS = 9,
32 kCodecPCM_S16BE = 10,
33 kCodecPCM_S24BE = 11,
34 kCodecOpus = 12,
35 // kCodecEAC3 = 13,
36 kCodecPCM_ALAW = 14,
37 // DO NOT ADD RANDOM AUDIO CODECS!
39 // The only acceptable time to add a new codec is if there is production code
40 // that uses said codec in the same CL.
42 // Must always be last!
43 kAudioCodecMax
46 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of
47 // |bits_per_channel|, we should switch over since bits are generally confusing
48 // to work with.
49 class MEDIA_EXPORT AudioDecoderConfig {
50 public:
51 // Constructs an uninitialized object. Clients should call Initialize() with
52 // appropriate values before using.
53 AudioDecoderConfig();
55 // Constructs an initialized object. It is acceptable to pass in NULL for
56 // |extra_data|, otherwise the memory is copied.
57 AudioDecoderConfig(AudioCodec codec, SampleFormat sample_format,
58 ChannelLayout channel_layout, int samples_per_second,
59 const uint8* extra_data, size_t extra_data_size,
60 bool is_encrypted);
62 ~AudioDecoderConfig();
64 // Resets the internal state of this object.
65 void Initialize(AudioCodec codec, SampleFormat sample_format,
66 ChannelLayout channel_layout, int samples_per_second,
67 const uint8* extra_data, size_t extra_data_size,
68 bool is_encrypted, bool record_stats,
69 base::TimeDelta seek_preroll,
70 base::TimeDelta codec_delay);
72 // Returns true if this object has appropriate configuration values, false
73 // otherwise.
74 bool IsValidConfig() const;
76 // Returns true if all fields in |config| match this config.
77 // Note: The contents of |extra_data_| are compared not the raw pointers.
78 bool Matches(const AudioDecoderConfig& config) const;
80 AudioCodec codec() const { return codec_; }
81 int bits_per_channel() const { return bytes_per_channel_ * 8; }
82 int bytes_per_channel() const { return bytes_per_channel_; }
83 ChannelLayout channel_layout() const { return channel_layout_; }
84 int samples_per_second() const { return samples_per_second_; }
85 SampleFormat sample_format() const { return sample_format_; }
86 int bytes_per_frame() const { return bytes_per_frame_; }
87 base::TimeDelta seek_preroll() const { return seek_preroll_; }
88 base::TimeDelta codec_delay() const { return codec_delay_; }
90 // Optional byte data required to initialize audio decoders such as Vorbis
91 // codebooks.
92 const uint8* extra_data() const {
93 return extra_data_.empty() ? NULL : &extra_data_[0];
95 size_t extra_data_size() const { return extra_data_.size(); }
97 // Whether the audio stream is potentially encrypted.
98 // Note that in a potentially encrypted audio stream, individual buffers
99 // can be encrypted or not encrypted.
100 bool is_encrypted() const { return is_encrypted_; }
102 private:
103 AudioCodec codec_;
104 SampleFormat sample_format_;
105 int bytes_per_channel_;
106 ChannelLayout channel_layout_;
107 int samples_per_second_;
108 int bytes_per_frame_;
109 std::vector<uint8> extra_data_;
110 bool is_encrypted_;
112 // |seek_preroll_| is the duration of the data that the decoder must decode
113 // before the decoded data is valid.
114 base::TimeDelta seek_preroll_;
116 // |codec_delay_| is the overall delay overhead added by the codec while
117 // encoding. This value should be subtracted from each block's timestamp to
118 // get the actual timestamp.
119 base::TimeDelta codec_delay_;
121 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
122 // generated copy constructor and assignment operator. Since the extra data is
123 // typically small, the performance impact is minimal.
126 } // namespace media
128 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_