 Chromium Code Reviews
 Chromium Code Reviews Issue 2634263002:
  Pass camera facing info to audio client  (Closed)
    
  
    Issue 2634263002:
  Pass camera facing info to audio client  (Closed) 
  | 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/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 Loading... | |
| 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 Loading... | |
| 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::AddVideoCaptureObserver( | |
| 342 media::VideoCaptureObserver* observer) { | |
| 343 if (observer != nullptr) | |
| 
jennyz
2017/02/09 19:42:55
client code is not supposed to call this function
 
shenghao
2017/02/09 22:32:51
Done.
 | |
| 344 capture_observers_.push_back(observer); | |
| 345 } | |
| 346 | |
| 347 void VideoCaptureManager::RemoveAllVideoCaptureObservers() { | |
| 348 capture_observers_.clear(); | |
| 349 } | |
| 350 | |
| 340 void VideoCaptureManager::Register( | 351 void VideoCaptureManager::Register( | 
| 341 MediaStreamProviderListener* listener, | 352 MediaStreamProviderListener* listener, | 
| 342 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | 353 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | 
| 343 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 354 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| 344 DCHECK(!listener_); | 355 DCHECK(!listener_); | 
| 345 DCHECK(!device_task_runner_.get()); | 356 DCHECK(!device_task_runner_.get()); | 
| 346 listener_ = listener; | 357 listener_ = listener; | 
| 347 device_task_runner_ = device_task_runner; | 358 device_task_runner_ = device_task_runner; | 
| 348 #if defined(OS_ANDROID) | 359 #if defined(OS_ANDROID) | 
| 349 application_state_has_running_activities_ = true; | 360 application_state_has_running_activities_ = true; | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 device_start_queue_.rbegin(); | 471 device_start_queue_.rbegin(); | 
| 461 request != device_start_queue_.rend(); ++request) { | 472 request != device_start_queue_.rend(); ++request) { | 
| 462 if (request->serial_id() == entry->serial_id) { | 473 if (request->serial_id() == entry->serial_id) { | 
| 463 request->set_abort_start(); | 474 request->set_abort_start(); | 
| 464 DVLOG(3) << "DoStopDevice, aborting start request for device " | 475 DVLOG(3) << "DoStopDevice, aborting start request for device " | 
| 465 << entry->id << " serial_id = " << entry->serial_id; | 476 << entry->id << " serial_id = " << entry->serial_id; | 
| 466 return; | 477 return; | 
| 467 } | 478 } | 
| 468 } | 479 } | 
| 469 | 480 | 
| 481 const DeviceInfo* device_info = GetDeviceInfoById(entry->id); | |
| 482 if (device_info != nullptr) { | |
| 483 for (auto& observer : capture_observers_) | |
| 484 observer->OnVideoCaptureStopped(device_info->descriptor.facing); | |
| 485 } | |
| 486 | |
| 470 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id | 487 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id | 
| 471 << " serial_id = " << entry->serial_id << "."; | 488 << " serial_id = " << entry->serial_id << "."; | 
| 472 entry->video_capture_controller.OnLog( | 489 entry->video_capture_controller.OnLog( | 
| 473 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); | 490 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); | 
| 474 entry->video_capture_controller.SetConsumerFeedbackObserver(nullptr); | 491 entry->video_capture_controller.SetConsumerFeedbackObserver(nullptr); | 
| 475 entry->video_capture_controller.SetFrameBufferPool(nullptr); | 492 entry->video_capture_controller.SetFrameBufferPool(nullptr); | 
| 476 | 493 | 
| 477 // |entry->video_capture_device| can be null if creating the device has | 494 // |entry->video_capture_device| can be null if creating the device has | 
| 478 // failed. | 495 // failed. | 
| 479 if (entry->video_capture_device) { | 496 if (entry->video_capture_device) { | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 // since the renderer does not have all the information that might be | 533 // since the renderer does not have all the information that might be | 
| 517 // held in the browser-side VideoCaptureDevice::Name structure. | 534 // held in the browser-side VideoCaptureDevice::Name structure. | 
| 518 const DeviceInfo* found = GetDeviceInfoById(entry->id); | 535 const DeviceInfo* found = GetDeviceInfoById(entry->id); | 
| 519 if (found) { | 536 if (found) { | 
| 520 entry->video_capture_controller.OnLog( | 537 entry->video_capture_controller.OnLog( | 
| 521 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", | 538 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", | 
| 522 found->descriptor.device_id.c_str(), | 539 found->descriptor.device_id.c_str(), | 
| 523 found->descriptor.GetNameAndModel().c_str(), | 540 found->descriptor.GetNameAndModel().c_str(), | 
| 524 found->descriptor.GetCaptureApiTypeString())); | 541 found->descriptor.GetCaptureApiTypeString())); | 
| 525 | 542 | 
| 543 for (auto& observer : capture_observers_) | |
| 544 observer->OnVideoCaptureStarted(found->descriptor.facing); | |
| 545 | |
| 526 start_capture_function = | 546 start_capture_function = | 
| 527 base::Bind(&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, | 547 base::Bind(&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, | 
| 528 this, found->descriptor, request->params(), | 548 this, found->descriptor, request->params(), | 
| 529 base::Passed(std::move(device_client))); | 549 base::Passed(std::move(device_client))); | 
| 530 } else { | 550 } else { | 
| 531 // Errors from DoStartDeviceCaptureOnDeviceThread go via | 551 // Errors from DoStartDeviceCaptureOnDeviceThread go via | 
| 532 // VideoCaptureDeviceClient::OnError, which needs some thread | 552 // VideoCaptureDeviceClient::OnError, which needs some thread | 
| 533 // dancing to get errors processed on the IO thread. But since | 553 // dancing to get errors processed on the IO thread. But since | 
| 534 // we're on that thread, we call VideoCaptureController | 554 // we're on that thread, we call VideoCaptureController | 
| 535 // methods directly. | 555 // methods directly. | 
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 if (!device_in_queue) { | 1358 if (!device_in_queue) { | 
| 1339 // Session ID is only valid for Screen capture. So we can fake it to | 1359 // Session ID is only valid for Screen capture. So we can fake it to | 
| 1340 // resume video capture devices here. | 1360 // resume video capture devices here. | 
| 1341 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1361 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 
| 1342 } | 1362 } | 
| 1343 } | 1363 } | 
| 1344 } | 1364 } | 
| 1345 #endif // defined(OS_ANDROID) | 1365 #endif // defined(OS_ANDROID) | 
| 1346 | 1366 | 
| 1347 } // namespace content | 1367 } // namespace content | 
| OLD | NEW |