OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 28 matching lines...) Expand all Loading... |
39 // be NULL where the result is not needed. | 39 // be NULL where the result is not needed. |
40 static bool ParseMediaFormat( | 40 static bool ParseMediaFormat( |
41 const MediaFormat& media_format, | 41 const MediaFormat& media_format, |
42 VideoFrame::SurfaceType* surface_type_out, | 42 VideoFrame::SurfaceType* surface_type_out, |
43 VideoFrame::Format* surface_format_out, | 43 VideoFrame::Format* surface_format_out, |
44 int* width_out, int* height_out); | 44 int* width_out, int* height_out); |
45 | 45 |
46 // MediaFilter implementation. | 46 // MediaFilter implementation. |
47 virtual void Play(FilterCallback* callback); | 47 virtual void Play(FilterCallback* callback); |
48 virtual void Pause(FilterCallback* callback); | 48 virtual void Pause(FilterCallback* callback); |
| 49 virtual void Flush(FilterCallback* callback); |
49 virtual void Stop(FilterCallback* callback); | 50 virtual void Stop(FilterCallback* callback); |
50 virtual void SetPlaybackRate(float playback_rate); | 51 virtual void SetPlaybackRate(float playback_rate); |
51 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | 52 virtual void Seek(base::TimeDelta time, FilterCallback* callback); |
52 | 53 |
53 // VideoRenderer implementation. | 54 // VideoRenderer implementation. |
54 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback); | 55 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback); |
55 virtual bool HasEnded(); | 56 virtual bool HasEnded(); |
56 | 57 |
57 // PlatformThread::Delegate implementation. | 58 // PlatformThread::Delegate implementation. |
58 virtual void ThreadMain(); | 59 virtual void ThreadMain(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 scoped_refptr<VideoFrame> current_frame_; | 147 scoped_refptr<VideoFrame> current_frame_; |
147 | 148 |
148 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: | 149 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: |
149 // always check |state_| to see if it was set to STOPPED after waking up! | 150 // always check |state_| to see if it was set to STOPPED after waking up! |
150 ConditionVariable frame_available_; | 151 ConditionVariable frame_available_; |
151 | 152 |
152 // Simple state tracking variable. | 153 // Simple state tracking variable. |
153 enum State { | 154 enum State { |
154 kUninitialized, | 155 kUninitialized, |
155 kPaused, | 156 kPaused, |
| 157 kFlushing, |
156 kSeeking, | 158 kSeeking, |
157 kPlaying, | 159 kPlaying, |
158 kEnded, | 160 kEnded, |
159 kStopped, | 161 kStopped, |
160 kError, | 162 kError, |
161 }; | 163 }; |
162 State state_; | 164 State state_; |
163 | 165 |
164 // Video thread handle. | 166 // Video thread handle. |
165 PlatformThreadHandle thread_; | 167 PlatformThreadHandle thread_; |
166 | 168 |
167 // Previous time returned from the pipeline. | 169 // Previous time returned from the pipeline. |
168 base::TimeDelta previous_time_; | 170 base::TimeDelta previous_time_; |
169 | 171 |
170 // Keeps track of our pending reads. We *must* have no pending reads before | 172 // Keeps track of our pending reads. We *must* have no pending reads before |
171 // executing the pause callback, otherwise we breach the contract that all | 173 // executing the pause callback, otherwise we breach the contract that all |
172 // filters are idling. | 174 // filters are idling. |
173 // | 175 // |
174 // We use size_t since we compare against std::deque::size(). | 176 // We use size_t since we compare against std::deque::size(). |
175 size_t pending_reads_; | 177 size_t pending_reads_; |
176 bool pending_paint_; | 178 bool pending_paint_; |
177 | 179 |
178 float playback_rate_; | 180 float playback_rate_; |
179 | 181 |
180 // Filter callbacks. | 182 // Filter callbacks. |
181 scoped_ptr<FilterCallback> pause_callback_; | 183 scoped_ptr<FilterCallback> flush_callback_; |
182 scoped_ptr<FilterCallback> seek_callback_; | 184 scoped_ptr<FilterCallback> seek_callback_; |
183 | 185 |
184 base::TimeDelta seek_timestamp_; | 186 base::TimeDelta seek_timestamp_; |
185 | 187 |
186 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 188 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
187 }; | 189 }; |
188 | 190 |
189 } // namespace media | 191 } // namespace media |
190 | 192 |
191 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 193 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
OLD | NEW |