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

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

Issue 1474843003: Revert of Define AudioBuffer and VideoFrame for mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | media/base/audio_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "media/base/channel_layout.h" 14 #include "media/base/channel_layout.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 #include "media/base/sample_format.h" 16 #include "media/base/sample_format.h"
17 17
18 namespace mojo {
19 template <typename T, typename U>
20 struct TypeConverter;
21 template <typename T>
22 class StructPtr;
23 };
24
25 namespace media { 18 namespace media {
26 class AudioBus; 19 class AudioBus;
27 20
28 namespace interfaces {
29 class AudioBuffer;
30 }
31
32 // An audio buffer that takes a copy of the data passed to it, holds it, and 21 // An audio buffer that takes a copy of the data passed to it, holds it, and
33 // copies it into an AudioBus when needed. Also supports an end of stream 22 // copies it into an AudioBus when needed. Also supports an end of stream
34 // marker. 23 // marker.
35 class MEDIA_EXPORT AudioBuffer 24 class MEDIA_EXPORT AudioBuffer
36 : public base::RefCountedThreadSafe<AudioBuffer> { 25 : public base::RefCountedThreadSafe<AudioBuffer> {
37 public: 26 public:
38 // Alignment of each channel's data; this must match what ffmpeg expects 27 // Alignment of each channel's data; this must match what ffmpeg expects
39 // (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
40 // order to work on all processors. 29 // order to work on all processors.
41 enum { kChannelAlignment = 32 }; 30 enum { kChannelAlignment = 32 };
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // If there's no data in this buffer, it represents end of stream. 116 // If there's no data in this buffer, it represents end of stream.
128 bool end_of_stream() const { return end_of_stream_; } 117 bool end_of_stream() const { return end_of_stream_; }
129 118
130 // Access to the raw buffer for ffmpeg to write directly to. Data for planar 119 // Access to the raw buffer for ffmpeg to write directly to. Data for planar
131 // data is grouped by channel. There is only 1 entry for interleaved formats. 120 // data is grouped by channel. There is only 1 entry for interleaved formats.
132 const std::vector<uint8*>& channel_data() const { return channel_data_; } 121 const std::vector<uint8*>& channel_data() const { return channel_data_; }
133 122
134 private: 123 private:
135 friend class base::RefCountedThreadSafe<AudioBuffer>; 124 friend class base::RefCountedThreadSafe<AudioBuffer>;
136 125
137 // mojo::TypeConverter added as a friend so that AudioBuffer can be
138 // transferred across a mojo connection.
139 friend struct mojo::TypeConverter<mojo::StructPtr<interfaces::AudioBuffer>,
140 scoped_refptr<AudioBuffer>>;
141
142 // Allocates aligned contiguous buffer to hold all channel data (1 block for 126 // Allocates aligned contiguous buffer to hold all channel data (1 block for
143 // interleaved data, |channel_count| blocks for planar data), copies 127 // interleaved data, |channel_count| blocks for planar data), copies
144 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no 128 // [data,data+data_size) to the allocated buffer(s). If |data| is null, no
145 // data is copied. If |create_buffer| is false, no data buffer is created (or 129 // data is copied. If |create_buffer| is false, no data buffer is created (or
146 // copied to). 130 // copied to).
147 AudioBuffer(SampleFormat sample_format, 131 AudioBuffer(SampleFormat sample_format,
148 ChannelLayout channel_layout, 132 ChannelLayout channel_layout,
149 int channel_count, 133 int channel_count,
150 int sample_rate, 134 int sample_rate,
151 int frame_count, 135 int frame_count,
152 bool create_buffer, 136 bool create_buffer,
153 const uint8* const* data, 137 const uint8* const* data,
154 const base::TimeDelta timestamp); 138 const base::TimeDelta timestamp);
155 139
156 virtual ~AudioBuffer(); 140 virtual ~AudioBuffer();
157 141
158 const SampleFormat sample_format_; 142 const SampleFormat sample_format_;
159 const ChannelLayout channel_layout_; 143 const ChannelLayout channel_layout_;
160 const int channel_count_; 144 const int channel_count_;
161 const int sample_rate_; 145 const int sample_rate_;
162 int adjusted_frame_count_; 146 int adjusted_frame_count_;
163 int trim_start_; 147 int trim_start_;
164 const bool end_of_stream_; 148 const bool end_of_stream_;
165 base::TimeDelta timestamp_; 149 base::TimeDelta timestamp_;
166 base::TimeDelta duration_; 150 base::TimeDelta duration_;
167 151
168 // Contiguous block of channel data. 152 // Contiguous block of channel data.
169 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; 153 scoped_ptr<uint8, base::AlignedFreeDeleter> data_;
170 size_t data_size_;
171 154
172 // For planar data, points to each channels data. 155 // For planar data, points to each channels data.
173 std::vector<uint8*> channel_data_; 156 std::vector<uint8*> channel_data_;
174 157
175 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); 158 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer);
176 }; 159 };
177 160
178 } // namespace media 161 } // namespace media
179 162
180 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ 163 #endif // MEDIA_BASE_AUDIO_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698