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

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

Issue 1027553002: Change the TimeSource interface to return wallclock time for video. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 5 years, 9 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/filters/decoder_stream.h" 24 #include "media/filters/decoder_stream.h"
25 25
26 namespace base { 26 namespace base {
27 class SingleThreadTaskRunner; 27 class SingleThreadTaskRunner;
28 class TickClock;
28 } 29 }
29 30
30 namespace media { 31 namespace media {
31 32
32 // 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
33 // presentation. It handles reading from the VideoFrameStream and stores the 34 // presentation. It handles reading from the VideoFrameStream and stores the
34 // 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
35 // ready for rendering. 36 // ready for rendering.
36 class MEDIA_EXPORT VideoRendererImpl 37 class MEDIA_EXPORT VideoRendererImpl
37 : public VideoRenderer, 38 : public VideoRenderer,
(...skipping 15 matching lines...) Expand all
53 54
54 // VideoRenderer implementation. 55 // VideoRenderer implementation.
55 void Initialize(DemuxerStream* stream, 56 void Initialize(DemuxerStream* stream,
56 const PipelineStatusCB& init_cb, 57 const PipelineStatusCB& init_cb,
57 const SetDecryptorReadyCB& set_decryptor_ready_cb, 58 const SetDecryptorReadyCB& set_decryptor_ready_cb,
58 const StatisticsCB& statistics_cb, 59 const StatisticsCB& statistics_cb,
59 const BufferingStateCB& buffering_state_cb, 60 const BufferingStateCB& buffering_state_cb,
60 const PaintCB& paint_cb, 61 const PaintCB& paint_cb,
61 const base::Closure& ended_cb, 62 const base::Closure& ended_cb,
62 const PipelineStatusCB& error_cb, 63 const PipelineStatusCB& error_cb,
63 const TimeDeltaCB& get_time_cb, 64 const TimeConverterCB& time_converter_cb,
64 const base::Closure& waiting_for_decryption_key_cb) override; 65 const base::Closure& waiting_for_decryption_key_cb) override;
65 void Flush(const base::Closure& callback) override; 66 void Flush(const base::Closure& callback) override;
66 void StartPlayingFrom(base::TimeDelta timestamp) override; 67 void StartPlayingFrom(base::TimeDelta timestamp) override;
67 68
68 // PlatformThread::Delegate implementation. 69 // PlatformThread::Delegate implementation.
69 void ThreadMain() override; 70 void ThreadMain() override;
70 71
72 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
73
71 private: 74 private:
72 // Creates a dedicated |thread_| for video rendering. 75 // Creates a dedicated |thread_| for video rendering.
73 void CreateVideoThread(); 76 void CreateVideoThread();
74 77
75 // Callback for |video_frame_stream_| initialization. 78 // Callback for |video_frame_stream_| initialization.
76 void OnVideoFrameStreamInitialized(bool success); 79 void OnVideoFrameStreamInitialized(bool success);
77 80
78 // Callback for |video_frame_stream_| to deliver decoded video frames and 81 // Callback for |video_frame_stream_| to deliver decoded video frames and
79 // report video decoding status. 82 // report video decoding status.
80 void FrameReady(VideoFrameStream::Status status, 83 void FrameReady(VideoFrameStream::Status status,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 178
176 // Playback operation callbacks. 179 // Playback operation callbacks.
177 base::Closure flush_cb_; 180 base::Closure flush_cb_;
178 181
179 // Event callbacks. 182 // Event callbacks.
180 PipelineStatusCB init_cb_; 183 PipelineStatusCB init_cb_;
181 StatisticsCB statistics_cb_; 184 StatisticsCB statistics_cb_;
182 BufferingStateCB buffering_state_cb_; 185 BufferingStateCB buffering_state_cb_;
183 base::Closure ended_cb_; 186 base::Closure ended_cb_;
184 PipelineStatusCB error_cb_; 187 PipelineStatusCB error_cb_;
185 TimeDeltaCB get_time_cb_; 188 TimeConverterCB time_converter_cb_;
186 189
187 base::TimeDelta start_timestamp_; 190 base::TimeDelta start_timestamp_;
188 191
189 // Embedder callback for notifying a new frame is available for painting. 192 // Embedder callback for notifying a new frame is available for painting.
190 PaintCB paint_cb_; 193 PaintCB paint_cb_;
191 194
192 // The timestamp of the last frame removed from the |ready_frames_| queue, 195 // The wallclock timestamp of the last frame removed from the |ready_frames_|
193 // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp() 196 // queue, either for calling |paint_cb_| or for dropping. Set to null during
197 // flushing.
198 base::TimeTicks last_timestamp_;
199
200 // The wallclock timestamp of the last successfully painted frame. Set to null
194 // during flushing. 201 // during flushing.
195 base::TimeDelta last_timestamp_; 202 base::TimeTicks last_painted_timestamp_;
196
197 // The timestamp of the last successfully painted frame. Set to kNoTimestamp()
198 // during flushing.
199 base::TimeDelta last_painted_timestamp_;
200 203
201 // Keeps track of the number of frames decoded and dropped since the 204 // Keeps track of the number of frames decoded and dropped since the
202 // last call to |statistics_cb_|. These must be accessed under lock. 205 // last call to |statistics_cb_|. These must be accessed under lock.
203 int frames_decoded_; 206 int frames_decoded_;
204 int frames_dropped_; 207 int frames_dropped_;
205 208
206 bool is_shutting_down_; 209 bool is_shutting_down_;
207 210
211 scoped_ptr<base::TickClock> tick_clock_;
212
208 // NOTE: Weak pointers must be invalidated before all other member variables. 213 // NOTE: Weak pointers must be invalidated before all other member variables.
209 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 214 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
210 215
211 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 216 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
212 }; 217 };
213 218
214 } // namespace media 219 } // namespace media
215 220
216 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 221 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698