Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(RendererClient* client, |
| 67 const PipelineStatusCB& init_cb, | 67 DemuxerStream* stream, |
| 68 CdmContext* cdm_context, | 68 CdmContext* cdm_context, |
| 69 const StatisticsCB& statistics_cb, | |
| 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); |
|
xhwang
2016/05/09 18:13:23
empty line here
alokp
2016/05/09 21:31:44
Done.
| |
| 91 // Functions to notify certain events to the RendererClient. | |
| 92 void OnPlaybackEnded(); | |
| 93 void OnStatisticsUpdate(const PipelineStatistics& stats); | |
| 94 void OnWaitingForDecryptionKey(); | |
| 95 | 95 |
| 96 // Callback for |video_frame_stream_| to deliver decoded video frames and | 96 // 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 | 97 // report video decoding status. If a frame is available the planes will be |
| 98 // copied asynchronously and FrameReady will be called once finished copying. | 98 // copied asynchronously and FrameReady will be called once finished copying. |
| 99 void FrameReadyForCopyingToGpuMemoryBuffers( | 99 void FrameReadyForCopyingToGpuMemoryBuffers( |
| 100 VideoFrameStream::Status status, | 100 VideoFrameStream::Status status, |
| 101 const scoped_refptr<VideoFrame>& frame); | 101 const scoped_refptr<VideoFrame>& frame); |
| 102 | 102 |
| 103 // Callback for |video_frame_stream_| to deliver decoded video frames and | 103 // Callback for |video_frame_stream_| to deliver decoded video frames and |
| 104 // report video decoding status. | 104 // report video decoding status. |
| (...skipping 75 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 | 180 // 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 | 181 // might deadlock. Do not call Start() or Stop() on the sink directly, use |
| 182 // StartSink() and StopSink() to ensure background rendering is started. Only | 182 // StartSink() and StopSink() to ensure background rendering is started. Only |
| 183 // access these values on |task_runner_|. | 183 // access these values on |task_runner_|. |
| 184 VideoRendererSink* const sink_; | 184 VideoRendererSink* const sink_; |
| 185 bool sink_started_; | 185 bool sink_started_; |
| 186 | 186 |
| 187 // Used for accessing data members. | 187 // Used for accessing data members. |
| 188 base::Lock lock_; | 188 base::Lock lock_; |
| 189 | 189 |
| 190 RendererClient* client_; | |
| 191 | |
| 190 // Provides video frames to VideoRendererImpl. | 192 // Provides video frames to VideoRendererImpl. |
| 191 std::unique_ptr<VideoFrameStream> video_frame_stream_; | 193 std::unique_ptr<VideoFrameStream> video_frame_stream_; |
| 192 | 194 |
| 193 // Pool of GpuMemoryBuffers and resources used to create hardware frames. | 195 // Pool of GpuMemoryBuffers and resources used to create hardware frames. |
| 194 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; | 196 std::unique_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; |
| 195 | 197 |
| 196 scoped_refptr<MediaLog> media_log_; | 198 scoped_refptr<MediaLog> media_log_; |
| 197 | 199 |
| 198 // Flag indicating low-delay mode. | 200 // Flag indicating low-delay mode. |
| 199 bool low_delay_; | 201 bool low_delay_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 | 239 |
| 238 // Keep track of the outstanding read on the VideoFrameStream. Flushing can | 240 // Keep track of the outstanding read on the VideoFrameStream. Flushing can |
| 239 // only complete once the read has completed. | 241 // only complete once the read has completed. |
| 240 bool pending_read_; | 242 bool pending_read_; |
| 241 | 243 |
| 242 bool drop_frames_; | 244 bool drop_frames_; |
| 243 | 245 |
| 244 BufferingState buffering_state_; | 246 BufferingState buffering_state_; |
| 245 | 247 |
| 246 // Playback operation callbacks. | 248 // Playback operation callbacks. |
| 249 PipelineStatusCB init_cb_; | |
| 247 base::Closure flush_cb_; | 250 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_; | 251 TimeSource::WallClockTimeCB wall_clock_time_cb_; |
| 256 | 252 |
| 257 base::TimeDelta start_timestamp_; | 253 base::TimeDelta start_timestamp_; |
| 258 | 254 |
| 259 // Keeps track of the number of frames decoded and dropped since the | 255 // Keeps track of the number of frames decoded and dropped since the |
| 260 // last call to |statistics_cb_|. These must be accessed under lock. | 256 // last call to |statistics_cb_|. These must be accessed under lock. |
| 261 int frames_decoded_; | 257 int frames_decoded_; |
| 262 int frames_dropped_; | 258 int frames_dropped_; |
| 263 | 259 |
| 264 std::unique_ptr<base::TickClock> tick_clock_; | 260 std::unique_ptr<base::TickClock> tick_clock_; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 288 | 284 |
| 289 // NOTE: Weak pointers must be invalidated before all other member variables. | 285 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 290 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; | 286 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; |
| 291 | 287 |
| 292 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); | 288 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); |
| 293 }; | 289 }; |
| 294 | 290 |
| 295 } // namespace media | 291 } // namespace media |
| 296 | 292 |
| 297 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ | 293 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ |
| OLD | NEW |