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

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: recycling: vanquished 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 // Frames will be non-NULL yet may be end of stream frames.
174 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame) = 0; 176 typedef base::Callback<void(scoped_refptr<VideoFrame>)> FrameReadyCB;
acolwell GONE FROM CHROMIUM 2011/11/01 18:31:03 Rename to ReadCB or ReadCallback? This is just to
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 FWIW, we decided a long time ago to use *CB for th
scherkus (not reviewing) 2011/11/03 04:55:59 Renamed to ReadCB (I am fond of the shortness!) bu
175 177 virtual void Read(const FrameReadyCB& callback) = 0;
176 // Installs a permanent callback for passing decoded video output.
177 //
178 // A NULL frame represents a decoding error.
179 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ConsumeVideoFrameCB;
180 void set_consume_video_frame_callback(const ConsumeVideoFrameCB& callback) {
181 consume_video_frame_callback_ = callback;
182 }
183 178
184 // Returns the natural width and height of decoded video in pixels. 179 // Returns the natural width and height of decoded video in pixels.
185 // 180 //
186 // Clients should NOT rely on these values to remain constant. Instead, use 181 // Clients should NOT rely on these values to remain constant. Instead, use
187 // the width/height from decoded video frames themselves. 182 // the width/height from decoded video frames themselves.
188 // 183 //
189 // TODO(scherkus): why not rely on prerolling and decoding a single frame to 184 // TODO(scherkus): why not rely on prerolling and decoding a single frame to
190 // get dimensions? 185 // get dimensions?
191 virtual gfx::Size natural_size() = 0; 186 virtual gfx::Size natural_size() = 0;
192 187
193 protected: 188 protected:
194 // Executes the permanent callback to pass off decoded video.
195 //
196 // TODO(scherkus): name this ConsumeVideoFrame() once we fix the TODO in
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 I, for one, welcome our new reduced-craxy overlord
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(); 189 VideoDecoder();
203 virtual ~VideoDecoder(); 190 virtual ~VideoDecoder();
204
205 private:
206 ConsumeVideoFrameCB consume_video_frame_callback_;
207 }; 191 };
208 192
209 193
210 class MEDIA_EXPORT AudioDecoder : public Filter { 194 class MEDIA_EXPORT AudioDecoder : public Filter {
211 public: 195 public:
212 // Initialize a AudioDecoder with the given DemuxerStream, executing the 196 // Initialize a AudioDecoder with the given DemuxerStream, executing the
213 // callback upon completion. 197 // callback upon completion.
214 // stats_callback is used to update global pipeline statistics. 198 // stats_callback is used to update global pipeline statistics.
199 //
200 // TODO(scherkus): switch to PipelineStatus callback.
215 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, 201 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback,
216 const StatisticsCallback& stats_callback) = 0; 202 const StatisticsCallback& stats_callback) = 0;
217 203
218 // Renderer provides an output buffer for Decoder to write to. These buffers 204 // Renderer provides an output buffer for Decoder to write to. These buffers
219 // will be recycled to renderer via the permanent callback. 205 // will be recycled to renderer via the permanent callback.
220 // 206 //
221 // We could also pass empty pointer here to let decoder provide buffers pool. 207 // We could also pass empty pointer here to let decoder provide buffers pool.
222 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0; 208 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0;
223 209
224 // Installs a permanent callback for passing decoded audio output. 210 // Installs a permanent callback for passing decoded audio output.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 265
280 // Resumes playback after underflow occurs. 266 // Resumes playback after underflow occurs.
281 // |buffer_more_audio| is set to true if you want to increase the size of the 267 // |buffer_more_audio| is set to true if you want to increase the size of the
282 // decoded audio buffer. 268 // decoded audio buffer.
283 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; 269 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0;
284 }; 270 };
285 271
286 } // namespace media 272 } // namespace media
287 273
288 #endif // MEDIA_BASE_FILTERS_H_ 274 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698