Chromium Code Reviews| Index: content/renderer/media/webmediaplayer_ms.h |
| diff --git a/content/renderer/media/webmediaplayer_ms.h b/content/renderer/media/webmediaplayer_ms.h |
| index 3254f83ab3727352363088be8e1add1fccf00027..addfb7f92bc0b8d903d5fd13ef37e1303201d208 100644 |
| --- a/content/renderer/media/webmediaplayer_ms.h |
| +++ b/content/renderer/media/webmediaplayer_ms.h |
| @@ -53,16 +53,18 @@ class VideoFrameProvider; |
| // WebKit client of this media player object. |
| class WebMediaPlayerMS |
| : public blink::WebMediaPlayer, |
| - public cc::VideoFrameProvider, |
| public base::SupportsWeakPtr<WebMediaPlayerMS> { |
| public: |
| // Construct a WebMediaPlayerMS with reference to the client, and |
| // a MediaStreamClient which provides VideoFrameProvider. |
| - WebMediaPlayerMS(blink::WebFrame* frame, |
| - blink::WebMediaPlayerClient* client, |
| - base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
| - media::MediaLog* media_log, |
| - scoped_ptr<MediaStreamRendererFactory> factory); |
| + WebMediaPlayerMS( |
| + blink::WebFrame* frame, |
| + blink::WebMediaPlayerClient* client, |
| + base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
| + media::MediaLog* media_log, |
| + scoped_ptr<MediaStreamRendererFactory> factory, |
| + scoped_refptr<base::SingleThreadTaskRunner> compositor_thread); |
|
DaleCurtis
2015/08/17 21:31:30
const&, compositor_task_runner ?
qiangchen
2015/08/18 01:21:49
Done.
|
| + |
| virtual ~WebMediaPlayerMS(); |
| virtual void load(LoadType load_type, |
| @@ -125,16 +127,74 @@ class WebMediaPlayerMS |
| bool premultiply_alpha, |
| bool flip_y) override; |
| - // VideoFrameProvider implementation. |
| - void SetVideoFrameProviderClient( |
| - cc::VideoFrameProvider::Client* client) override; |
| - bool UpdateCurrentFrame(base::TimeTicks deadline_min, |
| - base::TimeTicks deadline_max) override; |
| - bool HasCurrentFrame() override; |
| - scoped_refptr<media::VideoFrame> GetCurrentFrame() override; |
| - void PutCurrentFrame() override; |
| - |
| private: |
| + class Compositor : public cc::VideoFrameProvider { |
| + public: |
| + Compositor( |
|
DaleCurtis
2015/08/17 21:31:30
explicit
qiangchen
2015/08/18 01:21:49
Done.
|
| + scoped_refptr<base::SingleThreadTaskRunner> const& compositor_thread); |
| + ~Compositor() override; |
| + |
| + void EnqueueFrame(scoped_refptr<media::VideoFrame> const& frame); |
| + |
| + // Metadata about current frame |
| + gfx::Size CurrentFrameSize(); |
|
DaleCurtis
2015/08/17 21:31:30
Are these two necessary since you have GetCurrentF
qiangchen
2015/08/18 01:21:49
N/A now.
Add staging_frame_. Just think it as a V
|
| + base::TimeDelta CurrentFrameTimestamp(); |
| + unsigned TotalFrameCount(); |
|
DaleCurtis
2015/08/17 21:31:30
Add GetXXX and const modifier to both of these.
qiangchen
2015/08/18 01:21:49
Done.
|
| + unsigned DroppedFrameCount(); |
| + |
| + // Get a reference to Current Frame. Different from GetCurrentFrame |
|
DaleCurtis
2015/08/17 21:31:30
This is pretty messy, can you avoid having both me
qiangchen
2015/08/18 01:21:49
Done.
|
| + // function, as a call to the latter would mean the current frame gets |
| + // rendered. Thus when one needs the frame for other purpose, one should |
| + // call this function. |
| + scoped_refptr<media::VideoFrame> CurrentFrame(); |
| + media::SkCanvasVideoRenderer* VideoRenderer(); |
| + |
| + // VideoFrameProvider implementation. |
| + void SetVideoFrameProviderClient( |
| + cc::VideoFrameProvider::Client* client) override; |
| + bool UpdateCurrentFrame(base::TimeTicks deadline_min, |
| + base::TimeTicks deadline_max) override; |
| + bool HasCurrentFrame() override; |
| + scoped_refptr<media::VideoFrame> GetCurrentFrame() override; |
| + void PutCurrentFrame() override; |
| + |
| + void StartRendering(); |
| + void StopRendering(); |
| + |
| + private: |
| + scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_; |
| + |
| + // A pointer back to the compositor to inform it about state changes. This |
| + // is |
| + // not NULL while the compositor is actively using this webmediaplayer. |
| + cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| + |
| + // |current_frame_| is updated only on main thread. The object it holds |
| + // can be freed on the compositor thread if it is the last to hold a |
| + // reference but media::VideoFrame is a thread-safe ref-pointer. It is |
| + // however read on the compositing thread so locking is required around all |
| + // modifications on the main thread, and all reads on the compositing |
| + // thread. |
| + scoped_refptr<media::VideoFrame> current_frame_; |
| + // |current_frame_used_| is updated on both main and compositing thread. |
|
DaleCurtis
2015/08/17 21:31:30
Insert blank line.
qiangchen
2015/08/18 01:21:49
Done.
|
| + // It's used to track whether |current_frame_| was painted for detecting |
| + // when to increase |dropped_frame_count_|. |
| + bool current_frame_used_; |
| + |
| + base::TimeDelta current_time_; |
| + base::TimeTicks last_deadline_max_; |
| + unsigned total_frame_count_; |
| + unsigned dropped_frame_count_; |
| + |
| + bool paused_; |
| + |
| + media::SkCanvasVideoRenderer video_renderer_; |
| + |
| + // |current_frame_lock_| protects |current_frame_used_| and |
| + // |current_frame_|. |
| + base::Lock current_frame_lock_; |
| + }; |
| + |
| // The callback for VideoFrameProvider to signal a new frame is available. |
| void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); |
| // Need repaint due to state change. |
| @@ -171,30 +231,9 @@ class WebMediaPlayerMS |
| scoped_refptr<content::VideoFrameProvider> video_frame_provider_; |
| bool paused_; |
| - // |current_frame_| is updated only on main thread. The object it holds |
| - // can be freed on the compositor thread if it is the last to hold a |
| - // reference but media::VideoFrame is a thread-safe ref-pointer. It is |
| - // however read on the compositing thread so locking is required around all |
| - // modifications on the main thread, and all reads on the compositing thread. |
| - scoped_refptr<media::VideoFrame> current_frame_; |
| - // |current_frame_used_| is updated on both main and compositing thread. |
| - // It's used to track whether |current_frame_| was painted for detecting |
| - // when to increase |dropped_frame_count_|. |
| - bool current_frame_used_; |
| - // |current_frame_lock_| protects |current_frame_used_| and |current_frame_|. |
| - base::Lock current_frame_lock_; |
| - |
| scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
| - // A pointer back to the compositor to inform it about state changes. This is |
| - // not NULL while the compositor is actively using this webmediaplayer. |
| - cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| - |
| bool received_first_frame_; |
| - base::TimeDelta current_time_; |
| - unsigned total_frame_count_; |
| - unsigned dropped_frame_count_; |
| - media::SkCanvasVideoRenderer video_renderer_; |
| scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; |
| @@ -202,6 +241,12 @@ class WebMediaPlayerMS |
| scoped_ptr<MediaStreamRendererFactory> renderer_factory_; |
| + // WebMediaPlayerMS owns the Compositor instance, but the destructions of |
| + // compositor should take place on Compositor Thread. |
| + scoped_ptr<Compositor> compositor_; |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
| }; |