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

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: tommi@s comments. FakeVCD PopulateFormatRoster() removed, the list comes from unit tests. 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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 1426 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
1424 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1427 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1425 if (device_task_runner_) 1428 if (device_task_runner_)
1426 return; 1429 return;
1427 1430
1428 device_task_runner_ = audio_manager_->GetWorkerTaskRunner(); 1431 device_task_runner_ = audio_manager_->GetWorkerTaskRunner();
1429 1432
1430 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); 1433 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_);
1431 audio_input_device_manager_->Register(this, device_task_runner_); 1434 audio_input_device_manager_->Register(this, device_task_runner_);
1432 1435
1433 video_capture_manager_ = new VideoCaptureManager();
1434 video_capture_manager_->Register(this, device_task_runner_);
1435
1436 // We want to be notified of IO message loop destruction to delete the thread 1436 // We want to be notified of IO message loop destruction to delete the thread
1437 // and the device managers. 1437 // and the device managers.
1438 io_loop_ = base::MessageLoop::current(); 1438 io_loop_ = base::MessageLoop::current();
1439 io_loop_->AddDestructionObserver(this); 1439 io_loop_->AddDestructionObserver(this);
1440 1440
1441 // Use a Fake Audio Device and Fake/File Video Device Factory if the command
1442 // line flags are present, otherwise use a normal device factory.
1441 if (CommandLine::ForCurrentProcess()->HasSwitch( 1443 if (CommandLine::ForCurrentProcess()->HasSwitch(
1442 switches::kUseFakeDeviceForMediaStream)) { 1444 switches::kUseFakeDeviceForMediaStream)) {
1443 DVLOG(1) << "Using fake device"; 1445 if (CommandLine::ForCurrentProcess()->HasSwitch(
perkj_chrome 2014/04/24 14:43:32 So to use kUseFileForFakeVideoCapture you also hav
mcasas 2014/04/24 20:20:26 Yes, it was indicated by fischman@.
1444 UseFakeDevice(); 1446 switches::kUseFileForFakeVideoCapture)) {
1447 video_capture_manager_ = new VideoCaptureManager(
1448 scoped_ptr<media::VideoCaptureDeviceFactory>(
1449 new media::FileVideoCaptureDeviceFactory()));
1450 } else {
1451 video_capture_manager_ = new VideoCaptureManager(
1452 scoped_ptr<media::VideoCaptureDeviceFactory>(
1453 new media::FakeVideoCaptureDeviceFactory()));
1454 }
1455 audio_input_device_manager()->UseFakeDevice();
1456 } else {
1457 video_capture_manager_ = new VideoCaptureManager(
1458 scoped_ptr<media::VideoCaptureDeviceFactory>(
perkj_chrome 2014/04/24 14:43:32 nit:indentation
mcasas 2014/04/24 20:20:26 Done.
1459 new media::VideoCaptureDeviceFactory()));
1445 } 1460 }
1461 video_capture_manager_->Register(this, device_task_runner_);
1446 } 1462 }
1447 1463
1448 void MediaStreamManager::Opened(MediaStreamType stream_type, 1464 void MediaStreamManager::Opened(MediaStreamType stream_type,
1449 int capture_session_id) { 1465 int capture_session_id) {
1450 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1466 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1451 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " 1467 DVLOG(1) << "Opened({stream_type = " << stream_type << "} "
1452 << "{capture_session_id = " << capture_session_id << "})"; 1468 << "{capture_session_id = " << capture_session_id << "})";
1453 // Find the request(s) containing this device and mark it as used. 1469 // Find the request(s) containing this device and mark it as used.
1454 // It can be used in several requests since the same device can be 1470 // It can be used in several requests since the same device can be
1455 // requested from the same web page. 1471 // requested from the same web page.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 device_it != request->devices.end(); ++device_it) { 1803 device_it != request->devices.end(); ++device_it) {
1788 request->requester->DeviceStopped(request->requesting_view_id, 1804 request->requester->DeviceStopped(request->requesting_view_id,
1789 label, 1805 label,
1790 *device_it); 1806 *device_it);
1791 } 1807 }
1792 } 1808 }
1793 1809
1794 CancelRequest(label); 1810 CancelRequest(label);
1795 } 1811 }
1796 1812
1797 void MediaStreamManager::UseFakeDevice() {
1798 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1799 video_capture_manager()->UseFakeDevice();
1800 audio_input_device_manager()->UseFakeDevice();
1801 }
1802
1803 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1813 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1804 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1814 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1805 use_fake_ui_ = true; 1815 use_fake_ui_ = true;
1806 fake_ui_ = fake_ui.Pass(); 1816 fake_ui_ = fake_ui.Pass();
1807 } 1817 }
1808 1818
1809 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 1819 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
1810 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()"; 1820 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()";
1811 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 1821 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
1812 DCHECK(requests_.empty()); 1822 DCHECK(requests_.empty());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 1933 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
1924 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, 1934 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id,
1925 window_id); 1935 window_id);
1926 break; 1936 break;
1927 } 1937 }
1928 } 1938 }
1929 } 1939 }
1930 } 1940 }
1931 1941
1932 } // namespace content 1942 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698