| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BASE_AUDIO_BUFFER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_BUFFER_H_ |
| 6 #define MEDIA_BASE_AUDIO_BUFFER_H_ | 6 #define MEDIA_BASE_AUDIO_BUFFER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // number of frames in each buffer. |data| must not be null and |frame_count| | 50 // number of frames in each buffer. |data| must not be null and |frame_count| |
| 51 // must be >= 0. | 51 // must be >= 0. |
| 52 static scoped_refptr<AudioBuffer> CopyFrom(SampleFormat sample_format, | 52 static scoped_refptr<AudioBuffer> CopyFrom(SampleFormat sample_format, |
| 53 ChannelLayout channel_layout, | 53 ChannelLayout channel_layout, |
| 54 int channel_count, | 54 int channel_count, |
| 55 int sample_rate, | 55 int sample_rate, |
| 56 int frame_count, | 56 int frame_count, |
| 57 const uint8_t* const* data, | 57 const uint8_t* const* data, |
| 58 const base::TimeDelta timestamp); | 58 const base::TimeDelta timestamp); |
| 59 | 59 |
| 60 // Create an AudioBuffer for compressed bitstream. Its channel data is copied |
| 61 // from |data|, and the size is |data_size|. |data| must not be null and |
| 62 // |frame_count| must be >= 0. |
| 63 static scoped_refptr<AudioBuffer> CopyBitstreamFrom( |
| 64 SampleFormat sample_format, |
| 65 ChannelLayout channel_layout, |
| 66 int channel_count, |
| 67 int sample_rate, |
| 68 int frame_count, |
| 69 const uint8_t* const* data, |
| 70 const size_t data_size, |
| 71 const base::TimeDelta timestamp); |
| 72 |
| 60 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but | 73 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but |
| 61 // not initialized. Timestamp and duration are set to kNoTimestamp. | 74 // not initialized. Timestamp and duration are set to kNoTimestamp. |
| 62 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, | 75 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, |
| 63 ChannelLayout channel_layout, | 76 ChannelLayout channel_layout, |
| 64 int channel_count, | 77 int channel_count, |
| 65 int sample_rate, | 78 int sample_rate, |
| 66 int frame_count); | 79 int frame_count); |
| 67 | 80 |
| 81 // Create an AudioBuffer for compressed bitstream. Buffer is allocated, but |
| 82 // not initialized. Timestamp and duration are set to kNoTimestamp. |
| 83 static scoped_refptr<AudioBuffer> CreateBitstreamBuffer( |
| 84 SampleFormat sample_format, |
| 85 ChannelLayout channel_layout, |
| 86 int channel_count, |
| 87 int sample_rate, |
| 88 int frame_count, |
| 89 size_t data_size); |
| 90 |
| 68 // Create an empty AudioBuffer with |frame_count| frames. | 91 // Create an empty AudioBuffer with |frame_count| frames. |
| 69 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( | 92 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( |
| 70 ChannelLayout channel_layout, | 93 ChannelLayout channel_layout, |
| 71 int channel_count, | 94 int channel_count, |
| 72 int sample_rate, | 95 int sample_rate, |
| 73 int frame_count, | 96 int frame_count, |
| 74 const base::TimeDelta timestamp); | 97 const base::TimeDelta timestamp); |
| 75 | 98 |
| 76 // Create a AudioBuffer indicating we've reached end of stream. | 99 // Create a AudioBuffer indicating we've reached end of stream. |
| 77 // Calling any method other than end_of_stream() on the resulting buffer | 100 // Calling any method other than end_of_stream() on the resulting buffer |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 133 |
| 111 // Return the number of channels. | 134 // Return the number of channels. |
| 112 int channel_count() const { return channel_count_; } | 135 int channel_count() const { return channel_count_; } |
| 113 | 136 |
| 114 // Return the number of frames held. | 137 // Return the number of frames held. |
| 115 int frame_count() const { return adjusted_frame_count_; } | 138 int frame_count() const { return adjusted_frame_count_; } |
| 116 | 139 |
| 117 // Return the sample rate. | 140 // Return the sample rate. |
| 118 int sample_rate() const { return sample_rate_; } | 141 int sample_rate() const { return sample_rate_; } |
| 119 | 142 |
| 143 // Return the sample format. |
| 144 SampleFormat sample_format() const { return sample_format_; } |
| 145 |
| 120 // Return the channel layout. | 146 // Return the channel layout. |
| 121 ChannelLayout channel_layout() const { return channel_layout_; } | 147 ChannelLayout channel_layout() const { return channel_layout_; } |
| 122 | 148 |
| 123 base::TimeDelta timestamp() const { return timestamp_; } | 149 base::TimeDelta timestamp() const { return timestamp_; } |
| 124 base::TimeDelta duration() const { return duration_; } | 150 base::TimeDelta duration() const { return duration_; } |
| 125 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; } | 151 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; } |
| 126 | 152 |
| 127 // If there's no data in this buffer, it represents end of stream. | 153 // If there's no data in this buffer, it represents end of stream. |
| 128 bool end_of_stream() const { return end_of_stream_; } | 154 bool end_of_stream() const { return end_of_stream_; } |
| 129 | 155 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 150 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no | 176 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no |
| 151 // data is copied. If |create_buffer| is false, no data buffer is created (or | 177 // data is copied. If |create_buffer| is false, no data buffer is created (or |
| 152 // copied to). | 178 // copied to). |
| 153 AudioBuffer(SampleFormat sample_format, | 179 AudioBuffer(SampleFormat sample_format, |
| 154 ChannelLayout channel_layout, | 180 ChannelLayout channel_layout, |
| 155 int channel_count, | 181 int channel_count, |
| 156 int sample_rate, | 182 int sample_rate, |
| 157 int frame_count, | 183 int frame_count, |
| 158 bool create_buffer, | 184 bool create_buffer, |
| 159 const uint8_t* const* data, | 185 const uint8_t* const* data, |
| 186 size_t data_size, |
| 160 const base::TimeDelta timestamp); | 187 const base::TimeDelta timestamp); |
| 161 | 188 |
| 162 virtual ~AudioBuffer(); | 189 virtual ~AudioBuffer(); |
| 163 | 190 |
| 164 const SampleFormat sample_format_; | 191 const SampleFormat sample_format_; |
| 165 const ChannelLayout channel_layout_; | 192 const ChannelLayout channel_layout_; |
| 166 const int channel_count_; | 193 const int channel_count_; |
| 167 int sample_rate_; | 194 int sample_rate_; |
| 168 int adjusted_frame_count_; | 195 int adjusted_frame_count_; |
| 169 const bool end_of_stream_; | 196 const bool end_of_stream_; |
| 170 base::TimeDelta timestamp_; | 197 base::TimeDelta timestamp_; |
| 171 base::TimeDelta duration_; | 198 base::TimeDelta duration_; |
| 172 | 199 |
| 173 // Contiguous block of channel data. | 200 // Contiguous block of channel data. |
| 174 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; | 201 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; |
| 175 size_t data_size_; | 202 size_t data_size_; |
| 176 | 203 |
| 177 // For planar data, points to each channels data. | 204 // For planar data, points to each channels data. |
| 178 std::vector<uint8_t*> channel_data_; | 205 std::vector<uint8_t*> channel_data_; |
| 179 | 206 |
| 180 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); | 207 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); |
| 181 }; | 208 }; |
| 182 | 209 |
| 183 } // namespace media | 210 } // namespace media |
| 184 | 211 |
| 185 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ | 212 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ |
| OLD | NEW |