OLD | NEW |
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/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::OnVideoFrame( | 84 void RTCVideoRenderer::OnVideoFrame( |
85 const scoped_refptr<media::VideoFrame>& frame, | 85 const scoped_refptr<media::VideoFrame>& frame, |
86 const media::VideoCaptureFormat& format, | |
87 const base::TimeTicks& estimated_capture_time) { | 86 const base::TimeTicks& estimated_capture_time) { |
88 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 87 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
89 if (state_ != STARTED) { | 88 if (state_ != STARTED) { |
90 return; | 89 return; |
91 } | 90 } |
92 | 91 |
93 frame_size_ = frame->natural_size(); | 92 frame_size_ = frame->natural_size(); |
94 | 93 |
95 TRACE_EVENT_INSTANT1("rtc_video_renderer", | 94 TRACE_EVENT_INSTANT1("rtc_video_renderer", |
96 "OnVideoFrame", | 95 "OnVideoFrame", |
97 TRACE_EVENT_SCOPE_THREAD, | 96 TRACE_EVENT_SCOPE_THREAD, |
98 "timestamp", | 97 "timestamp", |
99 frame->timestamp().InMilliseconds()); | 98 frame->timestamp().InMilliseconds()); |
100 repaint_cb_.Run(frame); | 99 repaint_cb_.Run(frame); |
101 } | 100 } |
102 | 101 |
103 void RTCVideoRenderer::RenderSignalingFrame() { | 102 void RTCVideoRenderer::RenderSignalingFrame() { |
104 // This is necessary to make sure audio can play if the video tag src is | 103 // This is necessary to make sure audio can play if the video tag src is |
105 // a MediaStream video track that has been rejected or ended. | 104 // a MediaStream video track that has been rejected or ended. |
106 // It also ensure that the renderer don't hold a reference to a real video | 105 // It also ensure that the renderer don't hold a reference to a real video |
107 // frame if no more frames are provided. This is since there might be a | 106 // frame if no more frames are provided. This is since there might be a |
108 // finite number of available buffers. E.g, video that | 107 // finite number of available buffers. E.g, video that |
109 // originates from a video camera. | 108 // originates from a video camera. |
110 scoped_refptr<media::VideoFrame> video_frame = | 109 scoped_refptr<media::VideoFrame> video_frame = |
111 media::VideoFrame::CreateBlackFrame(frame_size_); | 110 media::VideoFrame::CreateBlackFrame(frame_size_); |
112 OnVideoFrame(video_frame, media::VideoCaptureFormat(), base::TimeTicks()); | 111 OnVideoFrame(video_frame, base::TimeTicks()); |
113 } | 112 } |
114 | 113 |
115 } // namespace content | 114 } // namespace content |
OLD | NEW |