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

Side by Side Diff: content/renderer/media/user_media_client_impl.h

Issue 2380793002: Migrate MediaDevices.enumerateDevices to Mojo (Closed)
Patch Set: add missing file Created 4 years, 2 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 #ifndef CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/common/media/media_devices.h"
20 #include "content/common/media/media_devices.mojom.h"
19 #include "content/public/renderer/render_frame_observer.h" 21 #include "content/public/renderer/render_frame_observer.h"
20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" 22 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
21 #include "content/renderer/media/media_stream_source.h" 23 #include "content/renderer/media/media_stream_source.h"
24 #include "services/shell/public/cpp/interface_provider.h"
22 #include "third_party/WebKit/public/platform/WebMediaStream.h" 25 #include "third_party/WebKit/public/platform/WebMediaStream.h"
23 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 26 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
24 #include "third_party/WebKit/public/platform/WebSourceInfo.h" 27 #include "third_party/WebKit/public/platform/WebSourceInfo.h"
25 #include "third_party/WebKit/public/platform/WebVector.h" 28 #include "third_party/WebKit/public/platform/WebVector.h"
26 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" 29 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h"
27 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" 30 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h"
28 #include "third_party/WebKit/public/web/WebUserMediaClient.h" 31 #include "third_party/WebKit/public/web/WebUserMediaClient.h"
29 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" 32 #include "third_party/WebKit/public/web/WebUserMediaRequest.h"
30 33
31 namespace content { 34 namespace content {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 protected: 186 protected:
184 // These methods can be accessed in unit tests. 187 // These methods can be accessed in unit tests.
185 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id); 188 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id);
186 UserMediaRequestInfo* FindUserMediaRequestInfo( 189 UserMediaRequestInfo* FindUserMediaRequestInfo(
187 const blink::WebUserMediaRequest& request); 190 const blink::WebUserMediaRequest& request);
188 191
189 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request); 192 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request);
190 193
191 private: 194 private:
192 typedef std::vector<blink::WebMediaStreamSource> LocalStreamSources; 195 typedef std::vector<blink::WebMediaStreamSource> LocalStreamSources;
193 struct MediaDevicesRequestInfo;
194 typedef ScopedVector<MediaDevicesRequestInfo> MediaDevicesRequests;
195 196
196 // RenderFrameObserver implementation. 197 // RenderFrameObserver implementation.
197 void OnDestruct() override; 198 void OnDestruct() override;
198 199
199 // Creates a WebKit representation of stream sources based on 200 // Creates a WebKit representation of stream sources based on
200 // |devices| from the MediaStreamDispatcher. 201 // |devices| from the MediaStreamDispatcher.
201 void InitializeSourceObject( 202 void InitializeSourceObject(
202 const StreamDeviceInfo& device, 203 const StreamDeviceInfo& device,
203 blink::WebMediaStreamSource::Type type, 204 blink::WebMediaStreamSource::Type type,
204 const blink::WebMediaConstraints& constraints, 205 const blink::WebMediaConstraints& constraints,
(...skipping 15 matching lines...) Expand all
220 // underlying media sources and tracks have been created and started. 221 // underlying media sources and tracks have been created and started.
221 void OnCreateNativeTracksCompleted( 222 void OnCreateNativeTracksCompleted(
222 UserMediaRequestInfo* request, 223 UserMediaRequestInfo* request,
223 MediaStreamRequestResult result, 224 MediaStreamRequestResult result,
224 const blink::WebString& result_name); 225 const blink::WebString& result_name);
225 226
226 void OnStreamGeneratedForCancelledRequest( 227 void OnStreamGeneratedForCancelledRequest(
227 const StreamDeviceInfoArray& audio_array, 228 const StreamDeviceInfoArray& audio_array,
228 const StreamDeviceInfoArray& video_array); 229 const StreamDeviceInfoArray& video_array);
229 230
230 void FinalizeEnumerateDevices(MediaDevicesRequestInfo* request); 231 using EnumerationResult = std::vector<std::vector<MediaDeviceInfo>>;
231 void FinalizeEnumerateSources(MediaDevicesRequestInfo* request); 232 void FinalizeEnumerateDevices(blink::WebMediaDevicesRequest request,
233 const EnumerationResult& result);
234 void FinalizeGetSources(blink::WebMediaStreamTrackSourcesRequest request,
235 const EnumerationResult& result);
232 236
233 void DeleteAllUserMediaRequests(); 237 void DeleteAllUserMediaRequests();
234 238
235 MediaDevicesRequestInfo* FindMediaDevicesRequestInfo(int request_id);
236 MediaDevicesRequestInfo* FindMediaDevicesRequestInfo(
237 const blink::WebMediaDevicesRequest& request);
238 void CancelAndDeleteMediaDevicesRequest(MediaDevicesRequestInfo* request);
239
240 // Returns the source that use a device with |device.session_id| 239 // Returns the source that use a device with |device.session_id|
241 // and |device.device.id|. NULL if such source doesn't exist. 240 // and |device.device.id|. NULL if such source doesn't exist.
242 const blink::WebMediaStreamSource* FindLocalSource( 241 const blink::WebMediaStreamSource* FindLocalSource(
243 const StreamDeviceInfo& device) const; 242 const StreamDeviceInfo& device) const;
244 243
245 // Returns true if we do find and remove the |source|. 244 // Returns true if we do find and remove the |source|.
246 // Otherwise returns false. 245 // Otherwise returns false.
247 bool RemoveLocalSource(const blink::WebMediaStreamSource& source); 246 bool RemoveLocalSource(const blink::WebMediaStreamSource& source);
248 247
249 void StopLocalSource(const blink::WebMediaStreamSource& source, 248 void StopLocalSource(const blink::WebMediaStreamSource& source,
250 bool notify_dispatcher); 249 bool notify_dispatcher);
251 250
251 const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher();
252
252 // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. 253 // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread.
253 // It's valid for the lifetime of RenderThread. 254 // It's valid for the lifetime of RenderThread.
254 // TODO(xians): Remove this dependency once audio do not need it for local 255 // TODO(xians): Remove this dependency once audio do not need it for local
255 // audio. 256 // audio.
256 PeerConnectionDependencyFactory* const dependency_factory_; 257 PeerConnectionDependencyFactory* const dependency_factory_;
257 258
258 // UserMediaClientImpl owns MediaStreamDispatcher instead of RenderFrameImpl 259 // UserMediaClientImpl owns MediaStreamDispatcher instead of RenderFrameImpl
259 // (or RenderFrameObserver) to ensure tear-down occurs in the right order. 260 // (or RenderFrameObserver) to ensure tear-down occurs in the right order.
260 const std::unique_ptr<MediaStreamDispatcher> media_stream_dispatcher_; 261 const std::unique_ptr<MediaStreamDispatcher> media_stream_dispatcher_;
261 262
263 ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher_;
264
262 LocalStreamSources local_sources_; 265 LocalStreamSources local_sources_;
263 266
264 UserMediaRequests user_media_requests_; 267 UserMediaRequests user_media_requests_;
265 268
266 // Requests to enumerate media devices.
267 MediaDevicesRequests media_devices_requests_;
268
269 blink::WebMediaDeviceChangeObserver media_device_change_observer_; 269 blink::WebMediaDeviceChangeObserver media_device_change_observer_;
270 270
271 // Note: This member must be the last to ensure all outstanding weak pointers 271 // Note: This member must be the last to ensure all outstanding weak pointers
272 // are invalidated first. 272 // are invalidated first.
273 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; 273 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_;
274 274
275 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); 275 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl);
276 }; 276 };
277 277
278 } // namespace content 278 } // namespace content
279 279
280 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ 280 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698