| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // Create an AudioBuffer whose channel data is copied from |data|. For | 32 // Create an AudioBuffer whose channel data is copied from |data|. For |
| 33 // interleaved data, only the first buffer is used. For planar data, the | 33 // interleaved data, only the first buffer is used. For planar data, the |
| 34 // number of buffers must be equal to |channel_count|. |frame_count| is the | 34 // number of buffers must be equal to |channel_count|. |frame_count| is the |
| 35 // number of frames in each buffer. |data| must not be null and |frame_count| | 35 // number of frames in each buffer. |data| must not be null and |frame_count| |
| 36 // must be >= 0. | 36 // must be >= 0. |
| 37 // | 37 // |
| 38 // TODO(jrummell): Compute duration rather than pass it in. | 38 // TODO(jrummell): Compute duration rather than pass it in. |
| 39 static scoped_refptr<AudioBuffer> CopyFrom(SampleFormat sample_format, | 39 static scoped_refptr<AudioBuffer> CopyFrom(SampleFormat sample_format, |
| 40 ChannelLayout channel_layout, | 40 ChannelLayout channel_layout, |
| 41 int channel_count, |
| 41 int sample_rate, | 42 int sample_rate, |
| 42 int frame_count, | 43 int frame_count, |
| 43 const uint8* const* data, | 44 const uint8* const* data, |
| 44 const base::TimeDelta timestamp, | 45 const base::TimeDelta timestamp, |
| 45 const base::TimeDelta duration); | 46 const base::TimeDelta duration); |
| 46 | 47 |
| 47 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but | 48 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but |
| 48 // not initialized. Timestamp and duration are set to kNoTimestamp(). | 49 // not initialized. Timestamp and duration are set to kNoTimestamp(). |
| 49 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, | 50 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, |
| 50 ChannelLayout channel_layout, | 51 ChannelLayout channel_layout, |
| 52 int channel_count, |
| 51 int sample_rate, | 53 int sample_rate, |
| 52 int frame_count); | 54 int frame_count); |
| 53 | 55 |
| 54 // Create an empty AudioBuffer with |frame_count| frames. | 56 // Create an empty AudioBuffer with |frame_count| frames. |
| 55 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( | 57 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( |
| 56 ChannelLayout channel_layout, | 58 ChannelLayout channel_layout, |
| 59 int channel_count, |
| 57 int sample_rate, | 60 int sample_rate, |
| 58 int frame_count, | 61 int frame_count, |
| 59 const base::TimeDelta timestamp, | 62 const base::TimeDelta timestamp, |
| 60 const base::TimeDelta duration); | 63 const base::TimeDelta duration); |
| 61 | 64 |
| 62 // Create a AudioBuffer indicating we've reached end of stream. | 65 // Create a AudioBuffer indicating we've reached end of stream. |
| 63 // Calling any method other than end_of_stream() on the resulting buffer | 66 // Calling any method other than end_of_stream() on the resulting buffer |
| 64 // is disallowed. | 67 // is disallowed. |
| 65 static scoped_refptr<AudioBuffer> CreateEOSBuffer(); | 68 static scoped_refptr<AudioBuffer> CreateEOSBuffer(); |
| 66 | 69 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 private: | 119 private: |
| 117 friend class base::RefCountedThreadSafe<AudioBuffer>; | 120 friend class base::RefCountedThreadSafe<AudioBuffer>; |
| 118 | 121 |
| 119 // Allocates aligned contiguous buffer to hold all channel data (1 block for | 122 // Allocates aligned contiguous buffer to hold all channel data (1 block for |
| 120 // interleaved data, |channel_count| blocks for planar data), copies | 123 // interleaved data, |channel_count| blocks for planar data), copies |
| 121 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no | 124 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no |
| 122 // data is copied. If |create_buffer| is false, no data buffer is created (or | 125 // data is copied. If |create_buffer| is false, no data buffer is created (or |
| 123 // copied to). | 126 // copied to). |
| 124 AudioBuffer(SampleFormat sample_format, | 127 AudioBuffer(SampleFormat sample_format, |
| 125 ChannelLayout channel_layout, | 128 ChannelLayout channel_layout, |
| 129 int channel_count, |
| 126 int sample_rate, | 130 int sample_rate, |
| 127 int frame_count, | 131 int frame_count, |
| 128 bool create_buffer, | 132 bool create_buffer, |
| 129 const uint8* const* data, | 133 const uint8* const* data, |
| 130 const base::TimeDelta timestamp, | 134 const base::TimeDelta timestamp, |
| 131 const base::TimeDelta duration); | 135 const base::TimeDelta duration); |
| 132 | 136 |
| 133 virtual ~AudioBuffer(); | 137 virtual ~AudioBuffer(); |
| 134 | 138 |
| 135 const SampleFormat sample_format_; | 139 const SampleFormat sample_format_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 147 | 151 |
| 148 // For planar data, points to each channels data. | 152 // For planar data, points to each channels data. |
| 149 std::vector<uint8*> channel_data_; | 153 std::vector<uint8*> channel_data_; |
| 150 | 154 |
| 151 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); | 155 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); |
| 152 }; | 156 }; |
| 153 | 157 |
| 154 } // namespace media | 158 } // namespace media |
| 155 | 159 |
| 156 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ | 160 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ |
| OLD | NEW |