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 1083683003: Speculative revert by sheriff (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed an unrelated commit that had accidentally slipped in. 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
« 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 <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"
25 #include "media/filters/decoder_stream.h" 24 #include "media/filters/decoder_stream.h"
26 25
27 namespace base { 26 namespace base {
28 class SingleThreadTaskRunner; 27 class SingleThreadTaskRunner;
29 class TickClock; 28 class TickClock;
30 } 29 }
31 30
32 namespace media { 31 namespace media {
33 32
34 // VideoRendererImpl creates its own thread for the sole purpose of timing frame 33 // VideoRendererImpl creates its own thread for the sole purpose of timing frame
35 // presentation. It handles reading from the VideoFrameStream and stores the 34 // presentation. It handles reading from the VideoFrameStream and stores the
36 // results in a queue of decoded frames and executing a callback when a frame is 35 // results in a queue of decoded frames and executing a callback when a frame is
37 // ready for rendering. 36 // ready for rendering.
38 class MEDIA_EXPORT VideoRendererImpl 37 class MEDIA_EXPORT VideoRendererImpl
39 : public VideoRenderer, 38 : public VideoRenderer,
40 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback),
41 public base::PlatformThread::Delegate { 39 public base::PlatformThread::Delegate {
42 public: 40 public:
43 // |decoders| contains the VideoDecoders to use when initializing. 41 // |decoders| contains the VideoDecoders to use when initializing.
44 // 42 //
45 // Implementors should avoid doing any sort of heavy work in this method and 43 // Implementors should avoid doing any sort of heavy work in this method and
46 // instead post a task to a common/worker thread to handle rendering. Slowing 44 // instead post a task to a common/worker thread to handle rendering. Slowing
47 // down the video thread may result in losing synchronization with audio. 45 // down the video thread may result in losing synchronization with audio.
48 // 46 //
49 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 47 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
50 VideoRendererImpl( 48 VideoRendererImpl(
51 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 49 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
52 VideoRendererSink* sink,
53 ScopedVector<VideoDecoder> decoders, 50 ScopedVector<VideoDecoder> decoders,
54 bool drop_frames, 51 bool drop_frames,
55 const scoped_refptr<MediaLog>& media_log); 52 const scoped_refptr<MediaLog>& media_log);
56 ~VideoRendererImpl() override; 53 ~VideoRendererImpl() override;
57 54
58 // VideoRenderer implementation. 55 // VideoRenderer implementation.
59 void Initialize(DemuxerStream* stream, 56 void Initialize(DemuxerStream* stream,
60 const PipelineStatusCB& init_cb, 57 const PipelineStatusCB& init_cb,
61 const SetDecryptorReadyCB& set_decryptor_ready_cb, 58 const SetDecryptorReadyCB& set_decryptor_ready_cb,
62 const StatisticsCB& statistics_cb, 59 const StatisticsCB& statistics_cb,
63 const BufferingStateCB& buffering_state_cb, 60 const BufferingStateCB& buffering_state_cb,
61 const PaintCB& paint_cb,
64 const base::Closure& ended_cb, 62 const base::Closure& ended_cb,
65 const PipelineStatusCB& error_cb, 63 const PipelineStatusCB& error_cb,
66 const WallClockTimeCB& wall_clock_time_cb, 64 const WallClockTimeCB& wall_clock_time_cb,
67 const base::Closure& waiting_for_decryption_key_cb) override; 65 const base::Closure& waiting_for_decryption_key_cb) override;
68 void Flush(const base::Closure& callback) override; 66 void Flush(const base::Closure& callback) override;
69 void StartPlayingFrom(base::TimeDelta timestamp) override; 67 void StartPlayingFrom(base::TimeDelta timestamp) override;
70 void OnTimeStateChanged(bool time_progressing) override; 68 void OnTimeStateChanged(bool time_progressing) override;
71 69
72 // PlatformThread::Delegate implementation. 70 // PlatformThread::Delegate implementation.
73 void ThreadMain() override; 71 void ThreadMain() override;
74 72
75 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); 73 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
76 74
77 // VideoRendererSink::RenderCallback implementation.
78 scoped_refptr<VideoFrame> Render(base::TimeTicks deadline_min,
79 base::TimeTicks deadline_max) override;
80 void OnFrameDropped() override;
81
82 private: 75 private:
83 // Creates a dedicated |thread_| for video rendering. 76 // Creates a dedicated |thread_| for video rendering.
84 void CreateVideoThread(); 77 void CreateVideoThread();
85 78
86 // Callback for |video_frame_stream_| initialization. 79 // Callback for |video_frame_stream_| initialization.
87 void OnVideoFrameStreamInitialized(bool success); 80 void OnVideoFrameStreamInitialized(bool success);
88 81
89 // Callback for |video_frame_stream_| to deliver decoded video frames and 82 // Callback for |video_frame_stream_| to deliver decoded video frames and
90 // report video decoding status. 83 // report video decoding status.
91 void FrameReady(VideoFrameStream::Status status, 84 void FrameReady(VideoFrameStream::Status status,
(...skipping 26 matching lines...) Expand all
118 bool HaveEnoughData_Locked(); 111 bool HaveEnoughData_Locked();
119 void TransitionToHaveEnough_Locked(); 112 void TransitionToHaveEnough_Locked();
120 113
121 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets 114 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets
122 // 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
123 // |wait_duration|. 116 // |wait_duration|.
124 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration); 117 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration);
125 118
126 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 119 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
127 120
128 VideoRendererSink* const sink_;
129
130 // Used for accessing data members. 121 // Used for accessing data members.
131 base::Lock lock_; 122 base::Lock lock_;
132 123
133 // Provides video frames to VideoRendererImpl. 124 // Provides video frames to VideoRendererImpl.
134 scoped_ptr<VideoFrameStream> video_frame_stream_; 125 scoped_ptr<VideoFrameStream> video_frame_stream_;
135 126
136 // Flag indicating low-delay mode. 127 // Flag indicating low-delay mode.
137 bool low_delay_; 128 bool low_delay_;
138 129
139 // Queue of incoming frames yet to be painted. 130 // Queue of incoming frames yet to be painted.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 212
222 // NOTE: Weak pointers must be invalidated before all other member variables. 213 // NOTE: Weak pointers must be invalidated before all other member variables.
223 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 214 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
224 215
225 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 216 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
226 }; 217 };
227 218
228 } // namespace media 219 } // namespace media
229 220
230 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 221 #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