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

Unified Diff: media/filters/video_renderer_base.h

Issue 12262058: Revert r180578, r180591, and r180604 from 1410 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/pipeline_integration_test_base.cc ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_base.h
===================================================================
--- media/filters/video_renderer_base.h (revision 182591)
+++ media/filters/video_renderer_base.h (working copy)
@@ -8,7 +8,6 @@
#include <deque>
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
@@ -36,14 +35,13 @@
: public VideoRenderer,
public base::PlatformThread::Delegate {
public:
- typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB;
typedef base::Callback<void(bool)> SetOpaqueCB;
// Maximum duration of the last frame.
static base::TimeDelta kMaxLastFrameDuration();
// |paint_cb| is executed on the video frame timing thread whenever a new
- // frame is available for painting.
+ // frame is available for painting via GetCurrentFrame().
//
// |set_opaque_cb| is executed when the renderer is initialized to inform
// the player whether the decoder's output will be opaque or not.
@@ -58,10 +56,9 @@
// Get/PutCurrentFrame() http://crbug.com/108435
VideoRendererBase(const scoped_refptr<base::MessageLoopProxy>& message_loop,
const SetDecryptorReadyCB& set_decryptor_ready_cb,
- const PaintCB& paint_cb,
+ const base::Closure& paint_cb,
const SetOpaqueCB& set_opaque_cb,
bool drop_frames);
- virtual ~VideoRendererBase();
// VideoRenderer implementation.
virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
@@ -85,6 +82,18 @@
// PlatformThread::Delegate implementation.
virtual void ThreadMain() OVERRIDE;
+ // Clients of this class (painter/compositor) should use GetCurrentFrame()
+ // obtain ownership of VideoFrame, it should always relinquish the ownership
+ // by use PutCurrentFrame(). Current frame is not guaranteed to be non-NULL.
+ // It expects clients to use color-fill the background if current frame
+ // is NULL. This could happen before pipeline is pre-rolled or during
+ // pause/flush/preroll.
+ void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out);
+ void PutCurrentFrame(scoped_refptr<VideoFrame> frame);
+
+ protected:
+ virtual ~VideoRendererBase();
+
private:
// Called when |decoder_selector_| selected the |selected_decoder|.
// |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
@@ -115,7 +124,7 @@
// Attempts to complete flushing and transition into the flushed state.
void AttemptFlush_Locked();
- // Calculates the duration to sleep for based on |last_timestamp_|,
+ // Calculates the duration to sleep for based on |current_frame_|'s timestamp,
// the next frame timestamp (may be NULL), and the provided playback rate.
//
// We don't use |playback_rate_| to avoid locking.
@@ -129,18 +138,10 @@
// Return the number of frames currently held by this class.
int NumFrames_Locked() const;
- // Runs |paint_cb_| with the next frame from |ready_frames_|, updating
- // |last_natural_size_| and running |size_changed_cb_| if the natural size
- // changes.
- //
- // A read is scheduled to replace the frame.
- void PaintNextReadyFrame_Locked();
+ // Updates |current_frame_| to the next frame on |ready_frames_| and calls
+ // |size_changed_cb_| if the natural size changes.
+ void SetCurrentFrameToNextReadyFrame();
- // Drops the next frame from |ready_frames_| and runs |statistics_cb_|.
- //
- // A read is scheduled to replace the frame.
- void DropNextReadyFrame_Locked();
-
void ResetDecoder();
void StopDecoder(const base::Closure& callback);
@@ -157,8 +158,6 @@
PipelineStatus status);
scoped_refptr<base::MessageLoopProxy> message_loop_;
- base::WeakPtrFactory<VideoRendererBase> weak_factory_;
- base::WeakPtr<VideoRendererBase> weak_this_;
// Used for accessing data members.
base::Lock lock_;
@@ -169,10 +168,24 @@
scoped_refptr<VideoDecoder> decoder_;
scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
- // Queue of incoming frames yet to be painted.
+ // Queue of incoming frames as well as the current frame since the last time
+ // OnFrameAvailable() was called.
typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue;
VideoFrameQueue ready_frames_;
+ // The current frame available to subclasses for rendering via
+ // GetCurrentFrame(). |current_frame_| can only be altered when
+ // |pending_paint_| is false.
+ scoped_refptr<VideoFrame> current_frame_;
+
+ // The previous |current_frame_| and is returned via GetCurrentFrame() in the
+ // situation where all frames were deallocated (i.e., during a flush).
+ //
+ // TODO(scherkus): remove this after getting rid of Get/PutCurrentFrame() in
+ // favour of passing ownership of the current frame to the renderer via
+ // callback.
+ scoped_refptr<VideoFrame> last_available_frame_;
+
// Used to signal |thread_| as frames are added to |frames_|. Rule of thumb:
// always check |state_| to see if it was set to STOPPED after waking up!
base::ConditionVariable frame_available_;
@@ -219,9 +232,18 @@
// Video thread handle.
base::PlatformThreadHandle thread_;
- // Keep track of outstanding reads on the video decoder. Flushing can only
- // complete once reads have completed.
+ // Keep track of various pending operations:
+ // - |pending_read_| is true when there's an active video decoding request.
+ // - |pending_paint_| is true when |current_frame_| is currently being
+ // accessed by the subclass.
+ // - |pending_paint_with_last_available_| is true when
+ // |last_available_frame_| is currently being accessed by the subclass.
+ //
+ // Flushing cannot complete until both |pending_read_| and |pending_paint_|
+ // are false.
bool pending_read_;
+ bool pending_paint_;
+ bool pending_paint_with_last_available_;
bool drop_frames_;
@@ -248,24 +270,15 @@
scoped_refptr<VideoFrame> prerolling_delayed_frame_;
// Embedder callback for notifying a new frame is available for painting.
- PaintCB paint_cb_;
+ base::Closure paint_cb_;
// Callback to execute to inform the player if the video decoder's output is
// opaque.
SetOpaqueCB set_opaque_cb_;
// The last natural size |size_changed_cb_| was called with.
- //
- // TODO(scherkus): WebMediaPlayerImpl should track this instead of plumbing
- // this through Pipeline. The one tricky bit might be guaranteeing we deliver
- // the size information before we reach HAVE_METADATA.
gfx::Size last_natural_size_;
- // The timestamp of the last frame removed from the |ready_frames_| queue,
- // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp()
- // during flushing.
- base::TimeDelta last_timestamp_;
-
DISALLOW_COPY_AND_ASSIGN(VideoRendererBase);
};
« no previous file with comments | « media/filters/pipeline_integration_test_base.cc ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698