| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "content/common/media/media_stream_messages.h" |
| 14 #include "content/public/common/media_stream_request.h" | 15 #include "content/public/common/media_stream_request.h" |
| 15 #include "content/renderer/media/media_stream_constraints_util.h" | 16 #include "content/renderer/media/media_stream_constraints_util.h" |
| 16 #include "content/renderer/media/video_capture_impl_manager.h" | 17 #include "content/renderer/media/video_capture_impl_manager.h" |
| 17 #include "content/renderer/render_thread_impl.h" | 18 #include "content/renderer/render_thread_impl.h" |
| 18 #include "media/base/bind_to_current_loop.h" | 19 #include "media/base/bind_to_current_loop.h" |
| 19 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
| 20 #include "media/base/video_capturer_source.h" | 21 #include "media/base/video_capturer_source.h" |
| 21 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 312 } |
| 312 | 313 |
| 313 void LocalVideoCapturerSource::RequestRefreshFrame() { | 314 void LocalVideoCapturerSource::RequestRefreshFrame() { |
| 314 DVLOG(3) << __FUNCTION__; | 315 DVLOG(3) << __FUNCTION__; |
| 315 DCHECK(thread_checker_.CalledOnValidThread()); | 316 DCHECK(thread_checker_.CalledOnValidThread()); |
| 316 if (stop_capture_cb_.is_null()) | 317 if (stop_capture_cb_.is_null()) |
| 317 return; // Do not request frames if the source is stopped. | 318 return; // Do not request frames if the source is stopped. |
| 318 manager_->RequestRefreshFrame(session_id_); | 319 manager_->RequestRefreshFrame(session_id_); |
| 319 } | 320 } |
| 320 | 321 |
| 321 | |
| 322 void LocalVideoCapturerSource::StopCapture() { | 322 void LocalVideoCapturerSource::StopCapture() { |
| 323 DVLOG(3) << __FUNCTION__; | 323 DVLOG(3) << __FUNCTION__; |
| 324 DCHECK(thread_checker_.CalledOnValidThread()); | 324 DCHECK(thread_checker_.CalledOnValidThread()); |
| 325 // Immediately make sure we don't provide more frames. | 325 // Immediately make sure we don't provide more frames. |
| 326 if (!stop_capture_cb_.is_null()) | 326 if (!stop_capture_cb_.is_null()) |
| 327 base::ResetAndReturn(&stop_capture_cb_).Run(); | 327 base::ResetAndReturn(&stop_capture_cb_).Run(); |
| 328 running_callback_.Reset(); | 328 running_callback_.Reset(); |
| 329 // Invalidate any potential format enumerations going on. | 329 // Invalidate any potential format enumerations going on. |
| 330 formats_enumerated_callback_.Reset(); | 330 formats_enumerated_callback_.Reset(); |
| 331 } | 331 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 gfx::Size(resolution.width, resolution.height), frame_rate, | 386 gfx::Size(resolution.width, resolution.height), frame_rate, |
| 387 media::PIXEL_FORMAT_I420)); | 387 media::PIXEL_FORMAT_I420)); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 base::ResetAndReturn(&formats_enumerated_callback_).Run(default_formats); | 390 base::ResetAndReturn(&formats_enumerated_callback_).Run(default_formats); |
| 391 } | 391 } |
| 392 | 392 |
| 393 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( | 393 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
| 394 const SourceStoppedCallback& stop_callback, | 394 const SourceStoppedCallback& stop_callback, |
| 395 std::unique_ptr<media::VideoCapturerSource> source) | 395 std::unique_ptr<media::VideoCapturerSource> source) |
| 396 : source_(std::move(source)) { | 396 : RenderFrameObserver(nullptr), source_(std::move(source)) { |
| 397 SetStopCallback(stop_callback); | 397 SetStopCallback(stop_callback); |
| 398 } | 398 } |
| 399 | 399 |
| 400 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( | 400 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
| 401 const SourceStoppedCallback& stop_callback, | 401 const SourceStoppedCallback& stop_callback, |
| 402 const StreamDeviceInfo& device_info) | 402 const StreamDeviceInfo& device_info, |
| 403 : source_(new LocalVideoCapturerSource(device_info)) { | 403 RenderFrame* render_frame) |
| 404 : RenderFrameObserver(render_frame), |
| 405 source_(new LocalVideoCapturerSource(device_info)) { |
| 404 SetStopCallback(stop_callback); | 406 SetStopCallback(stop_callback); |
| 405 SetDeviceInfo(device_info); | 407 SetDeviceInfo(device_info); |
| 406 } | 408 } |
| 407 | 409 |
| 408 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { | 410 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { |
| 409 } | 411 } |
| 410 | 412 |
| 411 void MediaStreamVideoCapturerSource::RequestRefreshFrame() { | 413 void MediaStreamVideoCapturerSource::RequestRefreshFrame() { |
| 412 source_->RequestRefreshFrame(); | 414 source_->RequestRefreshFrame(); |
| 413 } | 415 } |
| 414 | 416 |
| 417 void MediaStreamVideoCapturerSource::SetCapturingLinkSecured(bool is_secure) { |
| 418 Send(new MediaStreamHostMsg_SetCapturingLinkSecured( |
| 419 device_info().session_id, device_info().device.type, is_secure)); |
| 420 } |
| 421 |
| 415 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( | 422 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( |
| 416 int max_requested_width, | 423 int max_requested_width, |
| 417 int max_requested_height, | 424 int max_requested_height, |
| 418 double max_requested_frame_rate, | 425 double max_requested_frame_rate, |
| 419 const VideoCaptureDeviceFormatsCB& callback) { | 426 const VideoCaptureDeviceFormatsCB& callback) { |
| 420 source_->GetCurrentSupportedFormats( | 427 source_->GetCurrentSupportedFormats( |
| 421 max_requested_width, | 428 max_requested_width, |
| 422 max_requested_height, | 429 max_requested_height, |
| 423 max_requested_frame_rate, | 430 max_requested_frame_rate, |
| 424 callback); | 431 callback); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 450 void MediaStreamVideoCapturerSource::OnStarted(bool result) { | 457 void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
| 451 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); | 458 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
| 452 } | 459 } |
| 453 | 460 |
| 454 const char* | 461 const char* |
| 455 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { | 462 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { |
| 456 return kPowerLineFrequency; | 463 return kPowerLineFrequency; |
| 457 } | 464 } |
| 458 | 465 |
| 459 } // namespace content | 466 } // namespace content |
| OLD | NEW |