| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FILTERS_VIDEO_RENDERER_BASE_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
| 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // down the video thread may result in losing synchronization with audio. | 39 // down the video thread may result in losing synchronization with audio. |
| 40 // | 40 // |
| 41 // Setting |drop_frames_| to true causes the renderer to drop expired frames. | 41 // Setting |drop_frames_| to true causes the renderer to drop expired frames. |
| 42 // | 42 // |
| 43 // TODO(scherkus): pass the VideoFrame* to this callback and remove | 43 // TODO(scherkus): pass the VideoFrame* to this callback and remove |
| 44 // Get/PutCurrentFrame() http://crbug.com/108435 | 44 // Get/PutCurrentFrame() http://crbug.com/108435 |
| 45 VideoRendererBase(const base::Closure& paint_cb, | 45 VideoRendererBase(const base::Closure& paint_cb, |
| 46 const SetOpaqueCB& set_opaque_cb, | 46 const SetOpaqueCB& set_opaque_cb, |
| 47 bool drop_frames); | 47 bool drop_frames); |
| 48 | 48 |
| 49 // Filter implementation. | 49 // VideoRenderer implementation. |
| 50 virtual void SetHost(FilterHost* host) OVERRIDE; | 50 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, |
| 51 const PipelineStatusCB& init_cb, |
| 52 const StatisticsCB& statistics_cb, |
| 53 const TimeCB& time_cb, |
| 54 const NaturalSizeChangedCB& size_changed_cb, |
| 55 const base::Closure& ended_cb, |
| 56 const PipelineStatusCB& error_cb, |
| 57 const TimeDeltaCB& get_time_cb, |
| 58 const TimeDeltaCB& get_duration_cb) OVERRIDE; |
| 51 virtual void Play(const base::Closure& callback) OVERRIDE; | 59 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 52 virtual void Pause(const base::Closure& callback) OVERRIDE; | 60 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 53 virtual void Flush(const base::Closure& callback) OVERRIDE; | 61 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 62 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 54 virtual void Stop(const base::Closure& callback) OVERRIDE; | 63 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 55 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 64 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
| 56 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | |
| 57 | |
| 58 // VideoRenderer implementation. | |
| 59 virtual void Initialize(const scoped_refptr<VideoDecoder>& decoder, | |
| 60 const PipelineStatusCB& status_cb, | |
| 61 const StatisticsCB& statistics_cb, | |
| 62 const TimeCB& time_cb) OVERRIDE; | |
| 63 virtual bool HasEnded() OVERRIDE; | 65 virtual bool HasEnded() OVERRIDE; |
| 64 | 66 |
| 65 // PlatformThread::Delegate implementation. | 67 // PlatformThread::Delegate implementation. |
| 66 virtual void ThreadMain() OVERRIDE; | 68 virtual void ThreadMain() OVERRIDE; |
| 67 | 69 |
| 68 // Clients of this class (painter/compositor) should use GetCurrentFrame() | 70 // Clients of this class (painter/compositor) should use GetCurrentFrame() |
| 69 // obtain ownership of VideoFrame, it should always relinquish the ownership | 71 // obtain ownership of VideoFrame, it should always relinquish the ownership |
| 70 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL. | 72 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL. |
| 71 // It expects clients to use color-fill the background if current frame | 73 // It expects clients to use color-fill the background if current frame |
| 72 // is NULL. This could happen before pipeline is pre-rolled or during | 74 // is NULL. This could happen before pipeline is pre-rolled or during |
| (...skipping 30 matching lines...) Expand all Loading... |
| 103 | 105 |
| 104 // Safely handles entering to an error state. | 106 // Safely handles entering to an error state. |
| 105 void EnterErrorState_Locked(PipelineStatus status); | 107 void EnterErrorState_Locked(PipelineStatus status); |
| 106 | 108 |
| 107 // Helper function that flushes the buffers when a Stop() or error occurs. | 109 // Helper function that flushes the buffers when a Stop() or error occurs. |
| 108 void DoStopOrError_Locked(); | 110 void DoStopOrError_Locked(); |
| 109 | 111 |
| 110 // Return the number of frames currently held by this class. | 112 // Return the number of frames currently held by this class. |
| 111 int NumFrames_Locked() const; | 113 int NumFrames_Locked() const; |
| 112 | 114 |
| 113 FilterHost* host_; | |
| 114 | |
| 115 // Used for accessing data members. | 115 // Used for accessing data members. |
| 116 base::Lock lock_; | 116 base::Lock lock_; |
| 117 | 117 |
| 118 scoped_refptr<VideoDecoder> decoder_; | 118 scoped_refptr<VideoDecoder> decoder_; |
| 119 | 119 |
| 120 // Queue of incoming frames as well as the current frame since the last time | 120 // Queue of incoming frames as well as the current frame since the last time |
| 121 // OnFrameAvailable() was called. | 121 // OnFrameAvailable() was called. |
| 122 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; | 122 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; |
| 123 VideoFrameQueue ready_frames_; | 123 VideoFrameQueue ready_frames_; |
| 124 | 124 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // Flushing cannot complete until both |pending_read_| and |pending_paint_| | 191 // Flushing cannot complete until both |pending_read_| and |pending_paint_| |
| 192 // are false. | 192 // are false. |
| 193 bool pending_read_; | 193 bool pending_read_; |
| 194 bool pending_paint_; | 194 bool pending_paint_; |
| 195 bool pending_paint_with_last_available_; | 195 bool pending_paint_with_last_available_; |
| 196 | 196 |
| 197 bool drop_frames_; | 197 bool drop_frames_; |
| 198 | 198 |
| 199 float playback_rate_; | 199 float playback_rate_; |
| 200 | 200 |
| 201 // Filter callbacks. | 201 // Playback operation callbacks. |
| 202 base::Closure flush_cb_; | 202 base::Closure flush_cb_; |
| 203 PipelineStatusCB seek_cb_; | 203 PipelineStatusCB seek_cb_; |
| 204 |
| 205 // Event callbacks. |
| 204 StatisticsCB statistics_cb_; | 206 StatisticsCB statistics_cb_; |
| 205 TimeCB time_cb_; | 207 TimeCB time_cb_; |
| 208 NaturalSizeChangedCB size_changed_cb_; |
| 209 base::Closure ended_cb_; |
| 210 PipelineStatusCB error_cb_; |
| 211 TimeDeltaCB get_time_cb_; |
| 212 TimeDeltaCB get_duration_cb_; |
| 206 | 213 |
| 207 base::TimeDelta seek_timestamp_; | 214 base::TimeDelta seek_timestamp_; |
| 208 | 215 |
| 209 // Embedder callback for notifying a new frame is available for painting. | 216 // Embedder callback for notifying a new frame is available for painting. |
| 210 base::Closure paint_cb_; | 217 base::Closure paint_cb_; |
| 211 | 218 |
| 212 // Callback to execute to inform the player if the video decoder's output is | 219 // Callback to execute to inform the player if the video decoder's output is |
| 213 // opaque. | 220 // opaque. |
| 214 SetOpaqueCB set_opaque_cb_; | 221 SetOpaqueCB set_opaque_cb_; |
| 215 | 222 |
| 216 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 223 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
| 217 }; | 224 }; |
| 218 | 225 |
| 219 } // namespace media | 226 } // namespace media |
| 220 | 227 |
| 221 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 228 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
| OLD | NEW |