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

Unified Diff: content/renderer/media/webmediaplayer_ms_compositor.h

Issue 2529263004: Move passing of WebRTC rendering frames to IO thread (Closed)
Patch Set: Created 4 years 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
Index: content/renderer/media/webmediaplayer_ms_compositor.h
diff --git a/content/renderer/media/webmediaplayer_ms_compositor.h b/content/renderer/media/webmediaplayer_ms_compositor.h
index cf38aa5baeb2ea0d15f13482633c8dfd7363b0c8..0159d8204ba8d6609d36f1332804dea5126fc92b 100644
--- a/content/renderer/media/webmediaplayer_ms_compositor.h
+++ b/content/renderer/media/webmediaplayer_ms_compositor.h
@@ -39,7 +39,7 @@ class WebMediaPlayerMS;
// This class is designed to handle the work load on compositor thread for
// WebMediaPlayerMS. It will be instantiated on the main thread, but destroyed
-// on the compositor thread.
+// on the thread holding the last reference.
//
// WebMediaPlayerMSCompositor utilizes VideoRendererAlgorithm to store the
// incoming frames and select the best frame for rendering to maximize the
@@ -47,7 +47,8 @@ class WebMediaPlayerMS;
// Otherwise, WebMediaPlayerMSCompositor will simply store the most recent
// frame, and submit it whenever asked by the compositor.
class CONTENT_EXPORT WebMediaPlayerMSCompositor
- : public NON_EXPORTED_BASE(cc::VideoFrameProvider) {
+ : public NON_EXPORTED_BASE(cc::VideoFrameProvider),
+ public base::RefCountedThreadSafe<WebMediaPlayerMSCompositor> {
public:
// This |url| represents the media stream we are rendering. |url| is used to
// find out what web stream this WebMediaPlayerMSCompositor is playing, and
@@ -58,8 +59,6 @@ class CONTENT_EXPORT WebMediaPlayerMSCompositor
const blink::WebMediaStream& web_stream,
const base::WeakPtr<WebMediaPlayerMS>& player);
- ~WebMediaPlayerMSCompositor() override;
-
void EnqueueFrame(scoped_refptr<media::VideoFrame> frame);
// Statistical data
@@ -88,26 +87,35 @@ class CONTENT_EXPORT WebMediaPlayerMSCompositor
void StopRendering();
void ReplaceCurrentFrameWithACopy();
+ // Tell |video_frame_provider_client_| to stop using this instance in
+ // preparation for dtor.
+ void StopUsingProvider();
+
private:
+ friend class base::RefCountedThreadSafe<WebMediaPlayerMSCompositor>;
friend class WebMediaPlayerMSTest;
+ ~WebMediaPlayerMSCompositor() override;
+
bool MapTimestampsToRenderTimeTicks(
const std::vector<base::TimeDelta>& timestamps,
std::vector<base::TimeTicks>* wall_clock_times);
- void SetCurrentFrame(const scoped_refptr<media::VideoFrame>& frame);
-
// For algorithm enabled case only: given the render interval, update
// current_frame_ and dropped_frame_count_.
void Render(base::TimeTicks deadline_min, base::TimeTicks deadline_max);
+ void SetCurrentFrame(const scoped_refptr<media::VideoFrame>& frame);
qiangchen 2016/12/05 18:54:57 Can you order this before Render function to kill
emircan 2016/12/06 00:36:43 I wanted to sync the order of declaration/definiti
+
void StartRenderingInternal();
void StopRenderingInternal();
+ void StopUsingProviderInternal();
void SetAlgorithmEnabledForTesting(bool algorithm_enabled);
// Used for DCHECKs to ensure method calls executed in the correct thread.
base::ThreadChecker thread_checker_;
+ base::ThreadChecker media_thread_checker_;
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
base::MessageLoop* main_message_loop_;
@@ -148,6 +156,7 @@ class CONTENT_EXPORT WebMediaPlayerMSCompositor
size_t dropped_frame_count_;
bool stopped_;
+ bool provider_in_use_;
qiangchen 2016/12/05 18:54:57 Can you simply set video_frame_provider_client_ to
emircan 2016/12/06 00:36:43 Done.
std::map<base::TimeDelta, base::TimeTicks> timestamps_to_clock_times_;
@@ -155,9 +164,6 @@ class CONTENT_EXPORT WebMediaPlayerMSCompositor
// |current_frame_|, and |rendering_frame_buffer_|.
base::Lock current_frame_lock_;
- // Make sure the weak pointer factory member is the last member of the class.
- base::WeakPtrFactory<WebMediaPlayerMSCompositor> weak_ptr_factory_;
-
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMSCompositor);
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698