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

Side by Side Diff: media/blink/video_frame_compositor.h

Issue 1083383005: Connect the new video rendering path to the compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vra
Patch Set: Remove NullVideoSink Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 5 #ifndef MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/time/tick_clock.h"
12 #include "cc/layers/video_frame_provider.h" 13 #include "cc/layers/video_frame_provider.h"
13 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
14 #include "media/base/video_renderer_sink.h" 15 #include "media/base/video_renderer_sink.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 17
17 namespace media { 18 namespace media {
18 class VideoFrame; 19 class VideoFrame;
19 20
20 // VideoFrameCompositor acts as a bridge between the media and cc layers for 21 // VideoFrameCompositor acts as a bridge between the media and cc layers for
21 // rendering video frames. I.e. a media::VideoRenderer will talk to this class 22 // rendering video frames. I.e. a media::VideoRenderer will talk to this class
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 scoped_refptr<VideoFrame> GetCurrentFrame() override; 85 scoped_refptr<VideoFrame> GetCurrentFrame() override;
85 void PutCurrentFrame() override; 86 void PutCurrentFrame() override;
86 87
87 // VideoRendererSink implementation. These methods must be called from the 88 // VideoRendererSink implementation. These methods must be called from the
88 // same thread (typically the media thread). 89 // same thread (typically the media thread).
89 void Start(RenderCallback* callback) override; 90 void Start(RenderCallback* callback) override;
90 void Stop() override; 91 void Stop() override;
91 void PaintFrameUsingOldRenderingPath( 92 void PaintFrameUsingOldRenderingPath(
92 const scoped_refptr<VideoFrame>& frame) override; 93 const scoped_refptr<VideoFrame>& frame) override;
93 94
95 void set_tick_clock_for_testing(scoped_ptr<base::TickClock> tick_clock) {
96 tick_clock_ = tick_clock.Pass();
97 }
98
99 base::TimeDelta get_stale_frame_threshold_for_testing() const {
100 return stale_frame_threshold_;
101 }
102
94 private: 103 private:
95 // Called on the compositor thread to start or stop rendering if rendering was 104 // Called on the compositor thread to start or stop rendering if rendering was
96 // previously started or stopped before we had a |callback_|. 105 // previously started or stopped before we had a |client_|. Will only call
97 void OnRendererStateUpdate(); 106 // StopRendering() if |stop_if_not_rendering| is true.
107 void OnRendererStateUpdate(bool stop_if_not_rendering);
98 108
99 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 109 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
110 scoped_ptr<base::TickClock> tick_clock_;
100 111
101 // These callbacks are executed on the compositor thread. 112 // These callbacks are executed on the compositor thread.
102 base::Callback<void(gfx::Size)> natural_size_changed_cb_; 113 base::Callback<void(gfx::Size)> natural_size_changed_cb_;
103 base::Callback<void(bool)> opacity_changed_cb_; 114 base::Callback<void(bool)> opacity_changed_cb_;
104 115
105 // These values are only set and read on the compositor thread. 116 // These values are only set and read on the compositor thread.
106 cc::VideoFrameProvider::Client* client_; 117 cc::VideoFrameProvider::Client* client_;
107 scoped_refptr<VideoFrame> current_frame_; 118 scoped_refptr<VideoFrame> current_frame_;
119 base::TimeTicks last_frame_update_time_;
120 base::TimeDelta last_interval_;
121 base::TimeDelta stale_frame_threshold_;
108 122
109 // These values are updated and read from the media and compositor threads. 123 // These values are updated and read from the media and compositor threads.
110 base::Lock lock_; 124 base::Lock lock_;
111 bool rendering_; 125 bool rendering_;
126 bool rendered_last_frame_;
112 VideoRendererSink::RenderCallback* callback_; 127 VideoRendererSink::RenderCallback* callback_;
113 128
114 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); 129 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor);
115 }; 130 };
116 131
117 } // namespace media 132 } // namespace media
118 133
119 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ 134 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698