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

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

Issue 7572040: Enable media.dll / libmedia.so. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/h264_bitstream_converter.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Filters are connected in a strongly typed manner, with downstream filters 5 // Filters are connected in a strongly typed manner, with downstream filters
6 // always reading data from upstream filters. Upstream filters have no clue 6 // always reading data from upstream filters. Upstream filters have no clue
7 // who is actually reading from them, and return the results via callbacks. 7 // who is actually reading from them, and return the results via callbacks.
8 // 8 //
9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer 9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer
10 // DataSource <- Demuxer < 10 // DataSource <- Demuxer <
(...skipping 14 matching lines...) Expand all
25 25
26 #include <limits> 26 #include <limits>
27 #include <string> 27 #include <string>
28 28
29 #include "base/callback.h" 29 #include "base/callback.h"
30 #include "base/callback_old.h" 30 #include "base/callback_old.h"
31 #include "base/memory/ref_counted.h" 31 #include "base/memory/ref_counted.h"
32 #include "base/memory/scoped_ptr.h" 32 #include "base/memory/scoped_ptr.h"
33 #include "base/time.h" 33 #include "base/time.h"
34 #include "media/base/audio_decoder_config.h" 34 #include "media/base/audio_decoder_config.h"
35 #include "media/base/media_export.h"
35 #include "media/base/pipeline_status.h" 36 #include "media/base/pipeline_status.h"
36 #include "media/base/video_frame.h" 37 #include "media/base/video_frame.h"
37 38
38 struct AVStream; 39 struct AVStream;
39 40
40 namespace media { 41 namespace media {
41 42
42 class Buffer; 43 class Buffer;
43 class Decoder; 44 class Decoder;
44 class DemuxerStream; 45 class DemuxerStream;
(...skipping 15 matching lines...) Expand all
60 AUTO, 61 AUTO,
61 }; 62 };
62 63
63 // Used for completing asynchronous methods. 64 // Used for completing asynchronous methods.
64 typedef Callback0::Type FilterCallback; 65 typedef Callback0::Type FilterCallback;
65 typedef base::Callback<void(PipelineStatus)> FilterStatusCB; 66 typedef base::Callback<void(PipelineStatus)> FilterStatusCB;
66 67
67 // This function copies |cb|, calls Reset() on |cb|, and then calls Run() 68 // This function copies |cb|, calls Reset() on |cb|, and then calls Run()
68 // on the copy. This is used in the common case where you need to clear 69 // on the copy. This is used in the common case where you need to clear
69 // a callback member variable before running the callback. 70 // a callback member variable before running the callback.
70 void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status); 71 MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status);
71 72
72 // Used for updating pipeline statistics. 73 // Used for updating pipeline statistics.
73 typedef Callback1<const PipelineStatistics&>::Type StatisticsCallback; 74 typedef Callback1<const PipelineStatistics&>::Type StatisticsCallback;
74 75
75 class Filter : public base::RefCountedThreadSafe<Filter> { 76 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> {
76 public: 77 public:
77 Filter(); 78 Filter();
78 79
79 // Sets the private member |host_|. This is the first method called by 80 // Sets the private member |host_|. This is the first method called by
80 // the FilterHost after a filter is created. The host holds a strong 81 // the FilterHost after a filter is created. The host holds a strong
81 // reference to the filter. The reference held by the host is guaranteed 82 // reference to the filter. The reference held by the host is guaranteed
82 // to be released before the host object is destroyed by the pipeline. 83 // to be released before the host object is destroyed by the pipeline.
83 virtual void set_host(FilterHost* host); 84 virtual void set_host(FilterHost* host);
84 85
85 virtual FilterHost* host(); 86 virtual FilterHost* host();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 virtual ~Filter(); 124 virtual ~Filter();
124 125
125 FilterHost* host() const { return host_; } 126 FilterHost* host() const { return host_; }
126 127
127 private: 128 private:
128 FilterHost* host_; 129 FilterHost* host_;
129 130
130 DISALLOW_COPY_AND_ASSIGN(Filter); 131 DISALLOW_COPY_AND_ASSIGN(Filter);
131 }; 132 };
132 133
133 class DataSource : public Filter { 134 class MEDIA_EXPORT DataSource : public Filter {
134 public: 135 public:
135 typedef Callback1<size_t>::Type ReadCallback; 136 typedef Callback1<size_t>::Type ReadCallback;
136 static const size_t kReadError = static_cast<size_t>(-1); 137 static const size_t kReadError = static_cast<size_t>(-1);
137 138
138 // Reads |size| bytes from |position| into |data|. And when the read is done 139 // Reads |size| bytes from |position| into |data|. And when the read is done
139 // or failed, |read_callback| is called with the number of bytes read or 140 // or failed, |read_callback| is called with the number of bytes read or
140 // kReadError in case of error. 141 // kReadError in case of error.
141 // TODO(hclam): should change |size| to int! It makes the code so messy 142 // TODO(hclam): should change |size| to int! It makes the code so messy
142 // with size_t and int all over the place.. 143 // with size_t and int all over the place..
143 virtual void Read(int64 position, size_t size, 144 virtual void Read(int64 position, size_t size,
144 uint8* data, ReadCallback* read_callback) = 0; 145 uint8* data, ReadCallback* read_callback) = 0;
145 146
146 // Returns true and the file size, false if the file size could not be 147 // Returns true and the file size, false if the file size could not be
147 // retrieved. 148 // retrieved.
148 virtual bool GetSize(int64* size_out) = 0; 149 virtual bool GetSize(int64* size_out) = 0;
149 150
150 // Returns true if we are performing streaming. In this case seeking is 151 // Returns true if we are performing streaming. In this case seeking is
151 // not possible. 152 // not possible.
152 virtual bool IsStreaming() = 0; 153 virtual bool IsStreaming() = 0;
153 154
154 // Alert the DataSource that the video preload value has been changed. 155 // Alert the DataSource that the video preload value has been changed.
155 virtual void SetPreload(Preload preload) = 0; 156 virtual void SetPreload(Preload preload) = 0;
156 }; 157 };
157 158
158 class DemuxerStream : public base::RefCountedThreadSafe<DemuxerStream> { 159 class MEDIA_EXPORT DemuxerStream
160 : public base::RefCountedThreadSafe<DemuxerStream> {
159 public: 161 public:
160 typedef base::Callback<void(Buffer*)> ReadCallback; 162 typedef base::Callback<void(Buffer*)> ReadCallback;
161 163
162 enum Type { 164 enum Type {
163 UNKNOWN, 165 UNKNOWN,
164 AUDIO, 166 AUDIO,
165 VIDEO, 167 VIDEO,
166 NUM_TYPES, // Always keep this entry as the last one! 168 NUM_TYPES, // Always keep this entry as the last one!
167 }; 169 };
168 170
169 // Schedules a read. When the |read_callback| is called, the downstream 171 // Schedules a read. When the |read_callback| is called, the downstream
170 // filter takes ownership of the buffer by AddRef()'ing the buffer. 172 // filter takes ownership of the buffer by AddRef()'ing the buffer.
171 virtual void Read(const ReadCallback& read_callback) = 0; 173 virtual void Read(const ReadCallback& read_callback) = 0;
172 174
173 // Returns an |AVStream*| if supported, or NULL. 175 // Returns an |AVStream*| if supported, or NULL.
174 virtual AVStream* GetAVStream(); 176 virtual AVStream* GetAVStream();
175 177
176 // Returns the type of stream. 178 // Returns the type of stream.
177 virtual Type type() = 0; 179 virtual Type type() = 0;
178 180
179 virtual void EnableBitstreamConverter() = 0; 181 virtual void EnableBitstreamConverter() = 0;
180 182
181 protected: 183 protected:
182 friend class base::RefCountedThreadSafe<DemuxerStream>; 184 friend class base::RefCountedThreadSafe<DemuxerStream>;
183 virtual ~DemuxerStream(); 185 virtual ~DemuxerStream();
184 }; 186 };
185 187
186 class Demuxer : public Filter { 188 class MEDIA_EXPORT Demuxer : public Filter {
187 public: 189 public:
188 // Returns the given stream type, or NULL if that type is not present. 190 // Returns the given stream type, or NULL if that type is not present.
189 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0; 191 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0;
190 192
191 // Alert the Demuxer that the video preload value has been changed. 193 // Alert the Demuxer that the video preload value has been changed.
192 virtual void SetPreload(Preload preload) = 0; 194 virtual void SetPreload(Preload preload) = 0;
193 195
194 // Returns the starting time for the media file. 196 // Returns the starting time for the media file.
195 virtual base::TimeDelta GetStartTime() const = 0; 197 virtual base::TimeDelta GetStartTime() const = 0;
196 }; 198 };
197 199
198 200
199 class VideoDecoder : public Filter { 201 class MEDIA_EXPORT VideoDecoder : public Filter {
200 public: 202 public:
201 // Initialize a VideoDecoder with the given DemuxerStream, executing the 203 // Initialize a VideoDecoder with the given DemuxerStream, executing the
202 // callback upon completion. 204 // callback upon completion.
203 // stats_callback is used to update global pipeline statistics. 205 // stats_callback is used to update global pipeline statistics.
204 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback, 206 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback,
205 StatisticsCallback* stats_callback) = 0; 207 StatisticsCallback* stats_callback) = 0;
206 208
207 // Renderer provides an output buffer for Decoder to write to. These buffers 209 // Renderer provides an output buffer for Decoder to write to. These buffers
208 // will be recycled to renderer via the permanent callback. 210 // will be recycled to renderer via the permanent callback.
209 // 211 //
(...skipping 28 matching lines...) Expand all
238 } 240 }
239 241
240 VideoDecoder(); 242 VideoDecoder();
241 virtual ~VideoDecoder(); 243 virtual ~VideoDecoder();
242 244
243 private: 245 private:
244 ConsumeVideoFrameCB consume_video_frame_callback_; 246 ConsumeVideoFrameCB consume_video_frame_callback_;
245 }; 247 };
246 248
247 249
248 class AudioDecoder : public Filter { 250 class MEDIA_EXPORT AudioDecoder : public Filter {
249 public: 251 public:
250 // Initialize a AudioDecoder with the given DemuxerStream, executing the 252 // Initialize a AudioDecoder with the given DemuxerStream, executing the
251 // callback upon completion. 253 // callback upon completion.
252 // stats_callback is used to update global pipeline statistics. 254 // stats_callback is used to update global pipeline statistics.
253 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback, 255 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback,
254 StatisticsCallback* stats_callback) = 0; 256 StatisticsCallback* stats_callback) = 0;
255 257
256 virtual AudioDecoderConfig config() = 0; 258 virtual AudioDecoderConfig config() = 0;
257 259
258 // Renderer provides an output buffer for Decoder to write to. These buffers 260 // Renderer provides an output buffer for Decoder to write to. These buffers
(...skipping 14 matching lines...) Expand all
273 virtual ~AudioDecoder(); 275 virtual ~AudioDecoder();
274 276
275 // Executes the permanent callback to pass off decoded audio. 277 // Executes the permanent callback to pass off decoded audio.
276 void ConsumeAudioSamples(scoped_refptr<Buffer> buffer); 278 void ConsumeAudioSamples(scoped_refptr<Buffer> buffer);
277 279
278 private: 280 private:
279 ConsumeAudioSamplesCB consume_audio_samples_callback_; 281 ConsumeAudioSamplesCB consume_audio_samples_callback_;
280 }; 282 };
281 283
282 284
283 class VideoRenderer : public Filter { 285 class MEDIA_EXPORT VideoRenderer : public Filter {
284 public: 286 public:
285 // Initialize a VideoRenderer with the given VideoDecoder, executing the 287 // Initialize a VideoRenderer with the given VideoDecoder, executing the
286 // callback upon completion. 288 // callback upon completion.
287 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback, 289 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback,
288 StatisticsCallback* stats_callback) = 0; 290 StatisticsCallback* stats_callback) = 0;
289 291
290 // Returns true if this filter has received and processed an end-of-stream 292 // Returns true if this filter has received and processed an end-of-stream
291 // buffer. 293 // buffer.
292 virtual bool HasEnded() = 0; 294 virtual bool HasEnded() = 0;
293 }; 295 };
294 296
295 297
296 class AudioRenderer : public Filter { 298 class MEDIA_EXPORT AudioRenderer : public Filter {
297 public: 299 public:
298 // Initialize a AudioRenderer with the given AudioDecoder, executing the 300 // Initialize a AudioRenderer with the given AudioDecoder, executing the
299 // callback upon completion. 301 // callback upon completion.
300 virtual void Initialize(AudioDecoder* decoder, FilterCallback* callback) = 0; 302 virtual void Initialize(AudioDecoder* decoder, FilterCallback* callback) = 0;
301 303
302 // Returns true if this filter has received and processed an end-of-stream 304 // Returns true if this filter has received and processed an end-of-stream
303 // buffer. 305 // buffer.
304 virtual bool HasEnded() = 0; 306 virtual bool HasEnded() = 0;
305 307
306 // Sets the output volume. 308 // Sets the output volume.
307 virtual void SetVolume(float volume) = 0; 309 virtual void SetVolume(float volume) = 0;
308 }; 310 };
309 311
310 } // namespace media 312 } // namespace media
311 313
312 #endif // MEDIA_BASE_FILTERS_H_ 314 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/h264_bitstream_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698