Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: media/filters/video_renderer_base.h

Issue 10173012: Fix VideoRendererBase to allow the decoder to be flushed with a pending read. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fixes based on comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/mock_filters.h ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void PutCurrentFrame(scoped_refptr<VideoFrame> frame); 74 void PutCurrentFrame(scoped_refptr<VideoFrame> frame);
75 75
76 private: 76 private:
77 // Callback from the video decoder delivering decoded video frames. 77 // Callback from the video decoder delivering decoded video frames.
78 void FrameReady(scoped_refptr<VideoFrame> frame); 78 void FrameReady(scoped_refptr<VideoFrame> frame);
79 79
80 // Helper method that schedules an asynchronous read from the decoder as long 80 // Helper method that schedules an asynchronous read from the decoder as long
81 // as there isn't a pending read and we have capacity. 81 // as there isn't a pending read and we have capacity.
82 void AttemptRead_Locked(); 82 void AttemptRead_Locked();
83 83
84 // Called when the VideoDecoder Flush() completes.
85 void OnDecoderFlushDone();
86
84 // Attempts to complete flushing and transition into the flushed state. 87 // Attempts to complete flushing and transition into the flushed state.
85 void AttemptFlush_Locked(); 88 void AttemptFlush_Locked();
86 89
87 // Calculates the duration to sleep for based on |current_frame_|'s timestamp, 90 // Calculates the duration to sleep for based on |current_frame_|'s timestamp,
88 // the next frame timestamp (may be NULL), and the provided playback rate. 91 // the next frame timestamp (may be NULL), and the provided playback rate.
89 // 92 //
90 // We don't use |playback_rate_| to avoid locking. 93 // We don't use |playback_rate_| to avoid locking.
91 base::TimeDelta CalculateSleepDuration( 94 base::TimeDelta CalculateSleepDuration(
92 const scoped_refptr<VideoFrame>& next_frame, 95 const scoped_refptr<VideoFrame>& next_frame,
93 float playback_rate); 96 float playback_rate);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 129
127 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: 130 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb:
128 // always check |state_| to see if it was set to STOPPED after waking up! 131 // always check |state_| to see if it was set to STOPPED after waking up!
129 base::ConditionVariable frame_available_; 132 base::ConditionVariable frame_available_;
130 133
131 // State transition Diagram of this class: 134 // State transition Diagram of this class:
132 // [kUninitialized] -------> [kError] 135 // [kUninitialized] -------> [kError]
133 // | 136 // |
134 // | Initialize() 137 // | Initialize()
135 // V All frames returned 138 // V All frames returned
136 // +------[kFlushed]<----------------------[kFlushing] 139 // +------[kFlushed]<-----[kFlushing]<--- OnDecoderFlushDone()
137 // | | Seek() or upon ^ 140 // | | Seek() or upon ^
138 // | V got first frame | 141 // | V got first frame [kFlushingDecoder]
139 // | [kSeeking] | Flush() 142 // | [kSeeking] ^
140 // | | | 143 // | | | Flush()
141 // | V Got enough frames | 144 // | V Got enough frames |
142 // | [kPrerolled]---------------------->[kPaused] 145 // | [kPrerolled]---------------------->[kPaused]
143 // | | Pause() ^ 146 // | | Pause() ^
144 // | V Play() | 147 // | V Play() |
145 // | [kPlaying]---------------------------| 148 // | [kPlaying]---------------------------|
146 // | | Pause() ^ 149 // | | Pause() ^
147 // | V Receive EOF frame. | Pause() 150 // | V Receive EOF frame. | Pause()
148 // | [kEnded]-----------------------------+ 151 // | [kEnded]-----------------------------+
149 // | ^ 152 // | ^
150 // | | 153 // | |
151 // +-----> [kStopped] [Any state other than] 154 // +-----> [kStopped] [Any state other than]
152 // [kUninitialized/kError] 155 // [kUninitialized/kError]
153 156
154 // Simple state tracking variable. 157 // Simple state tracking variable.
155 enum State { 158 enum State {
156 kUninitialized, 159 kUninitialized,
157 kPrerolled, 160 kPrerolled,
158 kPaused, 161 kPaused,
162 kFlushingDecoder,
159 kFlushing, 163 kFlushing,
160 kFlushed, 164 kFlushed,
161 kSeeking, 165 kSeeking,
162 kPlaying, 166 kPlaying,
163 kEnded, 167 kEnded,
164 kStopped, 168 kStopped,
165 kError, 169 kError,
166 }; 170 };
167 State state_; 171 State state_;
168 172
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Callback to execute to inform the player if the video decoder's output is 204 // Callback to execute to inform the player if the video decoder's output is
201 // opaque. 205 // opaque.
202 SetOpaqueCB set_opaque_cb_; 206 SetOpaqueCB set_opaque_cb_;
203 207
204 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); 208 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase);
205 }; 209 };
206 210
207 } // namespace media 211 } // namespace media
208 212
209 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 213 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698