| 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 <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" | 30 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" |
| 31 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 31 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
| 32 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 32 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
| 33 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 33 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| 34 | 34 |
| 35 namespace base { | 35 namespace base { |
| 36 class TaskRunner; | 36 class TaskRunner; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace content { | 39 namespace content { |
| 40 class PeerConnectionDependencyFactory; | 40 class AudioCaptureSettings; |
| 41 class MediaStreamAudioSource; | 41 class MediaStreamAudioSource; |
| 42 class MediaStreamDispatcher; | 42 class MediaStreamDispatcher; |
| 43 class MediaStreamVideoSource; | 43 class MediaStreamVideoSource; |
| 44 class PeerConnectionDependencyFactory; |
| 44 class VideoCaptureSettings; | 45 class VideoCaptureSettings; |
| 45 | 46 |
| 46 // UserMediaClientImpl is a delegate for the Media Stream GetUserMedia API. | 47 // UserMediaClientImpl is a delegate for the Media Stream GetUserMedia API. |
| 47 // It ties together WebKit and MediaStreamManager | 48 // It ties together WebKit and MediaStreamManager |
| 48 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 49 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
| 49 // in the browser process. It must be created, called and destroyed on the | 50 // in the browser process. It must be created, called and destroyed on the |
| 50 // render thread. | 51 // render thread. |
| 51 class CONTENT_EXPORT UserMediaClientImpl | 52 class CONTENT_EXPORT UserMediaClientImpl |
| 52 : public RenderFrameObserver, | 53 : public RenderFrameObserver, |
| 53 NON_EXPORTED_BASE(public blink::WebUserMediaClient), | 54 NON_EXPORTED_BASE(public blink::WebUserMediaClient), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 95 |
| 95 void SetMediaDevicesDispatcherForTesting( | 96 void SetMediaDevicesDispatcherForTesting( |
| 96 ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher); | 97 ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher); |
| 97 | 98 |
| 98 protected: | 99 protected: |
| 99 // These methods are virtual for test purposes. A test can override them to | 100 // These methods are virtual for test purposes. A test can override them to |
| 100 // test requesting local media streams. The function notifies WebKit that the | 101 // test requesting local media streams. The function notifies WebKit that the |
| 101 // |request| have completed. | 102 // |request| have completed. |
| 102 virtual void GetUserMediaRequestSucceeded(const blink::WebMediaStream& stream, | 103 virtual void GetUserMediaRequestSucceeded(const blink::WebMediaStream& stream, |
| 103 blink::WebUserMediaRequest request); | 104 blink::WebUserMediaRequest request); |
| 104 virtual void GetUserMediaRequestFailed(blink::WebUserMediaRequest request, | 105 virtual void GetUserMediaRequestFailed(MediaStreamRequestResult result, |
| 105 MediaStreamRequestResult result, | |
| 106 const blink::WebString& result_name); | 106 const blink::WebString& result_name); |
| 107 | 107 |
| 108 virtual void EnumerateDevicesSucceded( | 108 virtual void EnumerateDevicesSucceded( |
| 109 blink::WebMediaDevicesRequest* request, | 109 blink::WebMediaDevicesRequest* request, |
| 110 blink::WebVector<blink::WebMediaDeviceInfo>& devices); | 110 blink::WebVector<blink::WebMediaDeviceInfo>& devices); |
| 111 | 111 |
| 112 // Creates a MediaStreamAudioSource/MediaStreamVideoSource objects. | 112 // Creates a MediaStreamAudioSource/MediaStreamVideoSource objects. |
| 113 // These are virtual for test purposes. | 113 // These are virtual for test purposes. |
| 114 virtual MediaStreamAudioSource* CreateAudioSource( | 114 virtual MediaStreamAudioSource* CreateAudioSource( |
| 115 const StreamDeviceInfo& device, | 115 const StreamDeviceInfo& device, |
| 116 const blink::WebMediaConstraints& constraints, | 116 const blink::WebMediaConstraints& constraints, |
| 117 const MediaStreamSource::ConstraintsCallback& source_ready); | 117 const MediaStreamSource::ConstraintsCallback& source_ready); |
| 118 virtual MediaStreamVideoSource* CreateVideoSource( | 118 virtual MediaStreamVideoSource* CreateVideoSource( |
| 119 const StreamDeviceInfo& device, | 119 const StreamDeviceInfo& device, |
| 120 const MediaStreamSource::SourceStoppedCallback& stop_callback); | 120 const MediaStreamSource::SourceStoppedCallback& stop_callback); |
| 121 | 121 |
| 122 // Returns no value if there is no request being processed. Use only for | 122 // Returns no value if there is no request being processed. Use only for |
| 123 // testing. | 123 // testing. |
| 124 // TODO(guidou): Remove this method once spec-compliant constraints algorithm | 124 // TODO(guidou): Remove this function. http://crbug.com/706408 |
| 125 // for audio is implemented. http://crbug.com/543997 | |
| 126 base::Optional<bool> AutomaticOutputDeviceSelectionEnabledForCurrentRequest(); | 125 base::Optional<bool> AutomaticOutputDeviceSelectionEnabledForCurrentRequest(); |
| 127 | 126 |
| 127 // Intended to be used only for testing. |
| 128 const AudioCaptureSettings& AudioCaptureSettingsForTesting() const; |
| 129 const VideoCaptureSettings& VideoCaptureSettingsForTesting() const; |
| 130 |
| 128 private: | 131 private: |
| 129 class UserMediaRequestInfo; | 132 class UserMediaRequestInfo; |
| 130 typedef std::vector<blink::WebMediaStreamSource> LocalStreamSources; | 133 typedef std::vector<blink::WebMediaStreamSource> LocalStreamSources; |
| 131 | 134 |
| 132 void MaybeProcessNextRequestInfo(); | 135 void MaybeProcessNextRequestInfo(); |
| 133 bool IsCurrentRequestInfo(int request_id) const; | 136 bool IsCurrentRequestInfo(int request_id) const; |
| 134 bool IsCurrentRequestInfo(const blink::WebUserMediaRequest& request) const; | 137 bool IsCurrentRequestInfo(const blink::WebUserMediaRequest& request) const; |
| 135 bool DeleteRequestInfo(const blink::WebUserMediaRequest& request); | 138 bool DeleteRequestInfo(const blink::WebUserMediaRequest& request); |
| 136 void DelayedGetUserMediaRequestSucceeded(const blink::WebMediaStream& stream, | 139 void DelayedGetUserMediaRequestSucceeded(const blink::WebMediaStream& stream, |
| 137 blink::WebUserMediaRequest request); | 140 blink::WebUserMediaRequest request); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 221 |
| 219 // Returns true if we do find and remove the |source|. | 222 // Returns true if we do find and remove the |source|. |
| 220 // Otherwise returns false. | 223 // Otherwise returns false. |
| 221 bool RemoveLocalSource(const blink::WebMediaStreamSource& source); | 224 bool RemoveLocalSource(const blink::WebMediaStreamSource& source); |
| 222 | 225 |
| 223 void StopLocalSource(const blink::WebMediaStreamSource& source, | 226 void StopLocalSource(const blink::WebMediaStreamSource& source, |
| 224 bool notify_dispatcher); | 227 bool notify_dispatcher); |
| 225 | 228 |
| 226 const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher(); | 229 const ::mojom::MediaDevicesDispatcherHostPtr& GetMediaDevicesDispatcher(); |
| 227 | 230 |
| 228 void SelectAudioInputDevice( | 231 // TODO(guidou): Remove these functions. http://crbug.com/706408 |
| 232 void LegacySetupAudioInput(); |
| 233 void LegacySelectAudioInputDevice( |
| 229 const blink::WebUserMediaRequest& user_media_request, | 234 const blink::WebUserMediaRequest& user_media_request, |
| 230 const EnumerationResult& device_enumeration); | 235 const EnumerationResult& device_enumeration); |
| 231 | 236 |
| 232 void SetupVideoInput(const blink::WebUserMediaRequest& user_media_request); | 237 void SetupAudioInput(); |
| 238 void SelectAudioSettings(const blink::WebUserMediaRequest& user_media_request, |
| 239 std::vector<::mojom::AudioInputDeviceCapabilitiesPtr> |
| 240 audio_input_capabilities); |
| 233 | 241 |
| 242 void SetupVideoInput(); |
| 234 void SelectVideoDeviceSettings( | 243 void SelectVideoDeviceSettings( |
| 235 const blink::WebUserMediaRequest& user_media_request, | 244 const blink::WebUserMediaRequest& user_media_request, |
| 236 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> | 245 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> |
| 237 video_input_capabilities); | 246 video_input_capabilities); |
| 238 | |
| 239 void FinalizeSelectVideoDeviceSettings( | 247 void FinalizeSelectVideoDeviceSettings( |
| 240 const blink::WebUserMediaRequest& user_media_request, | 248 const blink::WebUserMediaRequest& user_media_request, |
| 241 const VideoCaptureSettings& settings); | 249 const VideoCaptureSettings& settings); |
| 242 | |
| 243 void FinalizeSelectVideoContentSettings( | 250 void FinalizeSelectVideoContentSettings( |
| 244 const blink::WebUserMediaRequest& user_media_request, | 251 const blink::WebUserMediaRequest& user_media_request, |
| 245 const VideoCaptureSettings& settings); | 252 const VideoCaptureSettings& settings); |
| 246 | 253 |
| 247 void GenerateStreamForCurrentRequestInfo(); | 254 void GenerateStreamForCurrentRequestInfo(); |
| 248 | 255 |
| 249 // Callback invoked by MediaDevicesEventDispatcher when a device-change | 256 // Callback invoked by MediaDevicesEventDispatcher when a device-change |
| 250 // notification arrives. | 257 // notification arrives. |
| 251 void DevicesChanged(MediaDeviceType device_type, | 258 void DevicesChanged(MediaDeviceType device_type, |
| 252 const MediaDeviceInfoArray& device_infos); | 259 const MediaDeviceInfoArray& device_infos); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // Note: This member must be the last to ensure all outstanding weak pointers | 291 // Note: This member must be the last to ensure all outstanding weak pointers |
| 285 // are invalidated first. | 292 // are invalidated first. |
| 286 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; | 293 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; |
| 287 | 294 |
| 288 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); | 295 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); |
| 289 }; | 296 }; |
| 290 | 297 |
| 291 } // namespace content | 298 } // namespace content |
| 292 | 299 |
| 293 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ | 300 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ |
| OLD | NEW |