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

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

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perkj@s comments Created 6 years, 8 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 | Annotate | Revision Log
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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/media_device_id.h" 30 #include "content/public/browser/media_device_id.h"
31 #include "content/public/browser/media_observer.h" 31 #include "content/public/browser/media_observer.h"
32 #include "content/public/browser/media_request_state.h" 32 #include "content/public/browser/media_request_state.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/common/content_switches.h" 34 #include "content/public/common/content_switches.h"
35 #include "content/public/common/media_stream_request.h" 35 #include "content/public/common/media_stream_request.h"
36 #include "media/audio/audio_manager_base.h" 36 #include "media/audio/audio_manager_base.h"
37 #include "media/audio/audio_parameters.h" 37 #include "media/audio/audio_parameters.h"
38 #include "media/base/channel_layout.h" 38 #include "media/base/channel_layout.h"
39 #include "media/base/media_switches.h"
40 #include "media/video/capture/fake_video_capture_device_factory.h"
41 #include "media/video/capture/file_video_capture_device_factory.h"
39 #include "url/gurl.h" 42 #include "url/gurl.h"
40 43
41 #if defined(OS_WIN) 44 #if defined(OS_WIN)
42 #include "base/win/scoped_com_initializer.h" 45 #include "base/win/scoped_com_initializer.h"
43 #endif 46 #endif
44 47
45 namespace content { 48 namespace content {
46 49
47 // Forward declaration of DeviceMonitorMac and its only useable method. 50 // Forward declaration of DeviceMonitorMac and its only useable method.
48 class DeviceMonitorMac { 51 class DeviceMonitorMac {
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 1423 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
1421 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1424 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1422 if (device_task_runner_) 1425 if (device_task_runner_)
1423 return; 1426 return;
1424 1427
1425 device_task_runner_ = audio_manager_->GetWorkerTaskRunner(); 1428 device_task_runner_ = audio_manager_->GetWorkerTaskRunner();
1426 1429
1427 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); 1430 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_);
1428 audio_input_device_manager_->Register(this, device_task_runner_); 1431 audio_input_device_manager_->Register(this, device_task_runner_);
1429 1432
1430 video_capture_manager_ = new VideoCaptureManager();
1431 video_capture_manager_->Register(this, device_task_runner_);
1432
1433 // We want to be notified of IO message loop destruction to delete the thread 1433 // We want to be notified of IO message loop destruction to delete the thread
1434 // and the device managers. 1434 // and the device managers.
1435 io_loop_ = base::MessageLoop::current(); 1435 io_loop_ = base::MessageLoop::current();
1436 io_loop_->AddDestructionObserver(this); 1436 io_loop_->AddDestructionObserver(this);
1437 1437
1438 // Use a Fake Audio Device and Fake/File Video Device Factory if the command
1439 // line flags are present, otherwise use a normal device factory.
1438 if (CommandLine::ForCurrentProcess()->HasSwitch( 1440 if (CommandLine::ForCurrentProcess()->HasSwitch(
1439 switches::kUseFakeDeviceForMediaStream)) { 1441 switches::kUseFakeDeviceForMediaStream)) {
1440 DVLOG(1) << "Using fake device"; 1442 if (CommandLine::ForCurrentProcess()->HasSwitch(
1441 UseFakeDevice(); 1443 switches::kUseFileForFakeVideoCapture)) {
perkj_chrome 2014/04/17 08:39:09 indentation
mcasas 2014/04/23 06:20:28 Done.
1444 video_capture_manager_ = new VideoCaptureManager(
1445 scoped_ptr<media::VideoCaptureDeviceFactory>(
perkj_chrome 2014/04/17 08:39:09 why not just take a pointer to the factory?
mcasas 2014/04/23 06:20:28 The rest of MSM expects a scoped_ptr(), and is use
1446 new media::FileVideoCaptureDeviceFactory()));
1447 } else {
1448 video_capture_manager_ = new VideoCaptureManager(
1449 scoped_ptr<media::VideoCaptureDeviceFactory>(
1450 new media::FakeVideoCaptureDeviceFactory()));
1451 }
1452 UseFakeAudioDevice();
1453 } else {
1454 video_capture_manager_ = new VideoCaptureManager(
1455 scoped_ptr<media::VideoCaptureDeviceFactory>(
1456 new media::VideoCaptureDeviceFactory()));
1442 } 1457 }
1458 video_capture_manager_->Register(this, device_task_runner_);
1443 } 1459 }
1444 1460
1445 void MediaStreamManager::Opened(MediaStreamType stream_type, 1461 void MediaStreamManager::Opened(MediaStreamType stream_type,
1446 int capture_session_id) { 1462 int capture_session_id) {
1447 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1463 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1448 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " 1464 DVLOG(1) << "Opened({stream_type = " << stream_type << "} "
1449 << "{capture_session_id = " << capture_session_id << "})"; 1465 << "{capture_session_id = " << capture_session_id << "})";
1450 // Find the request(s) containing this device and mark it as used. 1466 // Find the request(s) containing this device and mark it as used.
1451 // It can be used in several requests since the same device can be 1467 // It can be used in several requests since the same device can be
1452 // requested from the same web page. 1468 // requested from the same web page.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 device_it != request->devices.end(); ++device_it) { 1800 device_it != request->devices.end(); ++device_it) {
1785 request->requester->DeviceStopped(request->requesting_view_id, 1801 request->requester->DeviceStopped(request->requesting_view_id,
1786 label, 1802 label,
1787 *device_it); 1803 *device_it);
1788 } 1804 }
1789 } 1805 }
1790 1806
1791 CancelRequest(label); 1807 CancelRequest(label);
1792 } 1808 }
1793 1809
1794 void MediaStreamManager::UseFakeDevice() { 1810 void MediaStreamManager::UseFakeVideoDevice(
perkj_chrome 2014/04/17 08:39:09 I think you should delete this method and in the u
mcasas 2014/04/23 06:20:28 Ok, I was actually undecided between the switch op
1811 scoped_ptr<media::VideoCaptureDeviceFactory> factory) {
1795 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1812 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1796 video_capture_manager()->UseFakeDevice(); 1813 video_capture_manager()->UseFakeDevice(factory.Pass());
1814 }
1815
1816 void MediaStreamManager::UseFakeAudioDevice() {
1817 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1797 audio_input_device_manager()->UseFakeDevice(); 1818 audio_input_device_manager()->UseFakeDevice();
perkj_chrome 2014/04/17 08:39:09 Actually - use the switch for this as well and rem
mcasas 2014/04/23 06:20:28 Done in InitializeDeviceManagersOnIOThread().
1798 } 1819 }
1799 1820
1800 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1821 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1801 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1822 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1802 use_fake_ui_ = true; 1823 use_fake_ui_ = true;
1803 fake_ui_ = fake_ui.Pass(); 1824 fake_ui_ = fake_ui.Pass();
1804 } 1825 }
1805 1826
1806 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 1827 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
1807 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()"; 1828 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()";
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 1941 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
1921 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, 1942 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id,
1922 window_id); 1943 window_id);
1923 break; 1944 break;
1924 } 1945 }
1925 } 1946 }
1926 } 1947 }
1927 } 1948 }
1928 1949
1929 } // namespace content 1950 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698