| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // interleaved data, only the first buffer is used. For planar data, the | 48 // interleaved data, only the first buffer is used. For planar data, the |
| 49 // number of buffers must be equal to |channel_count|. |frame_count| is the | 49 // number of buffers must be equal to |channel_count|. |frame_count| is the |
| 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 const size_t data_size = 0); |
| 59 | 60 |
| 60 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but | 61 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but |
| 61 // not initialized. Timestamp and duration are set to kNoTimestamp. | 62 // not initialized. Timestamp and duration are set to kNoTimestamp. |
| 62 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, | 63 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, |
| 63 ChannelLayout channel_layout, | 64 ChannelLayout channel_layout, |
| 64 int channel_count, | 65 int channel_count, |
| 65 int sample_rate, | 66 int sample_rate, |
| 66 int frame_count); | 67 int frame_count, |
| 68 size_t data_size = 0); |
| 67 | 69 |
| 68 // Create an empty AudioBuffer with |frame_count| frames. | 70 // Create an empty AudioBuffer with |frame_count| frames. |
| 69 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( | 71 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( |
| 70 ChannelLayout channel_layout, | 72 ChannelLayout channel_layout, |
| 71 int channel_count, | 73 int channel_count, |
| 72 int sample_rate, | 74 int sample_rate, |
| 73 int frame_count, | 75 int frame_count, |
| 74 const base::TimeDelta timestamp); | 76 const base::TimeDelta timestamp); |
| 75 | 77 |
| 76 // Create a AudioBuffer indicating we've reached end of stream. | 78 // Create a AudioBuffer indicating we've reached end of stream. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 112 |
| 111 // Return the number of channels. | 113 // Return the number of channels. |
| 112 int channel_count() const { return channel_count_; } | 114 int channel_count() const { return channel_count_; } |
| 113 | 115 |
| 114 // Return the number of frames held. | 116 // Return the number of frames held. |
| 115 int frame_count() const { return adjusted_frame_count_; } | 117 int frame_count() const { return adjusted_frame_count_; } |
| 116 | 118 |
| 117 // Return the sample rate. | 119 // Return the sample rate. |
| 118 int sample_rate() const { return sample_rate_; } | 120 int sample_rate() const { return sample_rate_; } |
| 119 | 121 |
| 122 // Return the sample format. |
| 123 SampleFormat sample_format() const { return sample_format_; } |
| 124 |
| 120 // Return the channel layout. | 125 // Return the channel layout. |
| 121 ChannelLayout channel_layout() const { return channel_layout_; } | 126 ChannelLayout channel_layout() const { return channel_layout_; } |
| 122 | 127 |
| 123 base::TimeDelta timestamp() const { return timestamp_; } | 128 base::TimeDelta timestamp() const { return timestamp_; } |
| 124 base::TimeDelta duration() const { return duration_; } | 129 base::TimeDelta duration() const { return duration_; } |
| 125 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; } | 130 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; } |
| 126 | 131 |
| 127 // If there's no data in this buffer, it represents end of stream. | 132 // If there's no data in this buffer, it represents end of stream. |
| 128 bool end_of_stream() const { return end_of_stream_; } | 133 bool end_of_stream() const { return end_of_stream_; } |
| 129 | 134 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 150 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no | 155 // [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 | 156 // data is copied. If |create_buffer| is false, no data buffer is created (or |
| 152 // copied to). | 157 // copied to). |
| 153 AudioBuffer(SampleFormat sample_format, | 158 AudioBuffer(SampleFormat sample_format, |
| 154 ChannelLayout channel_layout, | 159 ChannelLayout channel_layout, |
| 155 int channel_count, | 160 int channel_count, |
| 156 int sample_rate, | 161 int sample_rate, |
| 157 int frame_count, | 162 int frame_count, |
| 158 bool create_buffer, | 163 bool create_buffer, |
| 159 const uint8_t* const* data, | 164 const uint8_t* const* data, |
| 165 size_t data_size, |
| 160 const base::TimeDelta timestamp); | 166 const base::TimeDelta timestamp); |
| 161 | 167 |
| 162 virtual ~AudioBuffer(); | 168 virtual ~AudioBuffer(); |
| 163 | 169 |
| 164 const SampleFormat sample_format_; | 170 const SampleFormat sample_format_; |
| 165 const ChannelLayout channel_layout_; | 171 const ChannelLayout channel_layout_; |
| 166 const int channel_count_; | 172 const int channel_count_; |
| 167 int sample_rate_; | 173 int sample_rate_; |
| 168 int adjusted_frame_count_; | 174 int adjusted_frame_count_; |
| 169 const bool end_of_stream_; | 175 const bool end_of_stream_; |
| 170 base::TimeDelta timestamp_; | 176 base::TimeDelta timestamp_; |
| 171 base::TimeDelta duration_; | 177 base::TimeDelta duration_; |
| 172 | 178 |
| 173 // Contiguous block of channel data. | 179 // Contiguous block of channel data. |
| 174 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; | 180 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; |
| 175 size_t data_size_; | 181 size_t data_size_; |
| 176 | 182 |
| 177 // For planar data, points to each channels data. | 183 // For planar data, points to each channels data. |
| 178 std::vector<uint8_t*> channel_data_; | 184 std::vector<uint8_t*> channel_data_; |
| 179 | 185 |
| 180 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); | 186 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); |
| 181 }; | 187 }; |
| 182 | 188 |
| 183 } // namespace media | 189 } // namespace media |
| 184 | 190 |
| 185 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ | 191 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ |
| OLD | NEW |