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

Side by Side Diff: media/base/audio_buffer.h

Issue 261533002: Remove AudioBuffer::set_duration(), instead base on frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix content decryptor Created 6 years, 7 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
OLDNEW
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 17 matching lines...) Expand all
28 // (which may be 0, 16, or 32, depending on the processor). Selecting 32 in 28 // (which may be 0, 16, or 32, depending on the processor). Selecting 32 in
29 // order to work on all processors. 29 // order to work on all processors.
30 enum { kChannelAlignment = 32 }; 30 enum { kChannelAlignment = 32 };
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.
wolenetz 2014/05/01 20:18:24 drive-by nit: remove this comment now?
jrummell 2014/05/01 20:26:26 nit: Can you remove this comment since it's done n
DaleCurtis 2014/05/01 20:33:18 Done.
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 channel_count,
42 int sample_rate, 42 int sample_rate,
43 int frame_count, 43 int frame_count,
44 const uint8* const* data, 44 const uint8* const* data,
45 const base::TimeDelta timestamp, 45 const base::TimeDelta timestamp);
46 const base::TimeDelta duration);
47 46
48 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but 47 // Create an AudioBuffer with |frame_count| frames. Buffer is allocated, but
49 // not initialized. Timestamp and duration are set to kNoTimestamp(). 48 // not initialized. Timestamp and duration are set to kNoTimestamp().
50 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format, 49 static scoped_refptr<AudioBuffer> CreateBuffer(SampleFormat sample_format,
51 ChannelLayout channel_layout, 50 ChannelLayout channel_layout,
52 int channel_count, 51 int channel_count,
53 int sample_rate, 52 int sample_rate,
54 int frame_count); 53 int frame_count);
55 54
56 // Create an empty AudioBuffer with |frame_count| frames. 55 // Create an empty AudioBuffer with |frame_count| frames.
57 static scoped_refptr<AudioBuffer> CreateEmptyBuffer( 56 static scoped_refptr<AudioBuffer> CreateEmptyBuffer(
58 ChannelLayout channel_layout, 57 ChannelLayout channel_layout,
59 int channel_count, 58 int channel_count,
60 int sample_rate, 59 int sample_rate,
61 int frame_count, 60 int frame_count,
62 const base::TimeDelta timestamp, 61 const base::TimeDelta timestamp);
63 const base::TimeDelta duration);
64 62
65 // Create a AudioBuffer indicating we've reached end of stream. 63 // Create a AudioBuffer indicating we've reached end of stream.
66 // Calling any method other than end_of_stream() on the resulting buffer 64 // Calling any method other than end_of_stream() on the resulting buffer
67 // is disallowed. 65 // is disallowed.
68 static scoped_refptr<AudioBuffer> CreateEOSBuffer(); 66 static scoped_refptr<AudioBuffer> CreateEOSBuffer();
69 67
70 // Copy frames into |dest|. |frames_to_copy| is the number of frames to copy. 68 // Copy frames into |dest|. |frames_to_copy| is the number of frames to copy.
71 // |source_frame_offset| specifies how many frames in the buffer to skip 69 // |source_frame_offset| specifies how many frames in the buffer to skip
72 // first. |dest_frame_offset| is the frame offset in |dest|. The frames are 70 // first. |dest_frame_offset| is the frame offset in |dest|. The frames are
73 // converted from their source format into planar float32 data (which is all 71 // converted from their source format into planar float32 data (which is all
(...skipping 21 matching lines...) Expand all
95 93
96 // Return the sample rate. 94 // Return the sample rate.
97 int sample_rate() const { return sample_rate_; } 95 int sample_rate() const { return sample_rate_; }
98 96
99 // Return the channel layout. 97 // Return the channel layout.
100 ChannelLayout channel_layout() const { return channel_layout_; } 98 ChannelLayout channel_layout() const { return channel_layout_; }
101 99
102 base::TimeDelta timestamp() const { return timestamp_; } 100 base::TimeDelta timestamp() const { return timestamp_; }
103 base::TimeDelta duration() const { return duration_; } 101 base::TimeDelta duration() const { return duration_; }
104 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; } 102 void set_timestamp(base::TimeDelta timestamp) { timestamp_ = timestamp; }
105 void set_duration(base::TimeDelta duration) { duration_ = duration; }
106 103
107 // If there's no data in this buffer, it represents end of stream. 104 // If there's no data in this buffer, it represents end of stream.
108 bool end_of_stream() const { return end_of_stream_; } 105 bool end_of_stream() const { return end_of_stream_; }
109 106
110 // Access to the raw buffer for ffmpeg to write directly to. Data for planar 107 // Access to the raw buffer for ffmpeg to write directly to. Data for planar
111 // data is grouped by channel. There is only 1 entry for interleaved formats. 108 // data is grouped by channel. There is only 1 entry for interleaved formats.
112 const std::vector<uint8*>& channel_data() const { return channel_data_; } 109 const std::vector<uint8*>& channel_data() const { return channel_data_; }
113 110
114 private: 111 private:
115 friend class base::RefCountedThreadSafe<AudioBuffer>; 112 friend class base::RefCountedThreadSafe<AudioBuffer>;
116 113
117 // Allocates aligned contiguous buffer to hold all channel data (1 block for 114 // Allocates aligned contiguous buffer to hold all channel data (1 block for
118 // interleaved data, |channel_count| blocks for planar data), copies 115 // interleaved data, |channel_count| blocks for planar data), copies
119 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no 116 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no
120 // data is copied. If |create_buffer| is false, no data buffer is created (or 117 // data is copied. If |create_buffer| is false, no data buffer is created (or
121 // copied to). 118 // copied to).
122 AudioBuffer(SampleFormat sample_format, 119 AudioBuffer(SampleFormat sample_format,
123 ChannelLayout channel_layout, 120 ChannelLayout channel_layout,
124 int channel_count, 121 int channel_count,
125 int sample_rate, 122 int sample_rate,
126 int frame_count, 123 int frame_count,
127 bool create_buffer, 124 bool create_buffer,
128 const uint8* const* data, 125 const uint8* const* data,
129 const base::TimeDelta timestamp, 126 const base::TimeDelta timestamp);
130 const base::TimeDelta duration);
131 127
132 virtual ~AudioBuffer(); 128 virtual ~AudioBuffer();
133 129
134 const SampleFormat sample_format_; 130 const SampleFormat sample_format_;
135 const ChannelLayout channel_layout_; 131 const ChannelLayout channel_layout_;
136 const int channel_count_; 132 const int channel_count_;
137 const int sample_rate_; 133 const int sample_rate_;
138 int adjusted_frame_count_; 134 int adjusted_frame_count_;
139 int trim_start_; 135 int trim_start_;
140 const bool end_of_stream_; 136 const bool end_of_stream_;
141 base::TimeDelta timestamp_; 137 base::TimeDelta timestamp_;
142 base::TimeDelta duration_; 138 base::TimeDelta duration_;
143 139
144 // Contiguous block of channel data. 140 // Contiguous block of channel data.
145 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; 141 scoped_ptr<uint8, base::AlignedFreeDeleter> data_;
146 142
147 // For planar data, points to each channels data. 143 // For planar data, points to each channels data.
148 std::vector<uint8*> channel_data_; 144 std::vector<uint8*> channel_data_;
149 145
150 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); 146 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer);
151 }; 147 };
152 148
153 } // namespace media 149 } // namespace media
154 150
155 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ 151 #endif // MEDIA_BASE_AUDIO_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698