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

Side by Side Diff: media/renderers/video_renderer_impl.h

Issue 2684103005: Allow media track switching. (Closed)
Patch Set: Fixed comments Created 3 years, 8 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
« no previous file with comments | « media/renderers/renderer_impl_unittest.cc ('k') | media/renderers/video_renderer_impl.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_RENDERERS_VIDEO_RENDERER_IMPL_H_ 5 #ifndef MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "media/base/decryptor.h" 21 #include "media/base/decryptor.h"
22 #include "media/base/demuxer_stream.h" 22 #include "media/base/demuxer_stream.h"
23 #include "media/base/media_log.h" 23 #include "media/base/media_log.h"
24 #include "media/base/pipeline_status.h" 24 #include "media/base/pipeline_status.h"
25 #include "media/base/video_decoder.h" 25 #include "media/base/video_decoder.h"
26 #include "media/base/video_frame.h" 26 #include "media/base/video_frame.h"
27 #include "media/base/video_renderer.h" 27 #include "media/base/video_renderer.h"
28 #include "media/base/video_renderer_sink.h" 28 #include "media/base/video_renderer_sink.h"
29 #include "media/filters/decoder_stream.h" 29 #include "media/filters/decoder_stream.h"
30 #include "media/filters/video_renderer_algorithm.h" 30 #include "media/filters/video_renderer_algorithm.h"
31 #include "media/renderers/default_renderer_factory.h"
31 #include "media/renderers/gpu_video_accelerator_factories.h" 32 #include "media/renderers/gpu_video_accelerator_factories.h"
32 #include "media/video/gpu_memory_buffer_video_frame_pool.h" 33 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
33 34
34 namespace base { 35 namespace base {
35 class SingleThreadTaskRunner; 36 class SingleThreadTaskRunner;
36 class TickClock; 37 class TickClock;
37 } 38 }
38 39
39 namespace media { 40 namespace media {
40 41
41 // VideoRendererImpl handles reading from a VideoFrameStream storing the 42 // VideoRendererImpl handles reading from a VideoFrameStream storing the
42 // results in a queue of decoded frames and executing a callback when a frame is 43 // results in a queue of decoded frames and executing a callback when a frame is
43 // ready for rendering. 44 // ready for rendering.
44 class MEDIA_EXPORT VideoRendererImpl 45 class MEDIA_EXPORT VideoRendererImpl
45 : public VideoRenderer, 46 : public VideoRenderer,
46 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback) { 47 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback) {
47 public: 48 public:
48 // |decoders| contains the VideoDecoders to use when initializing. 49 // |decoders| contains the VideoDecoders to use when initializing.
49 // 50 //
50 // Implementors should avoid doing any sort of heavy work in this method and 51 // Implementors should avoid doing any sort of heavy work in this method and
51 // instead post a task to a common/worker thread to handle rendering. Slowing 52 // instead post a task to a common/worker thread to handle rendering. Slowing
52 // down the video thread may result in losing synchronization with audio. 53 // down the video thread may result in losing synchronization with audio.
53 // 54 //
54 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 55 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
55 VideoRendererImpl( 56 VideoRendererImpl(
56 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 57 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
57 const scoped_refptr<base::TaskRunner>& worker_task_runner, 58 const scoped_refptr<base::TaskRunner>& worker_task_runner,
58 VideoRendererSink* sink, 59 VideoRendererSink* sink,
59 ScopedVector<VideoDecoder> decoders, 60 const CreateVideoDecodersCB& create_video_decoders_cb,
60 bool drop_frames, 61 bool drop_frames,
61 GpuVideoAcceleratorFactories* gpu_factories, 62 GpuVideoAcceleratorFactories* gpu_factories,
62 const scoped_refptr<MediaLog>& media_log); 63 const scoped_refptr<MediaLog>& media_log);
63 ~VideoRendererImpl() override; 64 ~VideoRendererImpl() override;
64 65
65 // VideoRenderer implementation. 66 // VideoRenderer implementation.
66 void Initialize(DemuxerStream* stream, 67 void Initialize(DemuxerStream* stream,
67 CdmContext* cdm_context, 68 CdmContext* cdm_context,
68 RendererClient* client, 69 RendererClient* client,
69 const TimeSource::WallClockTimeCB& wall_clock_time_cb, 70 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 bool low_delay_; 214 bool low_delay_;
214 215
215 // Keeps track of whether we received the end of stream buffer and finished 216 // Keeps track of whether we received the end of stream buffer and finished
216 // rendering. 217 // rendering.
217 bool received_end_of_stream_; 218 bool received_end_of_stream_;
218 bool rendered_end_of_stream_; 219 bool rendered_end_of_stream_;
219 220
220 // Important detail: being in kPlaying doesn't imply that video is being 221 // Important detail: being in kPlaying doesn't imply that video is being
221 // rendered. Rather, it means that the renderer is ready to go. The actual 222 // rendered. Rather, it means that the renderer is ready to go. The actual
222 // rendering of video is controlled by time advancing via |get_time_cb_|. 223 // rendering of video is controlled by time advancing via |get_time_cb_|.
224 // Video renderer can be reinitialized completely by calling Initialize again
225 // when it is in a kFlushed state with video sink stopped.
223 // 226 //
224 // kUninitialized 227 // kUninitialized
225 // | Initialize() 228 // +------> | Initialize()
226 // | 229 // | |
227 // V 230 // | V
228 // kInitializing 231 // | kInitializing
229 // | Decoders initialized 232 // | | Decoders initialized
230 // | 233 // | |
231 // V Decoders reset 234 // | V Decoders reset
232 // kFlushed <------------------ kFlushing 235 // ---- kFlushed <------------------ kFlushing
233 // | StartPlayingFrom() ^ 236 // | StartPlayingFrom() ^
234 // | | 237 // | |
235 // | | Flush() 238 // | | Flush()
236 // `---------> kPlaying --------' 239 // `---------> kPlaying --------'
237 enum State { 240 enum State {
238 kUninitialized, 241 kUninitialized,
239 kInitializing, 242 kInitializing,
240 kFlushing, 243 kFlushing,
241 kFlushed, 244 kFlushed,
242 kPlaying 245 kPlaying
243 }; 246 };
244 State state_; 247 State state_;
245 248
249 // TODO(servolk): Consider using DecoderFactory here instead of the
250 // CreateVideoDecodersCB.
251 CreateVideoDecodersCB create_video_decoders_cb_;
252 GpuVideoAcceleratorFactories* gpu_factories_;
253 scoped_refptr<base::TaskRunner> worker_task_runner_;
254
246 // Keep track of the outstanding read on the VideoFrameStream. Flushing can 255 // Keep track of the outstanding read on the VideoFrameStream. Flushing can
247 // only complete once the read has completed. 256 // only complete once the read has completed.
248 bool pending_read_; 257 bool pending_read_;
249 258
250 bool drop_frames_; 259 bool drop_frames_;
251 260
252 BufferingState buffering_state_; 261 BufferingState buffering_state_;
253 262
254 // Playback operation callbacks. 263 // Playback operation callbacks.
255 PipelineStatusCB init_cb_; 264 PipelineStatusCB init_cb_;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // want to discard video frames that might be received after the stream has 313 // want to discard video frames that might be received after the stream has
305 // been reset. 314 // been reset.
306 base::WeakPtrFactory<VideoRendererImpl> frame_callback_weak_factory_; 315 base::WeakPtrFactory<VideoRendererImpl> frame_callback_weak_factory_;
307 316
308 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 317 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
309 }; 318 };
310 319
311 } // namespace media 320 } // namespace media
312 321
313 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 322 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl_unittest.cc ('k') | media/renderers/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698