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

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: 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 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 1433 video_capture_manager_ = new VideoCaptureManager();
1431 video_capture_manager_->Register(this, device_task_runner_); 1434 video_capture_manager_->Register(this, device_task_runner_);
1432 1435
1433 // 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
1434 // and the device managers. 1437 // and the device managers.
1435 io_loop_ = base::MessageLoop::current(); 1438 io_loop_ = base::MessageLoop::current();
1436 io_loop_->AddDestructionObserver(this); 1439 io_loop_->AddDestructionObserver(this);
1437 1440
1441 // Use a Fake Audio/Video Device if the command line flags are present.
1438 if (CommandLine::ForCurrentProcess()->HasSwitch( 1442 if (CommandLine::ForCurrentProcess()->HasSwitch(
1439 switches::kUseFakeDeviceForMediaStream)) { 1443 switches::kUseFakeDeviceForMediaStream)) {
1440 DVLOG(1) << "Using fake device"; 1444 if (CommandLine::ForCurrentProcess()->HasSwitch(
1441 UseFakeDevice(); 1445 switches::kUseFileForFakeVideoCapture)) {
1446 UseFakeVideoDevice(scoped_ptr<media::VideoCaptureDeviceFactory>(
1447 new media::FileVideoCaptureDeviceFactory()));
1448 } else {
1449 UseFakeVideoDevice(scoped_ptr<media::VideoCaptureDeviceFactory>(
1450 new media::FakeVideoCaptureDeviceFactory()));
1451 }
1452 UseFakeAudioDevice();
1442 } 1453 }
1443 } 1454 }
1444 1455
1445 void MediaStreamManager::Opened(MediaStreamType stream_type, 1456 void MediaStreamManager::Opened(MediaStreamType stream_type,
1446 int capture_session_id) { 1457 int capture_session_id) {
1447 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1458 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1448 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " 1459 DVLOG(1) << "Opened({stream_type = " << stream_type << "} "
1449 << "{capture_session_id = " << capture_session_id << "})"; 1460 << "{capture_session_id = " << capture_session_id << "})";
1450 // Find the request(s) containing this device and mark it as used. 1461 // 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 1462 // It can be used in several requests since the same device can be
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 device_it != request->devices.end(); ++device_it) { 1795 device_it != request->devices.end(); ++device_it) {
1785 request->requester->DeviceStopped(request->requesting_view_id, 1796 request->requester->DeviceStopped(request->requesting_view_id,
1786 label, 1797 label,
1787 *device_it); 1798 *device_it);
1788 } 1799 }
1789 } 1800 }
1790 1801
1791 CancelRequest(label); 1802 CancelRequest(label);
1792 } 1803 }
1793 1804
1794 void MediaStreamManager::UseFakeDevice() { 1805 void MediaStreamManager::UseFakeVideoDevice(
1806 scoped_ptr<media::VideoCaptureDeviceFactory> factory) {
1795 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1807 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1796 video_capture_manager()->UseFakeDevice(); 1808 video_capture_manager()->UseFakeDevice(factory.Pass());
1809 }
1810
1811 void MediaStreamManager::UseFakeAudioDevice() {
1812 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1797 audio_input_device_manager()->UseFakeDevice(); 1813 audio_input_device_manager()->UseFakeDevice();
1798 } 1814 }
1799 1815
1800 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1816 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1801 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1817 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1802 use_fake_ui_ = true; 1818 use_fake_ui_ = true;
1803 fake_ui_ = fake_ui.Pass(); 1819 fake_ui_ = fake_ui.Pass();
1804 } 1820 }
1805 1821
1806 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 1822 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 1936 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
1921 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, 1937 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id,
1922 window_id); 1938 window_id);
1923 break; 1939 break;
1924 } 1940 }
1925 } 1941 }
1926 } 1942 }
1927 } 1943 }
1928 1944
1929 } // namespace content 1945 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698