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

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

Issue 1053113002: Prime the landing pad for the new video rendering pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Revert canvas changes. Created 5 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
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 <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/synchronization/condition_variable.h" 14 #include "base/synchronization/condition_variable.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "media/base/decryptor.h" 17 #include "media/base/decryptor.h"
18 #include "media/base/demuxer_stream.h" 18 #include "media/base/demuxer_stream.h"
19 #include "media/base/media_log.h" 19 #include "media/base/media_log.h"
20 #include "media/base/pipeline_status.h" 20 #include "media/base/pipeline_status.h"
21 #include "media/base/video_decoder.h" 21 #include "media/base/video_decoder.h"
22 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
23 #include "media/base/video_renderer.h" 23 #include "media/base/video_renderer.h"
24 #include "media/base/video_renderer_sink.h"
24 #include "media/filters/decoder_stream.h" 25 #include "media/filters/decoder_stream.h"
25 26
26 namespace base { 27 namespace base {
27 class SingleThreadTaskRunner; 28 class SingleThreadTaskRunner;
28 class TickClock; 29 class TickClock;
29 } 30 }
30 31
31 namespace media { 32 namespace media {
32 33
33 // VideoRendererImpl creates its own thread for the sole purpose of timing frame 34 // VideoRendererImpl creates its own thread for the sole purpose of timing frame
34 // presentation. It handles reading from the VideoFrameStream and stores the 35 // presentation. It handles reading from the VideoFrameStream and stores the
35 // results in a queue of decoded frames and executing a callback when a frame is 36 // results in a queue of decoded frames and executing a callback when a frame is
36 // ready for rendering. 37 // ready for rendering.
37 class MEDIA_EXPORT VideoRendererImpl 38 class MEDIA_EXPORT VideoRendererImpl
38 : public VideoRenderer, 39 : public VideoRenderer,
39 public base::PlatformThread::Delegate { 40 public base::PlatformThread::Delegate {
40 public: 41 public:
41 // |decoders| contains the VideoDecoders to use when initializing. 42 // |decoders| contains the VideoDecoders to use when initializing.
42 // 43 //
43 // Implementors should avoid doing any sort of heavy work in this method and 44 // Implementors should avoid doing any sort of heavy work in this method and
44 // instead post a task to a common/worker thread to handle rendering. Slowing 45 // instead post a task to a common/worker thread to handle rendering. Slowing
45 // down the video thread may result in losing synchronization with audio. 46 // down the video thread may result in losing synchronization with audio.
46 // 47 //
47 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 48 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
48 VideoRendererImpl( 49 VideoRendererImpl(
49 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
51 VideoRendererSink* sink,
50 ScopedVector<VideoDecoder> decoders, 52 ScopedVector<VideoDecoder> decoders,
51 bool drop_frames, 53 bool drop_frames,
52 const scoped_refptr<MediaLog>& media_log); 54 const scoped_refptr<MediaLog>& media_log);
53 ~VideoRendererImpl() override; 55 ~VideoRendererImpl() override;
54 56
55 // VideoRenderer implementation. 57 // VideoRenderer implementation.
56 void Initialize(DemuxerStream* stream, 58 void Initialize(DemuxerStream* stream,
57 const PipelineStatusCB& init_cb, 59 const PipelineStatusCB& init_cb,
58 const SetDecryptorReadyCB& set_decryptor_ready_cb, 60 const SetDecryptorReadyCB& set_decryptor_ready_cb,
59 const StatisticsCB& statistics_cb, 61 const StatisticsCB& statistics_cb,
60 const BufferingStateCB& buffering_state_cb, 62 const BufferingStateCB& buffering_state_cb,
61 const PaintCB& paint_cb,
62 const base::Closure& ended_cb, 63 const base::Closure& ended_cb,
63 const PipelineStatusCB& error_cb, 64 const PipelineStatusCB& error_cb,
64 const WallClockTimeCB& wall_clock_time_cb, 65 const WallClockTimeCB& wall_clock_time_cb,
65 const base::Closure& waiting_for_decryption_key_cb) override; 66 const base::Closure& waiting_for_decryption_key_cb) override;
66 void Flush(const base::Closure& callback) override; 67 void Flush(const base::Closure& callback) override;
67 void StartPlayingFrom(base::TimeDelta timestamp) override; 68 void StartPlayingFrom(base::TimeDelta timestamp) override;
68 69
69 // PlatformThread::Delegate implementation. 70 // PlatformThread::Delegate implementation.
70 void ThreadMain() override; 71 void ThreadMain() override;
71 72
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool HaveEnoughData_Locked(); 115 bool HaveEnoughData_Locked();
115 void TransitionToHaveEnough_Locked(); 116 void TransitionToHaveEnough_Locked();
116 117
117 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets 118 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets
118 // them to 0, and then waits on |frame_available_| for up to the 119 // them to 0, and then waits on |frame_available_| for up to the
119 // |wait_duration|. 120 // |wait_duration|.
120 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration); 121 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration);
121 122
122 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 123 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
123 124
125 VideoRendererSink* const sink_;
126
124 // Used for accessing data members. 127 // Used for accessing data members.
125 base::Lock lock_; 128 base::Lock lock_;
126 129
127 // Provides video frames to VideoRendererImpl. 130 // Provides video frames to VideoRendererImpl.
128 scoped_ptr<VideoFrameStream> video_frame_stream_; 131 scoped_ptr<VideoFrameStream> video_frame_stream_;
129 132
130 // Flag indicating low-delay mode. 133 // Flag indicating low-delay mode.
131 bool low_delay_; 134 bool low_delay_;
132 135
133 // Queue of incoming frames yet to be painted. 136 // Queue of incoming frames yet to be painted.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 218
216 // NOTE: Weak pointers must be invalidated before all other member variables. 219 // NOTE: Weak pointers must be invalidated before all other member variables.
217 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 220 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
218 221
219 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 222 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
220 }; 223 };
221 224
222 } // namespace media 225 } // namespace media
223 226
224 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 227 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698