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

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

Issue 10836167: Move VideoDecoder initialization into VideoRendererBase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_FILTERS_VIDEO_RENDERER_BASE_H_ 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/condition_variable.h" 11 #include "base/synchronization/condition_variable.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "media/base/demuxer_stream.h"
14 #include "media/base/pipeline_status.h" 15 #include "media/base/pipeline_status.h"
15 #include "media/base/video_decoder.h" 16 #include "media/base/video_decoder.h"
16 #include "media/base/video_frame.h" 17 #include "media/base/video_frame.h"
17 #include "media/base/video_renderer.h" 18 #include "media/base/video_renderer.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 // VideoRendererBase creates its own thread for the sole purpose of timing frame 22 // VideoRendererBase creates its own thread for the sole purpose of timing frame
22 // presentation. It handles reading from the decoder and stores the results in 23 // presentation. It handles reading from the decoder and stores the results in
23 // a queue of decoded frames and executing a callback when a frame is ready for 24 // a queue of decoded frames and executing a callback when a frame is ready for
(...skipping 19 matching lines...) Expand all
43 // 44 //
44 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 45 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
45 // 46 //
46 // TODO(scherkus): pass the VideoFrame* to this callback and remove 47 // TODO(scherkus): pass the VideoFrame* to this callback and remove
47 // Get/PutCurrentFrame() http://crbug.com/108435 48 // Get/PutCurrentFrame() http://crbug.com/108435
48 VideoRendererBase(const base::Closure& paint_cb, 49 VideoRendererBase(const base::Closure& paint_cb,
49 const SetOpaqueCB& set_opaque_cb, 50 const SetOpaqueCB& set_opaque_cb,
50 bool drop_frames); 51 bool drop_frames);
51 52
52 // VideoRenderer implementation. 53 // VideoRenderer implementation.
53 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, 54 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
55 const VideoDecoderList& decoders,
54 const PipelineStatusCB& init_cb, 56 const PipelineStatusCB& init_cb,
55 const StatisticsCB& statistics_cb, 57 const StatisticsCB& statistics_cb,
56 const TimeCB& max_time_cb, 58 const TimeCB& max_time_cb,
57 const NaturalSizeChangedCB& size_changed_cb, 59 const NaturalSizeChangedCB& size_changed_cb,
58 const base::Closure& ended_cb, 60 const base::Closure& ended_cb,
59 const PipelineStatusCB& error_cb, 61 const PipelineStatusCB& error_cb,
60 const TimeDeltaCB& get_time_cb, 62 const TimeDeltaCB& get_time_cb,
61 const TimeDeltaCB& get_duration_cb) OVERRIDE; 63 const TimeDeltaCB& get_duration_cb) OVERRIDE;
62 virtual void Play(const base::Closure& callback) OVERRIDE; 64 virtual void Play(const base::Closure& callback) OVERRIDE;
63 virtual void Pause(const base::Closure& callback) OVERRIDE; 65 virtual void Pause(const base::Closure& callback) OVERRIDE;
64 virtual void Flush(const base::Closure& callback) OVERRIDE; 66 virtual void Flush(const base::Closure& callback) OVERRIDE;
65 virtual void Preroll(base::TimeDelta time, 67 virtual void Preroll(base::TimeDelta time,
66 const PipelineStatusCB& cb) OVERRIDE; 68 const PipelineStatusCB& cb) OVERRIDE;
67 virtual void Stop(const base::Closure& callback) OVERRIDE; 69 virtual void Stop(const base::Closure& callback) OVERRIDE;
68 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; 70 virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
69 virtual bool HasEnded() OVERRIDE; 71 virtual bool HasEnded() OVERRIDE;
72 virtual void PrepareForShutdownHack() OVERRIDE;
70 73
71 // PlatformThread::Delegate implementation. 74 // PlatformThread::Delegate implementation.
72 virtual void ThreadMain() OVERRIDE; 75 virtual void ThreadMain() OVERRIDE;
73 76
74 // Clients of this class (painter/compositor) should use GetCurrentFrame() 77 // Clients of this class (painter/compositor) should use GetCurrentFrame()
75 // obtain ownership of VideoFrame, it should always relinquish the ownership 78 // obtain ownership of VideoFrame, it should always relinquish the ownership
76 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL. 79 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL.
77 // It expects clients to use color-fill the background if current frame 80 // It expects clients to use color-fill the background if current frame
78 // is NULL. This could happen before pipeline is pre-rolled or during 81 // is NULL. This could happen before pipeline is pre-rolled or during
79 // pause/flush/preroll. 82 // pause/flush/preroll.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Helper function that flushes the buffers when a Stop() or error occurs. 116 // Helper function that flushes the buffers when a Stop() or error occurs.
114 void DoStopOrError_Locked(); 117 void DoStopOrError_Locked();
115 118
116 // Return the number of frames currently held by this class. 119 // Return the number of frames currently held by this class.
117 int NumFrames_Locked() const; 120 int NumFrames_Locked() const;
118 121
119 // Updates |current_frame_| to the next frame on |ready_frames_| and calls 122 // Updates |current_frame_| to the next frame on |ready_frames_| and calls
120 // |size_changed_cb_| if the natural size changes. 123 // |size_changed_cb_| if the natural size changes.
121 void SetCurrentFrameToNextReadyFrame(); 124 void SetCurrentFrameToNextReadyFrame();
122 125
126 // Pops the front of |decoders_|, assigns it to |decoder_| and then
127 // calls initialize on the new decoder.
128 void InitializeNextDecoder();
129
130 // Called when |decoder_| initialization completes.
131 void OnDecoderInitDone(PipelineStatus status);
132
123 // Used for accessing data members. 133 // Used for accessing data members.
124 base::Lock lock_; 134 base::Lock lock_;
125 135
136 // List of candidate decoders to try during initialization.
137 VideoDecoderList decoders_;
Ami GONE FROM CHROMIUM 2012/08/09 20:30:18 This is only used during initialization, so could
acolwell GONE FROM CHROMIUM 2012/08/09 22:23:32 Done.
138
139 scoped_refptr<DemuxerStream> demuxer_stream_;
Ami GONE FROM CHROMIUM 2012/08/09 20:30:18 ditto
acolwell GONE FROM CHROMIUM 2012/08/09 22:23:32 Done.
126 scoped_refptr<VideoDecoder> decoder_; 140 scoped_refptr<VideoDecoder> decoder_;
127 141
128 // Queue of incoming frames as well as the current frame since the last time 142 // Queue of incoming frames as well as the current frame since the last time
129 // OnFrameAvailable() was called. 143 // OnFrameAvailable() was called.
130 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; 144 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue;
131 VideoFrameQueue ready_frames_; 145 VideoFrameQueue ready_frames_;
132 146
133 // The current frame available to subclasses for rendering via 147 // The current frame available to subclasses for rendering via
134 // GetCurrentFrame(). |current_frame_| can only be altered when 148 // GetCurrentFrame(). |current_frame_| can only be altered when
135 // |pending_paint_| is false. 149 // |pending_paint_| is false.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 218
205 bool drop_frames_; 219 bool drop_frames_;
206 220
207 float playback_rate_; 221 float playback_rate_;
208 222
209 // Playback operation callbacks. 223 // Playback operation callbacks.
210 base::Closure flush_cb_; 224 base::Closure flush_cb_;
211 PipelineStatusCB preroll_cb_; 225 PipelineStatusCB preroll_cb_;
212 226
213 // Event callbacks. 227 // Event callbacks.
228 PipelineStatusCB init_cb_;
214 StatisticsCB statistics_cb_; 229 StatisticsCB statistics_cb_;
215 TimeCB max_time_cb_; 230 TimeCB max_time_cb_;
216 NaturalSizeChangedCB size_changed_cb_; 231 NaturalSizeChangedCB size_changed_cb_;
217 base::Closure ended_cb_; 232 base::Closure ended_cb_;
218 PipelineStatusCB error_cb_; 233 PipelineStatusCB error_cb_;
219 TimeDeltaCB get_time_cb_; 234 TimeDeltaCB get_time_cb_;
220 TimeDeltaCB get_duration_cb_; 235 TimeDeltaCB get_duration_cb_;
221 236
222 base::TimeDelta preroll_timestamp_; 237 base::TimeDelta preroll_timestamp_;
223 238
(...skipping 10 matching lines...) Expand all
234 249
235 // The last natural size |size_changed_cb_| was called with. 250 // The last natural size |size_changed_cb_| was called with.
236 gfx::Size last_natural_size_; 251 gfx::Size last_natural_size_;
237 252
238 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); 253 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase);
239 }; 254 };
240 255
241 } // namespace media 256 } // namespace media
242 257
243 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 258 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698