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

Side by Side Diff: content/renderer/media/rtc_video_renderer.cc

Issue 432903002: Change a disabled MediaStreamVideoTrack to output black video frames for each incoming frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Tommis comments. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/rtc_video_renderer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/media/rtc_video_renderer.h" 5 #include "content/renderer/media/rtc_video_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "media/base/bind_to_current_loop.h" 9 #include "media/base/bind_to_current_loop.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 } 75 }
76 76
77 void RTCVideoRenderer::OnReadyStateChanged( 77 void RTCVideoRenderer::OnReadyStateChanged(
78 blink::WebMediaStreamSource::ReadyState state) { 78 blink::WebMediaStreamSource::ReadyState state) {
79 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 79 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
80 if (state == blink::WebMediaStreamSource::ReadyStateEnded) 80 if (state == blink::WebMediaStreamSource::ReadyStateEnded)
81 RenderSignalingFrame(); 81 RenderSignalingFrame();
82 } 82 }
83 83
84 void RTCVideoRenderer::OnEnabledChanged(bool enabled) {
85 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
86 if (!enabled)
87 RenderSignalingFrame();
88 }
89
90 void RTCVideoRenderer::OnVideoFrame( 84 void RTCVideoRenderer::OnVideoFrame(
91 const scoped_refptr<media::VideoFrame>& frame, 85 const scoped_refptr<media::VideoFrame>& frame,
92 const media::VideoCaptureFormat& format, 86 const media::VideoCaptureFormat& format,
93 const base::TimeTicks& estimated_capture_time) { 87 const base::TimeTicks& estimated_capture_time) {
94 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 88 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
95 if (state_ != STARTED) { 89 if (state_ != STARTED) {
96 return; 90 return;
97 } 91 }
98 92
99 frame_size_ = frame->natural_size(); 93 frame_size_ = frame->natural_size();
100 94
101 TRACE_EVENT_INSTANT1("rtc_video_renderer", 95 TRACE_EVENT_INSTANT1("rtc_video_renderer",
102 "OnVideoFrame", 96 "OnVideoFrame",
103 TRACE_EVENT_SCOPE_THREAD, 97 TRACE_EVENT_SCOPE_THREAD,
104 "timestamp", 98 "timestamp",
105 frame->timestamp().InMilliseconds()); 99 frame->timestamp().InMilliseconds());
106 repaint_cb_.Run(frame); 100 repaint_cb_.Run(frame);
107 } 101 }
108 102
109 void RTCVideoRenderer::RenderSignalingFrame() { 103 void RTCVideoRenderer::RenderSignalingFrame() {
110 // This is necessary to make sure audio can play if the video tag src is 104 // This is necessary to make sure audio can play if the video tag src is
111 // a MediaStream video track that has been rejected, ended or disabled. 105 // a MediaStream video track that has been rejected or ended.
112 // It also ensure that the renderer don't hold a reference to a real video 106 // It also ensure that the renderer don't hold a reference to a real video
113 // frame if no more frames are provided. This is since there might be a 107 // frame if no more frames are provided. This is since there might be a
114 // finite number of available buffers. E.g, video that 108 // finite number of available buffers. E.g, video that
115 // originates from a video camera. 109 // originates from a video camera.
116 scoped_refptr<media::VideoFrame> video_frame = 110 scoped_refptr<media::VideoFrame> video_frame =
117 media::VideoFrame::CreateBlackFrame(frame_size_); 111 media::VideoFrame::CreateBlackFrame(frame_size_);
118 OnVideoFrame(video_frame, media::VideoCaptureFormat(), base::TimeTicks()); 112 OnVideoFrame(video_frame, media::VideoCaptureFormat(), base::TimeTicks());
119 } 113 }
120 114
121 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_renderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698