Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" | 5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 protected: | 33 protected: |
| 34 friend class base::RefCountedThreadSafe<RemoteVideoSourceDelegate>; | 34 friend class base::RefCountedThreadSafe<RemoteVideoSourceDelegate>; |
| 35 ~RemoteVideoSourceDelegate() override; | 35 ~RemoteVideoSourceDelegate() override; |
| 36 | 36 |
| 37 // Implements webrtc::VideoRendererInterface used for receiving video frames | 37 // Implements webrtc::VideoRendererInterface used for receiving video frames |
| 38 // from the PeerConnection video track. May be called on a libjingle internal | 38 // from the PeerConnection video track. May be called on a libjingle internal |
| 39 // thread. | 39 // thread. |
| 40 void SetSize(int width, int height) override; | 40 void SetSize(int width, int height) override; |
| 41 void RenderFrame(const cricket::VideoFrame* frame) override; | 41 void RenderFrame(const cricket::VideoFrame* frame) override; |
| 42 | 42 |
| 43 void DoRenderFrameOnIOThread(scoped_refptr<media::VideoFrame> video_frame, | 43 void DoRenderFrameOnIOThread(scoped_refptr<media::VideoFrame> video_frame); |
|
tommi (sloooow) - chröme
2015/03/03 10:06:15
nit: const & ?
miu
2015/03/03 21:31:52
Done.
| |
| 44 const media::VideoCaptureFormat& format); | |
| 45 private: | 44 private: |
| 46 // Bound to the render thread. | 45 // Bound to the render thread. |
| 47 base::ThreadChecker thread_checker_; | 46 base::ThreadChecker thread_checker_; |
| 48 | 47 |
| 49 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 48 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 50 // |frame_pool_| is only accessed on whatever | 49 // |frame_pool_| is only accessed on whatever |
| 51 // thread webrtc::VideoRendererInterface::RenderFrame is called on. | 50 // thread webrtc::VideoRendererInterface::RenderFrame is called on. |
| 52 media::VideoFramePool frame_pool_; | 51 media::VideoFramePool frame_pool_; |
| 53 | 52 |
| 54 // |frame_callback_| is accessed on the IO thread. | 53 // |frame_callback_| is accessed on the IO thread. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 int y_rows = frame->GetHeight(); | 95 int y_rows = frame->GetHeight(); |
| 97 int uv_rows = frame->GetChromaHeight(); | 96 int uv_rows = frame->GetChromaHeight(); |
| 98 CopyYPlane( | 97 CopyYPlane( |
| 99 frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame.get()); | 98 frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame.get()); |
| 100 CopyUPlane( | 99 CopyUPlane( |
| 101 frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame.get()); | 100 frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame.get()); |
| 102 CopyVPlane( | 101 CopyVPlane( |
| 103 frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame.get()); | 102 frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame.get()); |
| 104 } | 103 } |
| 105 | 104 |
| 106 media::VideoPixelFormat pixel_format = | |
| 107 (video_frame->format() == media::VideoFrame::YV12) ? | |
| 108 media::PIXEL_FORMAT_YV12 : media::PIXEL_FORMAT_TEXTURE; | |
| 109 | |
| 110 media::VideoCaptureFormat format( | |
| 111 gfx::Size(video_frame->natural_size().width(), | |
| 112 video_frame->natural_size().height()), | |
| 113 MediaStreamVideoSource::kUnknownFrameRate, | |
| 114 pixel_format); | |
| 115 | |
| 116 io_message_loop_->PostTask( | 105 io_message_loop_->PostTask( |
| 117 FROM_HERE, | 106 FROM_HERE, |
| 118 base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, | 107 base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, |
| 119 this, video_frame, format)); | 108 this, video_frame)); |
| 120 } | 109 } |
| 121 | 110 |
| 122 void MediaStreamRemoteVideoSource:: | 111 void MediaStreamRemoteVideoSource:: |
| 123 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( | 112 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( |
| 124 scoped_refptr<media::VideoFrame> video_frame, | 113 scoped_refptr<media::VideoFrame> video_frame) { |
| 125 const media::VideoCaptureFormat& format) { | |
| 126 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 114 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 127 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread"); | 115 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread"); |
| 128 // TODO(hclam): Give the estimated capture time. | 116 // TODO(hclam): Give the estimated capture time. |
| 129 frame_callback_.Run(video_frame, format, base::TimeTicks()); | 117 frame_callback_.Run(video_frame, base::TimeTicks()); |
| 130 } | 118 } |
| 131 | 119 |
| 132 MediaStreamRemoteVideoSource::MediaStreamRemoteVideoSource( | 120 MediaStreamRemoteVideoSource::MediaStreamRemoteVideoSource( |
| 133 scoped_ptr<TrackObserver> observer) | 121 scoped_ptr<TrackObserver> observer) |
| 134 : observer_(observer.Pass()) { | 122 : observer_(observer.Pass()) { |
| 135 // The callback will be automatically cleared when 'observer_' goes out of | 123 // The callback will be automatically cleared when 'observer_' goes out of |
| 136 // scope and no further callbacks will occur. | 124 // scope and no further callbacks will occur. |
| 137 observer_->SetCallback(base::Bind(&MediaStreamRemoteVideoSource::OnChanged, | 125 observer_->SetCallback(base::Bind(&MediaStreamRemoteVideoSource::OnChanged, |
| 138 base::Unretained(this))); | 126 base::Unretained(this))); |
| 139 } | 127 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 case webrtc::MediaStreamTrackInterface::kEnded: | 181 case webrtc::MediaStreamTrackInterface::kEnded: |
| 194 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 182 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
| 195 break; | 183 break; |
| 196 default: | 184 default: |
| 197 NOTREACHED(); | 185 NOTREACHED(); |
| 198 break; | 186 break; |
| 199 } | 187 } |
| 200 } | 188 } |
| 201 | 189 |
| 202 } // namespace content | 190 } // namespace content |
| OLD | NEW |