Index: media/filters/video_renderer_base.h |
diff --git a/media/filters/video_renderer_base.h b/media/filters/video_renderer_base.h |
index 1aa42d221dd6f61d77dcf245db6e289565d7f5d4..b41c51e294ed98d41d6a5305fb32db89cc32746a 100644 |
--- a/media/filters/video_renderer_base.h |
+++ b/media/filters/video_renderer_base.h |
@@ -107,6 +107,8 @@ class VideoRendererBase : public VideoRenderer, |
return surface_type_ == media::VideoFrame::TYPE_EGL_IMAGE; |
} |
+ void ReadInput(scoped_refptr<VideoFrame> frame); |
+ |
private: |
// Callback from video decoder to deliver decoded video frames and decrements |
// |pending_reads_|. |
@@ -118,6 +120,9 @@ class VideoRendererBase : public VideoRenderer, |
// Safe to call from any thread. |
void ScheduleRead_Locked(); |
+ // Helper function to finished "flush" operation |
+ void OnFlushDone(); |
+ |
// Helper method that flushes all video frame in "ready queue" including |
// current frame into "done queue". |
void FlushBuffers(); |
@@ -150,11 +155,36 @@ class VideoRendererBase : public VideoRenderer, |
// always check |state_| to see if it was set to STOPPED after waking up! |
ConditionVariable frame_available_; |
+ // State transition Diagram of this class: |
+ // [kUninitialized] -------> [kError] |
+ // | |
+ // | Initialize() |
+ // V All frames returned |
+ // +------[kFlushed]<----------------------[kFlushing] |
+ // | | Seek() or upon ^ |
+ // | V got first frame | |
+ // | [kSeeking] | Flush() |
+ // | | | |
+ // | V Got enough frames | |
+ // | [kPrerolled]---------------------->[kPaused] |
+ // | | Pause() ^ |
+ // | V Play() | |
+ // | [kPlaying]---------------------------| |
+ // | | Pause() ^ |
+ // | V Receive EOF frame. | Pause() |
+ // | [kEnded]-----------------------------+ |
+ // | ^ |
+ // | | |
+ // +-----> [kStopped] [Any state other than] |
+ // [kUninitialized/kError] |
+ |
// Simple state tracking variable. |
enum State { |
kUninitialized, |
+ kPrerolled, |
kPaused, |
kFlushing, |
+ kFlushed, |
kSeeking, |
kPlaying, |
kEnded, |
@@ -169,12 +199,12 @@ class VideoRendererBase : public VideoRenderer, |
// Previous time returned from the pipeline. |
base::TimeDelta previous_time_; |
- // Keeps track of our pending reads. We *must* have no pending reads before |
- // executing the pause callback, otherwise we breach the contract that all |
- // filters are idling. |
- // |
- // We use size_t since we compare against std::deque::size(). |
- size_t pending_reads_; |
+ // Keeps track of our pending buffers. We *must* have no pending reads |
+ // before executing the flush callback; We decrement it each time we receive |
+ // a buffer and increment it each time we send a buffer out. therefore if |
+ // decoder provides buffer, |pending_reads_| is always non-positive and if |
+ // renderer provides buffer, |pending_reads_| is always non-negative. |
+ int pending_reads_; |
bool pending_paint_; |
float playback_rate_; |