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

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: Fix cc_unittests 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 bool HaveEnoughData_Locked(); 111 bool HaveEnoughData_Locked();
111 void TransitionToHaveEnough_Locked(); 112 void TransitionToHaveEnough_Locked();
112 113
113 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets 114 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets
114 // them to 0, and then waits on |frame_available_| for up to the 115 // them to 0, and then waits on |frame_available_| for up to the
115 // |wait_duration|. 116 // |wait_duration|.
116 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration); 117 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration);
117 118
118 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 119 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
119 120
121 VideoRendererSink* const sink_;
122
120 // Used for accessing data members. 123 // Used for accessing data members.
121 base::Lock lock_; 124 base::Lock lock_;
122 125
123 // Provides video frames to VideoRendererImpl. 126 // Provides video frames to VideoRendererImpl.
124 scoped_ptr<VideoFrameStream> video_frame_stream_; 127 scoped_ptr<VideoFrameStream> video_frame_stream_;
125 128
126 // Flag indicating low-delay mode. 129 // Flag indicating low-delay mode.
127 bool low_delay_; 130 bool low_delay_;
128 131
129 // Queue of incoming frames yet to be painted. 132 // Queue of incoming frames yet to be painted.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 215
213 // NOTE: Weak pointers must be invalidated before all other member variables. 216 // NOTE: Weak pointers must be invalidated before all other member variables.
214 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 217 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
215 218
216 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 219 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
217 }; 220 };
218 221
219 } // namespace media 222 } // namespace media
220 223
221 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 224 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698