OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // VideoRendererBase creates its own thread for the sole purpose of timing frame | 5 // VideoRendererBase creates its own thread for the sole purpose of timing frame |
6 // presentation. It handles reading from the decoder and stores the results in | 6 // presentation. It handles reading from the decoder and stores the results in |
7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify | 7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify |
8 // when a frame is ready to display. | 8 // when a frame is ready to display. |
9 // | 9 // |
10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek() | 10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 StatisticsCallback* stats_callback); | 50 StatisticsCallback* stats_callback); |
51 virtual bool HasEnded(); | 51 virtual bool HasEnded(); |
52 | 52 |
53 // PlatformThread::Delegate implementation. | 53 // PlatformThread::Delegate implementation. |
54 virtual void ThreadMain(); | 54 virtual void ThreadMain(); |
55 | 55 |
56 // Clients of this class (painter/compositor) should use GetCurrentFrame() | 56 // Clients of this class (painter/compositor) should use GetCurrentFrame() |
57 // obtain ownership of VideoFrame, it should always relinquish the ownership | 57 // obtain ownership of VideoFrame, it should always relinquish the ownership |
58 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL. | 58 // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL. |
59 // It expects clients to use color-fill the background if current frame | 59 // It expects clients to use color-fill the background if current frame |
60 // is NULL. This could happen when before pipeline is pre-rolled or during | 60 // is NULL. This could happen before pipeline is pre-rolled or during |
61 // pause/flush/seek. | 61 // pause/flush/seek. |
62 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out); | 62 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out); |
63 void PutCurrentFrame(scoped_refptr<VideoFrame> frame); | 63 void PutCurrentFrame(scoped_refptr<VideoFrame> frame); |
64 | 64 |
65 protected: | 65 protected: |
66 // Subclass interface. Called before any other initialization in the base | 66 // Subclass interface. Called before any other initialization in the base |
67 // class takes place. | 67 // class takes place. |
68 // | 68 // |
69 // Implementors typically use the media format of |decoder| to create their | 69 // Implementors typically use the media format of |decoder| to create their |
70 // output surfaces. | 70 // output surfaces. |
(...skipping 24 matching lines...) Expand all Loading... |
95 // |pending_reads_|. | 95 // |pending_reads_|. |
96 void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame); | 96 void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame); |
97 | 97 |
98 // Helper method that schedules an asynchronous read from the decoder and | 98 // Helper method that schedules an asynchronous read from the decoder and |
99 // increments |pending_reads_|. | 99 // increments |pending_reads_|. |
100 // | 100 // |
101 // Safe to call from any thread. | 101 // Safe to call from any thread. |
102 void ScheduleRead_Locked(); | 102 void ScheduleRead_Locked(); |
103 | 103 |
104 // Helper function to finished "flush" operation | 104 // Helper function to finished "flush" operation |
105 void OnFlushDone(); | 105 void OnFlushDone_Locked(); |
106 | 106 |
107 // Helper method that flushes all video frame in "ready queue" including | 107 // Helper method that flushes all video frame in "ready queue" including |
108 // current frame into "done queue". | 108 // current frame into "done queue". |
109 void FlushBuffers(); | 109 void FlushBuffers_Locked(); |
110 | 110 |
111 // Calculates the duration to sleep for based on |current_frame_|'s timestamp, | 111 // Calculates the duration to sleep for based on |current_frame_|'s timestamp, |
112 // the next frame timestamp (may be NULL), and the provided playback rate. | 112 // the next frame timestamp (may be NULL), and the provided playback rate. |
113 // | 113 // |
114 // We don't use |playback_rate_| to avoid locking. | 114 // We don't use |playback_rate_| to avoid locking. |
115 base::TimeDelta CalculateSleepDuration(VideoFrame* next_frame, | 115 base::TimeDelta CalculateSleepDuration(VideoFrame* next_frame, |
116 float playback_rate); | 116 float playback_rate); |
117 | 117 |
118 // Safely handles entering to an error state. | 118 // Safely handles entering to an error state. |
119 void EnterErrorState_Locked(PipelineStatus status); | 119 void EnterErrorState_Locked(PipelineStatus status); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 scoped_ptr<StatisticsCallback> statistics_callback_; | 199 scoped_ptr<StatisticsCallback> statistics_callback_; |
200 | 200 |
201 base::TimeDelta seek_timestamp_; | 201 base::TimeDelta seek_timestamp_; |
202 | 202 |
203 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 203 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
204 }; | 204 }; |
205 | 205 |
206 } // namespace media | 206 } // namespace media |
207 | 207 |
208 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 208 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
OLD | NEW |