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

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

Issue 8417019: Simplify VideoDecodeEngine interface by making everything synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 1 month 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 (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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Notify the DataSource of the bitrate of the media. 157 // Notify the DataSource of the bitrate of the media.
158 // Values of |bitrate| <= 0 are invalid and should be ignored. 158 // Values of |bitrate| <= 0 are invalid and should be ignored.
159 virtual void SetBitrate(int bitrate) = 0; 159 virtual void SetBitrate(int bitrate) = 0;
160 }; 160 };
161 161
162 class MEDIA_EXPORT VideoDecoder : public Filter { 162 class MEDIA_EXPORT VideoDecoder : public Filter {
163 public: 163 public:
164 // Initialize a VideoDecoder with the given DemuxerStream, executing the 164 // Initialize a VideoDecoder with the given DemuxerStream, executing the
165 // callback upon completion. 165 // callback upon completion.
166 // stats_callback is used to update global pipeline statistics. 166 // stats_callback is used to update global pipeline statistics.
167 //
168 // TODO(scherkus): switch to PipelineStatus callback.
167 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, 169 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback,
168 const StatisticsCallback& stats_callback) = 0; 170 const StatisticsCallback& stats_callback) = 0;
169 171
170 // Renderer provides an output buffer for Decoder to write to. These buffers 172 // Request a frame to be decoded and returned via the provided callback.
171 // will be recycled to renderer via the permanent callback. 173 // Only one read may be in flight at any given time.
172 // 174 //
173 // We could also pass empty pointer here to let decoder provide buffers pool. 175 // This method must return immediately without executing the callback.
acolwell GONE FROM CHROMIUM 2011/11/03 20:00:43 Consider adding or replacing with "Implementations
scherkus (not reviewing) 2011/11/03 20:34:38 Done.
174 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame) = 0;
175
176 // Installs a permanent callback for passing decoded video output.
177 // 176 //
178 // A NULL frame represents a decoding error. 177 // ^^^^^^^^^^^ it would be better to require callees to post directly to
scherkus (not reviewing) 2011/11/03 04:55:59 FYI
acolwell GONE FROM CHROMIUM 2011/11/03 20:00:43 I don't think this commentary is useful especially
scherkus (not reviewing) 2011/11/03 20:34:38 Oh I wasn't planning on checking this comment in!
179 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ConsumeVideoFrameCB; 178 // the correct thread and have objects that only expect to live on one
180 void set_consume_video_frame_callback(const ConsumeVideoFrameCB& callback) { 179 // thread, but I can dream, can't I?
181 consume_video_frame_callback_ = callback; 180 //
182 } 181 // Frames will be non-NULL yet may be end of stream frames.
182 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB;
183 virtual void Read(const ReadCB& callback) = 0;
183 184
184 // Returns the natural width and height of decoded video in pixels. 185 // Returns the natural width and height of decoded video in pixels.
185 // 186 //
186 // Clients should NOT rely on these values to remain constant. Instead, use 187 // Clients should NOT rely on these values to remain constant. Instead, use
187 // the width/height from decoded video frames themselves. 188 // the width/height from decoded video frames themselves.
188 // 189 //
189 // TODO(scherkus): why not rely on prerolling and decoding a single frame to 190 // TODO(scherkus): why not rely on prerolling and decoding a single frame to
190 // get dimensions? 191 // get dimensions?
191 virtual gfx::Size natural_size() = 0; 192 virtual gfx::Size natural_size() = 0;
192 193
193 protected: 194 protected:
194 // Executes the permanent callback to pass off decoded video.
195 //
196 // TODO(scherkus): name this ConsumeVideoFrame() once we fix the TODO in
197 // VideoDecodeEngine::EventHandler to remove ConsumeVideoFrame() from there.
198 void VideoFrameReady(scoped_refptr<VideoFrame> frame) {
199 consume_video_frame_callback_.Run(frame);
200 }
201
202 VideoDecoder(); 195 VideoDecoder();
203 virtual ~VideoDecoder(); 196 virtual ~VideoDecoder();
204
205 private:
206 ConsumeVideoFrameCB consume_video_frame_callback_;
207 }; 197 };
208 198
209 199
210 class MEDIA_EXPORT AudioDecoder : public Filter { 200 class MEDIA_EXPORT AudioDecoder : public Filter {
211 public: 201 public:
212 // Initialize a AudioDecoder with the given DemuxerStream, executing the 202 // Initialize a AudioDecoder with the given DemuxerStream, executing the
213 // callback upon completion. 203 // callback upon completion.
214 // stats_callback is used to update global pipeline statistics. 204 // stats_callback is used to update global pipeline statistics.
205 //
206 // TODO(scherkus): switch to PipelineStatus callback.
215 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, 207 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback,
216 const StatisticsCallback& stats_callback) = 0; 208 const StatisticsCallback& stats_callback) = 0;
217 209
218 // Renderer provides an output buffer for Decoder to write to. These buffers 210 // Renderer provides an output buffer for Decoder to write to. These buffers
219 // will be recycled to renderer via the permanent callback. 211 // will be recycled to renderer via the permanent callback.
220 // 212 //
221 // We could also pass empty pointer here to let decoder provide buffers pool. 213 // We could also pass empty pointer here to let decoder provide buffers pool.
222 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0; 214 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0;
223 215
224 // Installs a permanent callback for passing decoded audio output. 216 // Installs a permanent callback for passing decoded audio output.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 271
280 // Resumes playback after underflow occurs. 272 // Resumes playback after underflow occurs.
281 // |buffer_more_audio| is set to true if you want to increase the size of the 273 // |buffer_more_audio| is set to true if you want to increase the size of the
282 // decoded audio buffer. 274 // decoded audio buffer.
283 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; 275 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0;
284 }; 276 };
285 277
286 } // namespace media 278 } // namespace media
287 279
288 #endif // MEDIA_BASE_FILTERS_H_ 280 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698