OLD | NEW |
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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const PipelineStatusCB& init_cb, | |
68 CdmContext* cdm_context, | 67 CdmContext* cdm_context, |
69 const StatisticsCB& statistics_cb, | 68 RendererClient* client, |
70 const BufferingStateCB& buffering_state_cb, | |
71 const base::Closure& ended_cb, | |
72 const PipelineStatusCB& error_cb, | |
73 const TimeSource::WallClockTimeCB& wall_clock_time_cb, | 69 const TimeSource::WallClockTimeCB& wall_clock_time_cb, |
74 const base::Closure& waiting_for_decryption_key_cb) override; | 70 const PipelineStatusCB& init_cb) override; |
75 void Flush(const base::Closure& callback) override; | 71 void Flush(const base::Closure& callback) override; |
76 void StartPlayingFrom(base::TimeDelta timestamp) override; | 72 void StartPlayingFrom(base::TimeDelta timestamp) override; |
77 void OnTimeStateChanged(bool time_progressing) override; | 73 void OnTimeStateChanged(bool time_progressing) override; |
78 | 74 |
79 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 75 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
80 void SetGpuMemoryBufferVideoForTesting( | 76 void SetGpuMemoryBufferVideoForTesting( |
81 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool); | 77 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool); |
82 size_t frames_queued_for_testing() const { | 78 size_t frames_queued_for_testing() const { |
83 return algorithm_->frames_queued(); | 79 return algorithm_->frames_queued(); |
84 } | 80 } |
85 | 81 |
86 // VideoRendererSink::RenderCallback implementation. | 82 // VideoRendererSink::RenderCallback implementation. |
87 scoped_refptr<VideoFrame> Render(base::TimeTicks deadline_min, | 83 scoped_refptr<VideoFrame> Render(base::TimeTicks deadline_min, |
88 base::TimeTicks deadline_max, | 84 base::TimeTicks deadline_max, |
89 bool background_rendering) override; | 85 bool background_rendering) override; |
90 void OnFrameDropped() override; | 86 void OnFrameDropped() override; |
91 | 87 |
92 private: | 88 private: |
93 // Callback for |video_frame_stream_| initialization. | 89 // Callback for |video_frame_stream_| initialization. |
94 void OnVideoFrameStreamInitialized(bool success); | 90 void OnVideoFrameStreamInitialized(bool success); |
95 | 91 |
| 92 // Functions to notify certain events to the RendererClient. |
| 93 void OnPlaybackError(PipelineStatus error); |
| 94 void OnPlaybackEnded(); |
| 95 void OnStatisticsUpdate(const PipelineStatistics& stats); |
| 96 void OnBufferingStateChange(BufferingState state); |
| 97 void OnWaitingForDecryptionKey(); |
| 98 |
96 // Callback for |video_frame_stream_| to deliver decoded video frames and | 99 // Callback for |video_frame_stream_| to deliver decoded video frames and |
97 // report video decoding status. If a frame is available the planes will be | 100 // report video decoding status. If a frame is available the planes will be |
98 // copied asynchronously and FrameReady will be called once finished copying. | 101 // copied asynchronously and FrameReady will be called once finished copying. |
99 void FrameReadyForCopyingToGpuMemoryBuffers( | 102 void FrameReadyForCopyingToGpuMemoryBuffers( |
100 VideoFrameStream::Status status, | 103 VideoFrameStream::Status status, |
101 const scoped_refptr<VideoFrame>& frame); | 104 const scoped_refptr<VideoFrame>& frame); |
102 | 105 |
103 // Callback for |video_frame_stream_| to deliver decoded video frames and | 106 // Callback for |video_frame_stream_| to deliver decoded video frames and |
104 // report video decoding status. | 107 // report video decoding status. |
105 void FrameReady(uint32_t sequence_token, | 108 void FrameReady(uint32_t sequence_token, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // not call any methods on the sink while |lock_| is held or the two threads | 183 // not call any methods on the sink while |lock_| is held or the two threads |
181 // might deadlock. Do not call Start() or Stop() on the sink directly, use | 184 // might deadlock. Do not call Start() or Stop() on the sink directly, use |
182 // StartSink() and StopSink() to ensure background rendering is started. Only | 185 // StartSink() and StopSink() to ensure background rendering is started. Only |
183 // access these values on |task_runner_|. | 186 // access these values on |task_runner_|. |
184 VideoRendererSink* const sink_; | 187 VideoRendererSink* const sink_; |
185 bool sink_started_; | 188 bool sink_started_; |
186 | 189 |
187 // Used for accessing data members. | 190 // Used for accessing data members. |
188 base::Lock lock_; | 191 base::Lock lock_; |
189 | 192 |
| 193 RendererClient* client_; |
| 194 |
190 // Provides video frames to VideoRendererImpl. | 195 // Provides video frames to VideoRendererImpl. |
191 std::unique_ptr<VideoFrameStream> video_frame_stream_; | 196 std::unique_ptr<VideoFrameStream> video_frame_stream_; |
192 | 197 |
193 // Pool of GpuMemoryBuffers and resources used to create hardware frames. | 198 // Pool of GpuMemoryBuffers and resources used to create hardware frames. |
194 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; | 199 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; |
195 | 200 |
196 scoped_refptr<MediaLog> media_log_; | 201 scoped_refptr<MediaLog> media_log_; |
197 | 202 |
198 // Flag indicating low-delay mode. | 203 // Flag indicating low-delay mode. |
199 bool low_delay_; | 204 bool low_delay_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 242 |
238 // Keep track of the outstanding read on the VideoFrameStream. Flushing can | 243 // Keep track of the outstanding read on the VideoFrameStream. Flushing can |
239 // only complete once the read has completed. | 244 // only complete once the read has completed. |
240 bool pending_read_; | 245 bool pending_read_; |
241 | 246 |
242 bool drop_frames_; | 247 bool drop_frames_; |
243 | 248 |
244 BufferingState buffering_state_; | 249 BufferingState buffering_state_; |
245 | 250 |
246 // Playback operation callbacks. | 251 // Playback operation callbacks. |
| 252 PipelineStatusCB init_cb_; |
247 base::Closure flush_cb_; | 253 base::Closure flush_cb_; |
248 | |
249 // Event callbacks. | |
250 PipelineStatusCB init_cb_; | |
251 StatisticsCB statistics_cb_; | |
252 BufferingStateCB buffering_state_cb_; | |
253 base::Closure ended_cb_; | |
254 PipelineStatusCB error_cb_; | |
255 TimeSource::WallClockTimeCB wall_clock_time_cb_; | 254 TimeSource::WallClockTimeCB wall_clock_time_cb_; |
256 | 255 |
257 base::TimeDelta start_timestamp_; | 256 base::TimeDelta start_timestamp_; |
258 | 257 |
259 // Keeps track of the number of frames decoded and dropped since the | 258 // Keeps track of the number of frames decoded and dropped since the |
260 // last call to |statistics_cb_|. These must be accessed under lock. | 259 // last call to |statistics_cb_|. These must be accessed under lock. |
261 int frames_decoded_; | 260 int frames_decoded_; |
262 int frames_dropped_; | 261 int frames_dropped_; |
263 | 262 |
264 std::unique_ptr<base::TickClock> tick_clock_; | 263 std::unique_ptr<base::TickClock> tick_clock_; |
(...skipping 23 matching lines...) Expand all Loading... |
288 | 287 |
289 // NOTE: Weak pointers must be invalidated before all other member variables. | 288 // NOTE: Weak pointers must be invalidated before all other member variables. |
290 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; | 289 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; |
291 | 290 |
292 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); | 291 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); |
293 }; | 292 }; |
294 | 293 |
295 } // namespace media | 294 } // namespace media |
296 | 295 |
297 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ | 296 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ |
OLD | NEW |