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

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

Issue 2805533002: Reland [Mojo Video Capture] Introduce abstraction VideoCaptureSystem (Closed)
Patch Set: Fix race condition in tests Created 3 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "content/public/browser/web_contents_media_capture_id.h" 42 #include "content/public/browser/web_contents_media_capture_id.h"
43 #include "content/public/common/content_client.h" 43 #include "content/public/common/content_client.h"
44 #include "content/public/common/content_switches.h" 44 #include "content/public/common/content_switches.h"
45 #include "content/public/common/media_stream_request.h" 45 #include "content/public/common/media_stream_request.h"
46 #include "crypto/hmac.h" 46 #include "crypto/hmac.h"
47 #include "media/audio/audio_device_description.h" 47 #include "media/audio/audio_device_description.h"
48 #include "media/audio/audio_system.h" 48 #include "media/audio/audio_system.h"
49 #include "media/base/audio_parameters.h" 49 #include "media/base/audio_parameters.h"
50 #include "media/base/channel_layout.h" 50 #include "media/base/channel_layout.h"
51 #include "media/base/media_switches.h" 51 #include "media/base/media_switches.h"
52 #include "media/capture/video/video_capture_device_factory.h" 52 #include "media/capture/video/video_capture_system.h"
53 #include "url/gurl.h" 53 #include "url/gurl.h"
54 #include "url/origin.h" 54 #include "url/origin.h"
55 55
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 #include "base/win/scoped_com_initializer.h" 57 #include "base/win/scoped_com_initializer.h"
58 #endif 58 #endif
59 59
60 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
61 #include "chromeos/audio/cras_audio_handler.h" 61 #include "chromeos/audio/cras_audio_handler.h"
62 #endif 62 #endif
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 3")); 1246 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 3"));
1247 // We want to be notified of IO message loop destruction to delete the thread 1247 // We want to be notified of IO message loop destruction to delete the thread
1248 // and the device managers. 1248 // and the device managers.
1249 base::MessageLoop::current()->AddDestructionObserver(this); 1249 base::MessageLoop::current()->AddDestructionObserver(this);
1250 1250
1251 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is 1251 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is
1252 // fixed. 1252 // fixed.
1253 tracked_objects::ScopedTracker tracking_profile4( 1253 tracked_objects::ScopedTracker tracking_profile4(
1254 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1254 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1255 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 4")); 1255 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 4"));
1256 auto video_capture_system = base::MakeUnique<media::VideoCaptureSystem>(
1257 media::VideoCaptureDeviceFactory::CreateFactory(
1258 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)));
1256 #if defined(OS_WIN) 1259 #if defined(OS_WIN)
1257 // Use an STA Video Capture Thread to try to avoid crashes on enumeration of 1260 // Use an STA Video Capture Thread to try to avoid crashes on enumeration of
1258 // buggy third party Direct Show modules, http://crbug.com/428958. 1261 // buggy third party Direct Show modules, http://crbug.com/428958.
1259 video_capture_thread_.init_com_with_mta(false); 1262 video_capture_thread_.init_com_with_mta(false);
1260 CHECK(video_capture_thread_.Start()); 1263 CHECK(video_capture_thread_.Start());
1261 video_capture_manager_ = new VideoCaptureManager( 1264 video_capture_manager_ = new VideoCaptureManager(
1262 media::VideoCaptureDeviceFactory::CreateFactory( 1265 std::move(video_capture_system), video_capture_thread_.task_runner());
1263 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)),
1264 video_capture_thread_.task_runner());
1265 #else 1266 #else
1266 video_capture_manager_ = new VideoCaptureManager( 1267 video_capture_manager_ = new VideoCaptureManager(
1267 media::VideoCaptureDeviceFactory::CreateFactory( 1268 std::move(video_capture_system), audio_system_->GetTaskRunner());
1268 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)),
1269 audio_system_->GetTaskRunner());
1270 #endif 1269 #endif
1271 1270
1272 video_capture_manager_->RegisterListener(this); 1271 video_capture_manager_->RegisterListener(this);
1273 1272
1274 media_devices_manager_.reset( 1273 media_devices_manager_.reset(
1275 new MediaDevicesManager(audio_system_, video_capture_manager_, this)); 1274 new MediaDevicesManager(audio_system_, video_capture_manager_, this));
1276 } 1275 }
1277 1276
1278 void MediaStreamManager::Opened(MediaStreamType stream_type, 1277 void MediaStreamManager::Opened(MediaStreamType stream_type,
1279 int capture_session_id) { 1278 int capture_session_id) {
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } 1727 }
1729 } 1728 }
1730 } 1729 }
1731 } 1730 }
1732 1731
1733 void MediaStreamManager::SetGenerateStreamCallbackForTesting( 1732 void MediaStreamManager::SetGenerateStreamCallbackForTesting(
1734 GenerateStreamTestCallback test_callback) { 1733 GenerateStreamTestCallback test_callback) {
1735 generate_stream_test_callback_ = test_callback; 1734 generate_stream_test_callback_ = test_callback;
1736 } 1735 }
1737 1736
1738 #if defined(OS_WIN)
1739 void MediaStreamManager::FlushVideoCaptureThreadForTesting() {
1740 video_capture_thread_.FlushForTesting();
1741 }
1742 #endif
1743
1744 MediaStreamDevices MediaStreamManager::ConvertToMediaStreamDevices( 1737 MediaStreamDevices MediaStreamManager::ConvertToMediaStreamDevices(
1745 MediaStreamType stream_type, 1738 MediaStreamType stream_type,
1746 const MediaDeviceInfoArray& device_infos) { 1739 const MediaDeviceInfoArray& device_infos) {
1747 MediaStreamDevices devices; 1740 MediaStreamDevices devices;
1748 for (const auto& info : device_infos) 1741 for (const auto& info : device_infos)
1749 devices.emplace_back(stream_type, info.device_id, info.label, 1742 devices.emplace_back(stream_type, info.device_id, info.label,
1750 info.video_facing); 1743 info.video_facing);
1751 1744
1752 if (stream_type != MEDIA_DEVICE_VIDEO_CAPTURE) 1745 if (stream_type != MEDIA_DEVICE_VIDEO_CAPTURE)
1753 return devices; 1746 return devices;
(...skipping 14 matching lines...) Expand all
1768 request->ui_proxy->OnStarted( 1761 request->ui_proxy->OnStarted(
1769 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, 1762 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser,
1770 base::Unretained(this), label), 1763 base::Unretained(this), label),
1771 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId, 1764 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId,
1772 base::Unretained(this), request->video_type(), 1765 base::Unretained(this), request->video_type(),
1773 request->devices)); 1766 request->devices));
1774 } 1767 }
1775 } 1768 }
1776 1769
1777 } // namespace content 1770 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698