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/media_stream_video_capturer_source.h" | 5 #include "content/renderer/media/media_stream_video_capturer_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_to_current_loop.h" |
8 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 10 #include "base/location.h" |
10 #include "content/renderer/media/video_capture_impl_manager.h" | 11 #include "content/renderer/media/video_capture_impl_manager.h" |
11 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
12 #include "media/base/bind_to_current_loop.h" | |
13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Resolutions used if the source doesn't support capability enumeration. | 17 // Resolutions used if the source doesn't support capability enumeration. |
18 struct { | 18 struct { |
19 int width; | 19 int width; |
20 int height; | 20 int height; |
21 } const kVideoResolutions[] = {{1920, 1080}, | 21 } const kVideoResolutions[] = {{1920, 1080}, |
22 {1280, 720}, | 22 {1280, 720}, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (!RenderThreadImpl::current()) | 88 if (!RenderThreadImpl::current()) |
89 return; | 89 return; |
90 VideoCaptureImplManager* const manager = | 90 VideoCaptureImplManager* const manager = |
91 RenderThreadImpl::current()->video_capture_impl_manager(); | 91 RenderThreadImpl::current()->video_capture_impl_manager(); |
92 if (!manager) | 92 if (!manager) |
93 return; | 93 return; |
94 DCHECK(source_formats_callback_.is_null()); | 94 DCHECK(source_formats_callback_.is_null()); |
95 source_formats_callback_ = callback; | 95 source_formats_callback_ = callback; |
96 manager->GetDeviceFormatsInUse( | 96 manager->GetDeviceFormatsInUse( |
97 session_id_, | 97 session_id_, |
98 media::BindToCurrentLoop( | 98 base::BindToCurrentLoop( |
99 base::Bind( | 99 base::Bind( |
100 &VideoCapturerDelegate::OnDeviceFormatsInUseReceived, | 100 &VideoCapturerDelegate::OnDeviceFormatsInUseReceived, |
101 weak_factory_.GetWeakPtr()))); | 101 weak_factory_.GetWeakPtr()))); |
102 } | 102 } |
103 | 103 |
104 void VideoCapturerDelegate::StartCapture( | 104 void VideoCapturerDelegate::StartCapture( |
105 const media::VideoCaptureParams& params, | 105 const media::VideoCaptureParams& params, |
106 const VideoCaptureDeliverFrameCB& new_frame_callback, | 106 const VideoCaptureDeliverFrameCB& new_frame_callback, |
107 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner, | 107 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner, |
108 const RunningCallback& running_callback) { | 108 const RunningCallback& running_callback) { |
(...skipping 12 matching lines...) Expand all Loading... |
121 RenderThreadImpl::current()->GetIOMessageLoopProxy()) { | 121 RenderThreadImpl::current()->GetIOMessageLoopProxy()) { |
122 DCHECK(false) << "Only IO thread supported right now."; | 122 DCHECK(false) << "Only IO thread supported right now."; |
123 running_callback.Run(false); | 123 running_callback.Run(false); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 stop_capture_cb_ = | 127 stop_capture_cb_ = |
128 manager->StartCapture( | 128 manager->StartCapture( |
129 session_id_, | 129 session_id_, |
130 params, | 130 params, |
131 media::BindToCurrentLoop(base::Bind( | 131 base::BindToCurrentLoop(base::Bind( |
132 &VideoCapturerDelegate::OnStateUpdate, | 132 &VideoCapturerDelegate::OnStateUpdate, |
133 weak_factory_.GetWeakPtr())), | 133 weak_factory_.GetWeakPtr())), |
134 new_frame_callback); | 134 new_frame_callback); |
135 } | 135 } |
136 | 136 |
137 void VideoCapturerDelegate::StopCapture() { | 137 void VideoCapturerDelegate::StopCapture() { |
138 // Immediately make sure we don't provide more frames. | 138 // Immediately make sure we don't provide more frames. |
139 DVLOG(3) << "VideoCapturerDelegate::StopCapture()"; | 139 DVLOG(3) << "VideoCapturerDelegate::StopCapture()"; |
140 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
141 if (!stop_capture_cb_.is_null()) { | 141 if (!stop_capture_cb_.is_null()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // NULL in unit test. | 177 // NULL in unit test. |
178 if (!RenderThreadImpl::current()) | 178 if (!RenderThreadImpl::current()) |
179 return; | 179 return; |
180 VideoCaptureImplManager* const manager = | 180 VideoCaptureImplManager* const manager = |
181 RenderThreadImpl::current()->video_capture_impl_manager(); | 181 RenderThreadImpl::current()->video_capture_impl_manager(); |
182 if (!manager) | 182 if (!manager) |
183 return; | 183 return; |
184 | 184 |
185 manager->GetDeviceSupportedFormats( | 185 manager->GetDeviceSupportedFormats( |
186 session_id_, | 186 session_id_, |
187 media::BindToCurrentLoop( | 187 base::BindToCurrentLoop( |
188 base::Bind( | 188 base::Bind( |
189 &VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated, | 189 &VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated, |
190 weak_factory_.GetWeakPtr()))); | 190 weak_factory_.GetWeakPtr()))); |
191 } | 191 } |
192 | 192 |
193 void VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated( | 193 void VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated( |
194 const media::VideoCaptureFormats& formats) { | 194 const media::VideoCaptureFormats& formats) { |
195 DVLOG(3) << "OnDeviceSupportedFormatsEnumerated: " << formats.size() | 195 DVLOG(3) << "OnDeviceSupportedFormatsEnumerated: " << formats.size() |
196 << " received"; | 196 << " received"; |
197 DCHECK(thread_checker_.CalledOnValidThread()); | 197 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 void MediaStreamVideoCapturerSource::StopSourceImpl() { | 267 void MediaStreamVideoCapturerSource::StopSourceImpl() { |
268 delegate_->StopCapture(); | 268 delegate_->StopCapture(); |
269 } | 269 } |
270 | 270 |
271 void MediaStreamVideoCapturerSource::OnStarted(bool result) { | 271 void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
272 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); | 272 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
273 } | 273 } |
274 | 274 |
275 } // namespace content | 275 } // namespace content |
OLD | NEW |