| Index: trunk/src/content/renderer/media/video_frame_compositor.h
|
| ===================================================================
|
| --- trunk/src/content/renderer/media/video_frame_compositor.h (revision 266950)
|
| +++ trunk/src/content/renderer/media/video_frame_compositor.h (working copy)
|
| @@ -8,29 +8,35 @@
|
| #include "base/callback.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/synchronization/lock.h"
|
| -#include "cc/layers/video_frame_provider.h"
|
| #include "content/common/content_export.h"
|
| #include "ui/gfx/size.h"
|
|
|
| +namespace base {
|
| +class SingleThreadTaskRunner;
|
| +}
|
| +
|
| +namespace cc {
|
| +class VideoFrameProvider;
|
| +}
|
| +
|
| namespace media {
|
| class VideoFrame;
|
| }
|
|
|
| namespace content {
|
|
|
| -// VideoFrameCompositor handles incoming frames by notifying the compositor and
|
| -// dispatching callbacks when detecting changes in video frames.
|
| +// VideoFrameCompositor handles incoming frames by notifying the compositor in a
|
| +// thread-safe manner.
|
| //
|
| -// Typical usage is to deliver ready-to-be-displayed video frames to
|
| +// Typical usage is to deliver the output of VideoRendererImpl to
|
| // UpdateCurrentFrame() so that VideoFrameCompositor can take care of tracking
|
| -// changes in video frames and firing callbacks as needed.
|
| +// dropped frames and firing callbacks as needed.
|
| //
|
| -// While VideoFrameCompositor must live on the same thread as the compositor,
|
| -// GetCurrentFrame() is callable from any thread to let clients access the
|
| -// current frame for non-compositing purposes.
|
| -class CONTENT_EXPORT VideoFrameCompositor
|
| - : NON_EXPORTED_BASE(public cc::VideoFrameProvider) {
|
| +// All APIs are callable from any thread.
|
| +class CONTENT_EXPORT VideoFrameCompositor {
|
| public:
|
| + // |compositor_task_runner| is the task runner of the compositor.
|
| + //
|
| // |natural_size_changed_cb| is run with the new natural size of the video
|
| // frame whenever a change in natural size is detected. It is not called the
|
| // first time UpdateCurrentFrame() is called. Run on the same thread as the
|
| @@ -44,31 +50,34 @@
|
| // respect to why we don't call |natural_size_changed_cb| on the first frame.
|
| // I suspect it was for historical reasons that no longer make sense.
|
| VideoFrameCompositor(
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
|
| const base::Callback<void(gfx::Size)>& natural_size_changed_cb,
|
| const base::Callback<void(bool)>& opacity_changed_cb);
|
| - virtual ~VideoFrameCompositor();
|
| + ~VideoFrameCompositor();
|
|
|
| - // cc::VideoFrameProvider implementation.
|
| - //
|
| - // NOTE: GetCurrentFrame() is safe to call from any thread.
|
| - virtual void SetVideoFrameProviderClient(
|
| - cc::VideoFrameProvider::Client* client) OVERRIDE;
|
| - virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE;
|
| - virtual void PutCurrentFrame(
|
| - const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
|
| + cc::VideoFrameProvider* GetVideoFrameProvider();
|
|
|
| // Updates the current frame and notifies the compositor.
|
| void UpdateCurrentFrame(const scoped_refptr<media::VideoFrame>& frame);
|
|
|
| - private:
|
| - base::Callback<void(gfx::Size)> natural_size_changed_cb_;
|
| - base::Callback<void(bool)> opacity_changed_cb_;
|
| + // Retrieves the last frame set via UpdateCurrentFrame() for non-compositing
|
| + // purposes (e.g., painting to a canvas).
|
| + //
|
| + // Note that the compositor retrieves frames via the cc::VideoFrameProvider
|
| + // interface instead of using this method.
|
| + scoped_refptr<media::VideoFrame> GetCurrentFrame();
|
|
|
| - cc::VideoFrameProvider::Client* client_;
|
| + // Returns the number of frames dropped before the compositor was notified
|
| + // of a new frame.
|
| + uint32 GetFramesDroppedBeforeCompositorWasNotified();
|
|
|
| - base::Lock lock_;
|
| - scoped_refptr<media::VideoFrame> current_frame_;
|
| + void SetFramesDroppedBeforeCompositorWasNotifiedForTesting(
|
| + uint32 dropped_frames);
|
|
|
| + private:
|
| + class Internal;
|
| + Internal* internal_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor);
|
| };
|
|
|
|
|