| OLD | NEW | 
|    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" |   19 #include "content/common/media/media_devices.h" | 
|   20 #include "content/common/media/media_devices.mojom.h" |   20 #include "content/common/media/media_devices.mojom.h" | 
|   21 #include "content/public/renderer/render_frame_observer.h" |   21 #include "content/public/renderer/render_frame_observer.h" | 
 |   22 #include "content/renderer/media/media_devices_event_dispatcher.h" | 
|   22 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |   23 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 
|   23 #include "content/renderer/media/media_stream_source.h" |   24 #include "content/renderer/media/media_stream_source.h" | 
|   24 #include "services/service_manager/public/cpp/interface_provider.h" |   25 #include "services/service_manager/public/cpp/interface_provider.h" | 
|   25 #include "third_party/WebKit/public/platform/WebMediaStream.h" |   26 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 
|   26 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |   27 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 
|   27 #include "third_party/WebKit/public/platform/WebVector.h" |   28 #include "third_party/WebKit/public/platform/WebVector.h" | 
|   28 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" |   29 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" | 
|   29 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |   30 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 
|   30 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |   31 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 
|   31 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |   32 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  217   // underlying media sources and tracks have been created and started. |  218   // underlying media sources and tracks have been created and started. | 
|  218   void OnCreateNativeTracksCompleted( |  219   void OnCreateNativeTracksCompleted( | 
|  219       UserMediaRequestInfo* request, |  220       UserMediaRequestInfo* request, | 
|  220       MediaStreamRequestResult result, |  221       MediaStreamRequestResult result, | 
|  221       const blink::WebString& result_name); |  222       const blink::WebString& result_name); | 
|  222  |  223  | 
|  223   void OnStreamGeneratedForCancelledRequest( |  224   void OnStreamGeneratedForCancelledRequest( | 
|  224       const StreamDeviceInfoArray& audio_array, |  225       const StreamDeviceInfoArray& audio_array, | 
|  225       const StreamDeviceInfoArray& video_array); |  226       const StreamDeviceInfoArray& video_array); | 
|  226  |  227  | 
|  227   using EnumerationResult = std::vector<std::vector<MediaDeviceInfo>>; |  228   using EnumerationResult = std::vector<MediaDeviceInfoArray>; | 
|  228   void FinalizeEnumerateDevices(blink::WebMediaDevicesRequest request, |  229   void FinalizeEnumerateDevices(blink::WebMediaDevicesRequest request, | 
|  229                                 const EnumerationResult& result); |  230                                 const EnumerationResult& result); | 
|  230  |  231  | 
|  231   void DeleteAllUserMediaRequests(); |  232   void DeleteAllUserMediaRequests(); | 
|  232  |  233  | 
|  233   // Returns the source that use a device with |device.session_id| |  234   // Returns the source that use a device with |device.session_id| | 
|  234   // and |device.device.id|. NULL if such source doesn't exist. |  235   // and |device.device.id|. NULL if such source doesn't exist. | 
|  235   const blink::WebMediaStreamSource* FindLocalSource( |  236   const blink::WebMediaStreamSource* FindLocalSource( | 
|  236       const StreamDeviceInfo& device) const; |  237       const StreamDeviceInfo& device) const; | 
|  237  |  238  | 
|  238   // Returns true if we do find and remove the |source|. |  239   // Returns true if we do find and remove the |source|. | 
|  239   // Otherwise returns false. |  240   // Otherwise returns false. | 
|  240   bool RemoveLocalSource(const blink::WebMediaStreamSource& source); |  241   bool RemoveLocalSource(const blink::WebMediaStreamSource& source); | 
|  241  |  242  | 
|  242   void StopLocalSource(const blink::WebMediaStreamSource& source, |  243   void StopLocalSource(const blink::WebMediaStreamSource& source, | 
|  243                        bool notify_dispatcher); |  244                        bool notify_dispatcher); | 
|  244  |  245  | 
|  245   const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher(); |  246   const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher(); | 
|  246  |  247  | 
 |  248   // Callback invoked by MediaDevicesEventDispatcher when a device-change | 
 |  249   // notification arrives. | 
 |  250   void DevicesChanged(MediaDeviceType device_type, | 
 |  251                       const MediaDeviceInfoArray& device_infos); | 
 |  252  | 
|  247   // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. |  253   // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. | 
|  248   // It's valid for the lifetime of RenderThread. |  254   // It's valid for the lifetime of RenderThread. | 
|  249   // 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 | 
|  250   // audio. |  256   // audio. | 
|  251   PeerConnectionDependencyFactory* const dependency_factory_; |  257   PeerConnectionDependencyFactory* const dependency_factory_; | 
|  252  |  258  | 
|  253   // UserMediaClientImpl owns MediaStreamDispatcher instead of RenderFrameImpl |  259   // UserMediaClientImpl owns MediaStreamDispatcher instead of RenderFrameImpl | 
|  254   // (or RenderFrameObserver) to ensure tear-down occurs in the right order. |  260   // (or RenderFrameObserver) to ensure tear-down occurs in the right order. | 
|  255   const std::unique_ptr<MediaStreamDispatcher> media_stream_dispatcher_; |  261   const std::unique_ptr<MediaStreamDispatcher> media_stream_dispatcher_; | 
|  256  |  262  | 
|  257   ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher_; |  263   ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher_; | 
|  258  |  264  | 
|  259   LocalStreamSources local_sources_; |  265   LocalStreamSources local_sources_; | 
|  260  |  266  | 
|  261   UserMediaRequests user_media_requests_; |  267   UserMediaRequests user_media_requests_; | 
 |  268   MediaDevicesEventDispatcher::SubscriptionIdList | 
 |  269       device_change_subscription_ids_; | 
|  262  |  270  | 
|  263   blink::WebMediaDeviceChangeObserver media_device_change_observer_; |  271   blink::WebMediaDeviceChangeObserver media_device_change_observer_; | 
|  264  |  272  | 
|  265   // Note: This member must be the last to ensure all outstanding weak pointers |  273   // Note: This member must be the last to ensure all outstanding weak pointers | 
|  266   // are invalidated first. |  274   // are invalidated first. | 
|  267   base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; |  275   base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; | 
|  268  |  276  | 
|  269   DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); |  277   DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); | 
|  270 }; |  278 }; | 
|  271  |  279  | 
|  272 }  // namespace content |  280 }  // namespace content | 
|  273  |  281  | 
|  274 #endif  // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ |  282 #endif  // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ | 
| OLD | NEW |