Index: content/renderer/media/video_frame_compositor.h |
diff --git a/content/renderer/media/video_frame_compositor.h b/content/renderer/media/video_frame_compositor.h |
index 21654bd8d81b2985fa5b2af9d8067ff99319bfa4..1ff7dcea3e8abba910ca9d7cf333529fbc86ae78 100644 |
--- a/content/renderer/media/video_frame_compositor.h |
+++ b/content/renderer/media/video_frame_compositor.h |
@@ -8,35 +8,26 @@ |
#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 in a |
-// thread-safe manner. |
+// VideoFrameCompositor handles incoming frames by notifying the compositor and |
+// dispatching callbacks when detecting changes in video frames. |
// |
-// Typical usage is to deliver the output of VideoRendererImpl to |
+// Typical usage is to deliver ready-to-be-displayed video frames to |
// UpdateCurrentFrame() so that VideoFrameCompositor can take care of tracking |
-// dropped frames and firing callbacks as needed. |
+// changes in video frames and firing callbacks as needed. |
// |
-// All APIs are callable from any thread. |
-class CONTENT_EXPORT VideoFrameCompositor { |
+// VideoFrameCompositor must live on the same thread as the compositor. |
xhwang
2014/04/28 06:42:59
Can you add more comments about threading? It seem
scherkus (not reviewing)
2014/04/28 16:59:47
Done.
|
+class CONTENT_EXPORT VideoFrameCompositor : public cc::VideoFrameProvider { |
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 |
@@ -50,33 +41,30 @@ class CONTENT_EXPORT VideoFrameCompositor { |
// 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); |
- ~VideoFrameCompositor(); |
+ virtual ~VideoFrameCompositor(); |
- cc::VideoFrameProvider* GetVideoFrameProvider(); |
+ // 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; |
// Updates the current frame and notifies the compositor. |
void UpdateCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); |
- // 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(); |
- |
- // Returns the number of frames dropped before the compositor was notified |
- // of a new frame. |
- uint32 GetFramesDroppedBeforeCompositorWasNotified(); |
+ private: |
+ base::Callback<void(gfx::Size)> natural_size_changed_cb_; |
+ base::Callback<void(bool)> opacity_changed_cb_; |
- void SetFramesDroppedBeforeCompositorWasNotifiedForTesting( |
- uint32 dropped_frames); |
+ cc::VideoFrameProvider::Client* client_; |
- private: |
- class Internal; |
- Internal* internal_; |
+ base::Lock lock_; |
+ scoped_refptr<media::VideoFrame> current_frame_; |
DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); |
}; |