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

Side by Side Diff: content/renderer/pepper/pepper_media_device_manager.cc

Issue 2517953003: Move enable_webrtc to a buildflag header. (Closed)
Patch Set: Fix Created 4 years 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/renderer/pepper/pepper_media_device_manager.h" 5 #include "content/renderer/pepper/pepper_media_device_manager.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "content/renderer/media/media_devices_event_dispatcher.h" 11 #include "content/renderer/media/media_devices_event_dispatcher.h"
12 #include "content/renderer/media/media_stream_dispatcher.h" 12 #include "content/renderer/media/media_stream_dispatcher.h"
13 #include "content/renderer/render_frame_impl.h" 13 #include "content/renderer/render_frame_impl.h"
14 #include "media/media_features.h"
14 #include "ppapi/shared_impl/ppb_device_ref_shared.h" 15 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
15 #include "services/service_manager/public/cpp/interface_provider.h" 16 #include "services/service_manager/public/cpp/interface_provider.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 namespace { 20 namespace {
20 21
21 PP_DeviceType_Dev FromMediaDeviceType(MediaDeviceType type) { 22 PP_DeviceType_Dev FromMediaDeviceType(MediaDeviceType type) {
22 switch (type) { 23 switch (type) {
23 case MEDIA_DEVICE_TYPE_AUDIO_INPUT: 24 case MEDIA_DEVICE_TYPE_AUDIO_INPUT:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 next_id_(1) {} 72 next_id_(1) {}
72 73
73 PepperMediaDeviceManager::~PepperMediaDeviceManager() { 74 PepperMediaDeviceManager::~PepperMediaDeviceManager() {
74 DCHECK(open_callbacks_.empty()); 75 DCHECK(open_callbacks_.empty());
75 } 76 }
76 77
77 void PepperMediaDeviceManager::EnumerateDevices( 78 void PepperMediaDeviceManager::EnumerateDevices(
78 PP_DeviceType_Dev type, 79 PP_DeviceType_Dev type,
79 const GURL& document_url, 80 const GURL& document_url,
80 const DevicesCallback& callback) { 81 const DevicesCallback& callback) {
81 #if defined(ENABLE_WEBRTC) 82 #if BUILDFLAG(ENABLE_WEBRTC)
82 bool request_audio_input = type == PP_DEVICETYPE_DEV_AUDIOCAPTURE; 83 bool request_audio_input = type == PP_DEVICETYPE_DEV_AUDIOCAPTURE;
83 bool request_video_input = type == PP_DEVICETYPE_DEV_VIDEOCAPTURE; 84 bool request_video_input = type == PP_DEVICETYPE_DEV_VIDEOCAPTURE;
84 CHECK(request_audio_input || request_video_input); 85 CHECK(request_audio_input || request_video_input);
85 GetMediaDevicesDispatcher()->EnumerateDevices( 86 GetMediaDevicesDispatcher()->EnumerateDevices(
86 request_audio_input, request_video_input, false /* audio_output */, 87 request_audio_input, request_video_input, false /* audio_output */,
87 url::Origin(document_url.GetOrigin()), 88 url::Origin(document_url.GetOrigin()),
88 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(), 89 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(),
89 callback, ToMediaDeviceType(type))); 90 callback, ToMediaDeviceType(type)));
90 #else 91 #else
91 base::ThreadTaskRunnerHandle::Get()->PostTask( 92 base::ThreadTaskRunnerHandle::Get()->PostTask(
92 FROM_HERE, 93 FROM_HERE,
93 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(), 94 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(),
94 callback, ToMediaDeviceType(type), MediaDeviceInfoArray())); 95 callback, ToMediaDeviceType(type), MediaDeviceInfoArray()));
95 #endif 96 #endif
96 } 97 }
97 98
98 uint32_t PepperMediaDeviceManager::StartMonitoringDevices( 99 uint32_t PepperMediaDeviceManager::StartMonitoringDevices(
99 PP_DeviceType_Dev type, 100 PP_DeviceType_Dev type,
100 const GURL& document_url, 101 const GURL& document_url,
101 const DevicesCallback& callback) { 102 const DevicesCallback& callback) {
102 #if defined(ENABLE_WEBRTC) 103 #if BUILDFLAG(ENABLE_WEBRTC)
103 base::WeakPtr<MediaDevicesEventDispatcher> event_dispatcher = 104 base::WeakPtr<MediaDevicesEventDispatcher> event_dispatcher =
104 MediaDevicesEventDispatcher::GetForRenderFrame(render_frame()); 105 MediaDevicesEventDispatcher::GetForRenderFrame(render_frame());
105 return event_dispatcher->SubscribeDeviceChangeNotifications( 106 return event_dispatcher->SubscribeDeviceChangeNotifications(
106 ToMediaDeviceType(type), url::Origin(document_url.GetOrigin()), 107 ToMediaDeviceType(type), url::Origin(document_url.GetOrigin()),
107 base::Bind(&PepperMediaDeviceManager::DevicesChanged, AsWeakPtr(), 108 base::Bind(&PepperMediaDeviceManager::DevicesChanged, AsWeakPtr(),
108 callback)); 109 callback));
109 #else 110 #else
110 return 0; 111 return 0;
111 #endif 112 #endif
112 } 113 }
113 114
114 void PepperMediaDeviceManager::StopMonitoringDevices(PP_DeviceType_Dev type, 115 void PepperMediaDeviceManager::StopMonitoringDevices(PP_DeviceType_Dev type,
115 uint32_t subscription_id) { 116 uint32_t subscription_id) {
116 #if defined(ENABLE_WEBRTC) 117 #if BUILDFLAG(ENABLE_WEBRTC)
117 base::WeakPtr<MediaDevicesEventDispatcher> event_dispatcher = 118 base::WeakPtr<MediaDevicesEventDispatcher> event_dispatcher =
118 MediaDevicesEventDispatcher::GetForRenderFrame(render_frame()); 119 MediaDevicesEventDispatcher::GetForRenderFrame(render_frame());
119 event_dispatcher->UnsubscribeDeviceChangeNotifications( 120 event_dispatcher->UnsubscribeDeviceChangeNotifications(
120 ToMediaDeviceType(type), subscription_id); 121 ToMediaDeviceType(type), subscription_id);
121 #endif 122 #endif
122 } 123 }
123 124
124 int PepperMediaDeviceManager::OpenDevice(PP_DeviceType_Dev type, 125 int PepperMediaDeviceManager::OpenDevice(PP_DeviceType_Dev type,
125 const std::string& device_id, 126 const std::string& device_id,
126 const GURL& document_url, 127 const GURL& document_url,
127 const OpenDeviceCallback& callback) { 128 const OpenDeviceCallback& callback) {
128 open_callbacks_[next_id_] = callback; 129 open_callbacks_[next_id_] = callback;
129 int request_id = next_id_++; 130 int request_id = next_id_++;
130 131
131 #if defined(ENABLE_WEBRTC) 132 #if BUILDFLAG(ENABLE_WEBRTC)
132 GetMediaStreamDispatcher()->OpenDevice( 133 GetMediaStreamDispatcher()->OpenDevice(
133 request_id, AsWeakPtr(), device_id, 134 request_id, AsWeakPtr(), device_id,
134 PepperMediaDeviceManager::FromPepperDeviceType(type), 135 PepperMediaDeviceManager::FromPepperDeviceType(type),
135 url::Origin(document_url.GetOrigin())); 136 url::Origin(document_url.GetOrigin()));
136 #else 137 #else
137 base::ThreadTaskRunnerHandle::Get()->PostTask( 138 base::ThreadTaskRunnerHandle::Get()->PostTask(
138 FROM_HERE, base::Bind(&PepperMediaDeviceManager::OnDeviceOpenFailed, 139 FROM_HERE, base::Bind(&PepperMediaDeviceManager::OnDeviceOpenFailed,
139 AsWeakPtr(), request_id)); 140 AsWeakPtr(), request_id));
140 #endif 141 #endif
141 142
142 return request_id; 143 return request_id;
143 } 144 }
144 145
145 void PepperMediaDeviceManager::CancelOpenDevice(int request_id) { 146 void PepperMediaDeviceManager::CancelOpenDevice(int request_id) {
146 open_callbacks_.erase(request_id); 147 open_callbacks_.erase(request_id);
147 148
148 #if defined(ENABLE_WEBRTC) 149 #if BUILDFLAG(ENABLE_WEBRTC)
149 GetMediaStreamDispatcher()->CancelOpenDevice(request_id, AsWeakPtr()); 150 GetMediaStreamDispatcher()->CancelOpenDevice(request_id, AsWeakPtr());
150 #endif 151 #endif
151 } 152 }
152 153
153 void PepperMediaDeviceManager::CloseDevice(const std::string& label) { 154 void PepperMediaDeviceManager::CloseDevice(const std::string& label) {
154 #if defined(ENABLE_WEBRTC) 155 #if BUILDFLAG(ENABLE_WEBRTC)
155 GetMediaStreamDispatcher()->CloseDevice(label); 156 GetMediaStreamDispatcher()->CloseDevice(label);
156 #endif 157 #endif
157 } 158 }
158 159
159 int PepperMediaDeviceManager::GetSessionID(PP_DeviceType_Dev type, 160 int PepperMediaDeviceManager::GetSessionID(PP_DeviceType_Dev type,
160 const std::string& label) { 161 const std::string& label) {
161 #if defined(ENABLE_WEBRTC) 162 #if BUILDFLAG(ENABLE_WEBRTC)
162 switch (type) { 163 switch (type) {
163 case PP_DEVICETYPE_DEV_AUDIOCAPTURE: 164 case PP_DEVICETYPE_DEV_AUDIOCAPTURE:
164 return GetMediaStreamDispatcher()->audio_session_id(label, 0); 165 return GetMediaStreamDispatcher()->audio_session_id(label, 0);
165 case PP_DEVICETYPE_DEV_VIDEOCAPTURE: 166 case PP_DEVICETYPE_DEV_VIDEOCAPTURE:
166 return GetMediaStreamDispatcher()->video_session_id(label, 0); 167 return GetMediaStreamDispatcher()->video_session_id(label, 0);
167 default: 168 default:
168 NOTREACHED(); 169 NOTREACHED();
169 return 0; 170 return 0;
170 } 171 }
171 #else 172 #else
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 267 }
267 268
268 return media_devices_dispatcher_; 269 return media_devices_dispatcher_;
269 } 270 }
270 271
271 void PepperMediaDeviceManager::OnDestruct() { 272 void PepperMediaDeviceManager::OnDestruct() {
272 delete this; 273 delete this;
273 } 274 }
274 275
275 } // namespace content 276 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/content_renderer_pepper_host_factory.cc ('k') | content/renderer/pepper/resource_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698