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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2634263002: Pass camera facing info to audio client (Closed)
Patch Set: separate out video_capture_observer_chromeos Created 3 years, 10 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
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/browser/renderer_host/media/video_capture_manager.h" 5 #include "content/browser/renderer_host/media/video_capture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "content/browser/media/media_internals.h" 27 #include "content/browser/media/media_internals.h"
28 #include "content/browser/renderer_host/media/video_capture_controller.h" 28 #include "content/browser/renderer_host/media/video_capture_controller.h"
29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" 29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h"
30 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" 30 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h"
31 #include "content/browser/renderer_host/media/video_frame_receiver_on_io_thread. h" 31 #include "content/browser/renderer_host/media/video_frame_receiver_on_io_thread. h"
32 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/desktop_media_id.h" 33 #include "content/public/browser/desktop_media_id.h"
34 #include "content/public/common/media_stream_request.h" 34 #include "content/public/common/media_stream_request.h"
35 #include "media/base/bind_to_current_loop.h" 35 #include "media/base/bind_to_current_loop.h"
36 #include "media/base/media_switches.h" 36 #include "media/base/media_switches.h"
37 #include "media/base/video_facing.h"
37 #include "media/capture/video/video_capture_buffer_pool_impl.h" 38 #include "media/capture/video/video_capture_buffer_pool_impl.h"
38 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" 39 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h"
39 #include "media/capture/video/video_capture_device.h" 40 #include "media/capture/video/video_capture_device.h"
40 #include "media/capture/video/video_capture_device_client.h" 41 #include "media/capture/video/video_capture_device_client.h"
41 #include "media/capture/video/video_capture_device_factory.h" 42 #include "media/capture/video/video_capture_device_factory.h"
42 43
43 #if defined(ENABLE_SCREEN_CAPTURE) 44 #if defined(ENABLE_SCREEN_CAPTURE)
44 45
45 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) 46 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID)
46 #include "content/browser/media/capture/desktop_capture_device.h" 47 #include "content/browser/media/capture/desktop_capture_device.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 std::unique_ptr<media::VideoCaptureDeviceFactory> factory) 331 std::unique_ptr<media::VideoCaptureDeviceFactory> factory)
331 : listener_(nullptr), 332 : listener_(nullptr),
332 new_capture_session_id_(1), 333 new_capture_session_id_(1),
333 video_capture_device_factory_(std::move(factory)) {} 334 video_capture_device_factory_(std::move(factory)) {}
334 335
335 VideoCaptureManager::~VideoCaptureManager() { 336 VideoCaptureManager::~VideoCaptureManager() {
336 DCHECK(devices_.empty()); 337 DCHECK(devices_.empty());
337 DCHECK(device_start_queue_.empty()); 338 DCHECK(device_start_queue_.empty());
338 } 339 }
339 340
341 void VideoCaptureManager::SetVideoCaptureObserver(
342 std::unique_ptr<media::VideoCaptureObserver> observer) {
343 capture_observer_ = std::move(observer);
344 }
345
340 void VideoCaptureManager::Register( 346 void VideoCaptureManager::Register(
341 MediaStreamProviderListener* listener, 347 MediaStreamProviderListener* listener,
342 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { 348 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) {
343 DCHECK_CURRENTLY_ON(BrowserThread::IO); 349 DCHECK_CURRENTLY_ON(BrowserThread::IO);
344 DCHECK(!listener_); 350 DCHECK(!listener_);
345 DCHECK(!device_task_runner_.get()); 351 DCHECK(!device_task_runner_.get());
346 listener_ = listener; 352 listener_ = listener;
347 device_task_runner_ = device_task_runner; 353 device_task_runner_ = device_task_runner;
348 #if defined(OS_ANDROID) 354 #if defined(OS_ANDROID)
349 application_state_has_running_activities_ = true; 355 application_state_has_running_activities_ = true;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 device_start_queue_.rbegin(); 466 device_start_queue_.rbegin();
461 request != device_start_queue_.rend(); ++request) { 467 request != device_start_queue_.rend(); ++request) {
462 if (request->serial_id() == entry->serial_id) { 468 if (request->serial_id() == entry->serial_id) {
463 request->set_abort_start(); 469 request->set_abort_start();
464 DVLOG(3) << "DoStopDevice, aborting start request for device " 470 DVLOG(3) << "DoStopDevice, aborting start request for device "
465 << entry->id << " serial_id = " << entry->serial_id; 471 << entry->id << " serial_id = " << entry->serial_id;
466 return; 472 return;
467 } 473 }
468 } 474 }
469 475
476 const DeviceInfo* device_info = GetDeviceInfoById(entry->id);
477 if (device_info != nullptr && capture_observer_.get() != nullptr) {
478 capture_observer_->OnVideoCaptureStopped(device_info->descriptor.facing);
479 }
480
470 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id 481 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id
471 << " serial_id = " << entry->serial_id << "."; 482 << " serial_id = " << entry->serial_id << ".";
472 entry->video_capture_controller.OnLog( 483 entry->video_capture_controller.OnLog(
473 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); 484 base::StringPrintf("Stopping device: id: %s", entry->id.c_str()));
474 entry->video_capture_controller.SetConsumerFeedbackObserver(nullptr); 485 entry->video_capture_controller.SetConsumerFeedbackObserver(nullptr);
475 entry->video_capture_controller.SetFrameBufferPool(nullptr); 486 entry->video_capture_controller.SetFrameBufferPool(nullptr);
476 487
477 // |entry->video_capture_device| can be null if creating the device has 488 // |entry->video_capture_device| can be null if creating the device has
478 // failed. 489 // failed.
479 if (entry->video_capture_device) { 490 if (entry->video_capture_device) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // since the renderer does not have all the information that might be 527 // since the renderer does not have all the information that might be
517 // held in the browser-side VideoCaptureDevice::Name structure. 528 // held in the browser-side VideoCaptureDevice::Name structure.
518 const DeviceInfo* found = GetDeviceInfoById(entry->id); 529 const DeviceInfo* found = GetDeviceInfoById(entry->id);
519 if (found) { 530 if (found) {
520 entry->video_capture_controller.OnLog( 531 entry->video_capture_controller.OnLog(
521 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", 532 base::StringPrintf("Starting device: id: %s, name: %s, api: %s",
522 found->descriptor.device_id.c_str(), 533 found->descriptor.device_id.c_str(),
523 found->descriptor.GetNameAndModel().c_str(), 534 found->descriptor.GetNameAndModel().c_str(),
524 found->descriptor.GetCaptureApiTypeString())); 535 found->descriptor.GetCaptureApiTypeString()));
525 536
537 if (capture_observer_.get() != nullptr) {
538 capture_observer_->OnVideoCaptureStarted(found->descriptor.facing);
539 }
540
526 start_capture_function = 541 start_capture_function =
527 base::Bind(&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, 542 base::Bind(&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread,
528 this, found->descriptor, request->params(), 543 this, found->descriptor, request->params(),
529 base::Passed(std::move(device_client))); 544 base::Passed(std::move(device_client)));
530 } else { 545 } else {
531 // Errors from DoStartDeviceCaptureOnDeviceThread go via 546 // Errors from DoStartDeviceCaptureOnDeviceThread go via
532 // VideoCaptureDeviceClient::OnError, which needs some thread 547 // VideoCaptureDeviceClient::OnError, which needs some thread
533 // dancing to get errors processed on the IO thread. But since 548 // dancing to get errors processed on the IO thread. But since
534 // we're on that thread, we call VideoCaptureController 549 // we're on that thread, we call VideoCaptureController
535 // methods directly. 550 // methods directly.
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (!device_in_queue) { 1353 if (!device_in_queue) {
1339 // Session ID is only valid for Screen capture. So we can fake it to 1354 // Session ID is only valid for Screen capture. So we can fake it to
1340 // resume video capture devices here. 1355 // resume video capture devices here.
1341 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); 1356 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters);
1342 } 1357 }
1343 } 1358 }
1344 } 1359 }
1345 #endif // defined(OS_ANDROID) 1360 #endif // defined(OS_ANDROID)
1346 1361
1347 } // namespace content 1362 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698