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

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

Issue 2366373003: Not for submission. fastSeek prototype. (Closed)
Patch Set: Created 4 years, 2 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.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
11 #include <deque>
12 #include <memory> 11 #include <memory>
13 12
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
17 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
18 #include "base/synchronization/condition_variable.h" 17 #include "base/synchronization/condition_variable.h"
19 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
20 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
21 #include "media/base/decryptor.h" 20 #include "media/base/decryptor.h"
22 #include "media/base/demuxer_stream.h" 21 #include "media/base/demuxer_stream.h"
23 #include "media/base/media_log.h" 22 #include "media/base/media_log.h"
24 #include "media/base/pipeline_status.h" 23 #include "media/base/pipeline_status.h"
24 #include "media/base/stream_position.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/gpu_video_accelerator_factories.h" 31 #include "media/renderers/gpu_video_accelerator_factories.h"
32 #include "media/video/gpu_memory_buffer_video_frame_pool.h" 32 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
33 33
34 namespace base { 34 namespace base {
35 class SingleThreadTaskRunner; 35 class SingleThreadTaskRunner;
36 class TickClock; 36 class TickClock;
37 } 37 }
38 38
39 namespace media { 39 namespace media {
40 40
41 // VideoRendererImpl handles reading from a VideoFrameStream storing the 41 // VideoRendererImpl handles reading from a VideoFrameStream, storing the
42 // results in a queue of decoded frames and executing a callback when a frame is 42 // results in a queue of decoded frames, and selecting the best one for display
43 // ready for rendering. 43 // in response to Render() calls.
44 class MEDIA_EXPORT VideoRendererImpl 44 class MEDIA_EXPORT VideoRendererImpl
45 : public VideoRenderer, 45 : public VideoRenderer,
46 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback) { 46 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback) {
47 public: 47 public:
48 // |decoders| contains the VideoDecoders to use when initializing. 48 // |decoders| contains the VideoDecoders to use when initializing.
49 // 49 //
50 // Implementors should avoid doing any sort of heavy work in this method and 50 // 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 51 // 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. 52 // down the video thread may result in losing synchronization with audio.
53 // 53 //
54 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 54 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
55 VideoRendererImpl( 55 VideoRendererImpl(
56 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 56 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
57 const scoped_refptr<base::TaskRunner>& worker_task_runner, 57 const scoped_refptr<base::TaskRunner>& worker_task_runner,
58 VideoRendererSink* sink, 58 VideoRendererSink* sink,
59 ScopedVector<VideoDecoder> decoders, 59 ScopedVector<VideoDecoder> decoders,
60 bool drop_frames, 60 bool drop_frames,
61 GpuVideoAcceleratorFactories* gpu_factories, 61 GpuVideoAcceleratorFactories* gpu_factories,
62 const scoped_refptr<MediaLog>& media_log); 62 const scoped_refptr<MediaLog>& media_log);
63 ~VideoRendererImpl() override; 63 ~VideoRendererImpl() override;
64 64
65 // VideoRenderer implementation. 65 // VideoRenderer implementation.
66 void Initialize(DemuxerStream* stream, 66 void Initialize(DemuxerStream* stream,
67 CdmContext* cdm_context, 67 CdmContext* cdm_context,
68 RendererClient* client, 68 RendererClient* client,
69 const TimeSource::WallClockTimeCB& wall_clock_time_cb, 69 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
70 const PipelineStatusCB& init_cb) override; 70 const PipelineStatusCB& init_cb) override;
71 void Flush(const base::Closure& callback) override; 71 void Flush(const base::Closure& callback) override;
72 void StartPlayingFrom(base::TimeDelta timestamp) override; 72 void StartPlayingFrom(StreamPosition position) override;
73 void OnTimeStateChanged(bool time_progressing) override; 73 void OnTimeStateChanged(bool time_progressing) override;
74 74
75 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 75 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
76 void SetGpuMemoryBufferVideoForTesting( 76 void SetGpuMemoryBufferVideoForTesting(
77 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool); 77 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool);
78 size_t frames_queued_for_testing() const { 78 size_t frames_queued_for_testing() const {
79 return algorithm_->frames_queued(); 79 return algorithm_->frames_queued();
80 } 80 }
81 81
82 // VideoRendererSink::RenderCallback implementation. 82 // VideoRendererSink::RenderCallback implementation.
(...skipping 18 matching lines...) Expand all
101 // copied asynchronously and FrameReady will be called once finished copying. 101 // copied asynchronously and FrameReady will be called once finished copying.
102 void FrameReadyForCopyingToGpuMemoryBuffers( 102 void FrameReadyForCopyingToGpuMemoryBuffers(
103 VideoFrameStream::Status status, 103 VideoFrameStream::Status status,
104 const scoped_refptr<VideoFrame>& frame); 104 const scoped_refptr<VideoFrame>& frame);
105 105
106 // Callback for |video_frame_stream_| to deliver decoded video frames and 106 // Callback for |video_frame_stream_| to deliver decoded video frames and
107 // report video decoding status. 107 // report video decoding status.
108 void FrameReady(VideoFrameStream::Status status, 108 void FrameReady(VideoFrameStream::Status status,
109 const scoped_refptr<VideoFrame>& frame); 109 const scoped_refptr<VideoFrame>& frame);
110 110
111 // Helper method for enqueueing a frame to |alogorithm_|. 111 // Helper method for enqueueing a frame to |algorithm_|.
112 void AddReadyFrame_Locked(const scoped_refptr<VideoFrame>& frame); 112 void AddReadyFrame_Locked(const scoped_refptr<VideoFrame>& frame);
113 113
114 // Helper method that schedules an asynchronous read from the 114 // Helper method that schedules an asynchronous read from the
115 // |video_frame_stream_| as long as there isn't a pending read and we have 115 // |video_frame_stream_| as long as there isn't a pending read and we have
116 // capacity. 116 // capacity.
117 void AttemptRead_Locked(); 117 void AttemptRead_Locked();
118 118
119 // Called when VideoFrameStream::Reset() completes. 119 // Called when VideoFrameStream::Reset() completes.
120 void OnVideoFrameStreamResetDone(); 120 void OnVideoFrameStreamResetDone();
121 121
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 bool drop_frames_; 246 bool drop_frames_;
247 247
248 BufferingState buffering_state_; 248 BufferingState buffering_state_;
249 249
250 // Playback operation callbacks. 250 // Playback operation callbacks.
251 PipelineStatusCB init_cb_; 251 PipelineStatusCB init_cb_;
252 base::Closure flush_cb_; 252 base::Closure flush_cb_;
253 TimeSource::WallClockTimeCB wall_clock_time_cb_; 253 TimeSource::WallClockTimeCB wall_clock_time_cb_;
254 254
255 bool start_rendering_from_first_frame_;
256
255 base::TimeDelta start_timestamp_; 257 base::TimeDelta start_timestamp_;
256 258
257 // Keeps track of the number of frames decoded and dropped since the 259 // Keeps track of the number of frames decoded and dropped since the
258 // last call to |statistics_cb_|. These must be accessed under lock. 260 // last call to |statistics_cb_|. These must be accessed under lock.
259 int frames_decoded_; 261 int frames_decoded_;
260 int frames_dropped_; 262 int frames_dropped_;
261 263
262 std::unique_ptr<base::TickClock> tick_clock_; 264 std::unique_ptr<base::TickClock> tick_clock_;
263 265
264 // Algorithm for selecting which frame to render; manages frames and all 266 // Algorithm for selecting which frame to render; manages frames and all
(...skipping 28 matching lines...) Expand all
293 // want to discard video frames that might be received after the stream has 295 // want to discard video frames that might be received after the stream has
294 // been reset. 296 // been reset.
295 base::WeakPtrFactory<VideoRendererImpl> frame_callback_weak_factory_; 297 base::WeakPtrFactory<VideoRendererImpl> frame_callback_weak_factory_;
296 298
297 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 299 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
298 }; 300 };
299 301
300 } // namespace media 302 } // namespace media
301 303
302 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 304 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | media/renderers/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698