Chromium Code Reviews| Index: content/renderer/media/user_media_client_impl.h |
| diff --git a/content/renderer/media/user_media_client_impl.h b/content/renderer/media/user_media_client_impl.h |
| index 2492ccc00bebd8fc887990a2b46527f765a0e549..eebd327d3bd547e45a6e4422eb2656d1a082c8c3 100644 |
| --- a/content/renderer/media/user_media_client_impl.h |
| +++ b/content/renderer/media/user_media_client_impl.h |
| @@ -119,7 +119,8 @@ class CONTENT_EXPORT UserMediaClientImpl |
| // These are virtual for test purposes. |
| virtual MediaStreamAudioSource* CreateAudioSource( |
| const StreamDeviceInfo& device, |
| - const blink::WebMediaConstraints& constraints); |
| + const blink::WebMediaConstraints& constraints, |
| + const MediaStreamSource::ConstraintsCallback& source_ready); |
| virtual MediaStreamVideoSource* CreateVideoSource( |
| const StreamDeviceInfo& device, |
| const MediaStreamSource::SourceStoppedCallback& stop_callback); |
| @@ -146,7 +147,8 @@ class CONTENT_EXPORT UserMediaClientImpl |
| blink::WebMediaStream web_stream; |
| blink::WebUserMediaRequest request; |
| - void StartAudioTrack(const blink::WebMediaStreamTrack& track); |
| + void StartAudioTrack(const blink::WebMediaStreamTrack& track, |
| + bool source_initialized); |
| blink::WebMediaStreamTrack CreateAndStartVideoTrack( |
| const blink::WebMediaStreamSource& source, |
| @@ -156,16 +158,22 @@ class CONTENT_EXPORT UserMediaClientImpl |
| // successfully started, or a source has failed to start. |
| void CallbackOnTracksStarted(const ResourcesReady& callback); |
| - bool IsSourceUsed(const blink::WebMediaStreamSource& source) const; |
| - void RemoveSource(const blink::WebMediaStreamSource& source); |
| - |
| bool HasPendingSources() const; |
| + // Called when a local audio source has finished (or failed) initializing. |
| + void OnAudioSourceStarted(MediaStreamSource* source, |
| + MediaStreamRequestResult result, |
| + const blink::WebString& result_name); |
| + |
| private: |
| void OnTrackStarted( |
| MediaStreamSource* source, |
| MediaStreamRequestResult result, |
| const blink::WebString& result_name); |
| + |
| + // Cheks if the sources for all tracks have been started and if so, |
| + // invoke the |ready_callback_|. Note that the caller should expect |
| + // that |this| might be deleted when the function returns. |
| void CheckAllTracksStarted(); |
| ResourcesReady ready_callback_; |
| @@ -193,12 +201,17 @@ class CONTENT_EXPORT UserMediaClientImpl |
| // Creates a WebKit representation of stream sources based on |
| // |devices| from the MediaStreamDispatcher. |
| - void InitializeSourceObject( |
| + void InitializeVideoSourceObject( |
| const StreamDeviceInfo& device, |
| - blink::WebMediaStreamSource::Type type, |
| const blink::WebMediaConstraints& constraints, |
| blink::WebMediaStreamSource* webkit_source); |
| + void InitializeAudioSourceObject( |
|
miu
2017/01/11 20:51:11
Please return a bool instead of make the caller pr
tommi (sloooow) - chröme
2017/01/11 22:40:59
Done. Also changed InitializeVideoSourceObject to
|
| + const StreamDeviceInfo& device, |
| + const blink::WebMediaConstraints& constraints, |
| + blink::WebMediaStreamSource* webkit_source, |
| + bool* source_initialized); |
| + |
| void CreateVideoTracks( |
| const StreamDeviceInfoArray& devices, |
| const blink::WebMediaConstraints& constraints, |
| @@ -222,6 +235,17 @@ class CONTENT_EXPORT UserMediaClientImpl |
| const StreamDeviceInfoArray& audio_array, |
| const StreamDeviceInfoArray& video_array); |
| + static void OnAudioSourceStartedOnAudioThread( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| + base::WeakPtr<UserMediaClientImpl> weak_ptr, |
| + MediaStreamSource* source, |
| + MediaStreamRequestResult result, |
| + const blink::WebString& result_name); |
| + |
| + void OnAudioSourceStarted(MediaStreamSource* source, |
| + MediaStreamRequestResult result, |
| + const blink::WebString& result_name); |
| + |
| using EnumerationResult = std::vector<MediaDeviceInfoArray>; |
| void FinalizeEnumerateDevices(blink::WebMediaDevicesRequest request, |
| const EnumerationResult& result); |
| @@ -231,8 +255,22 @@ class CONTENT_EXPORT UserMediaClientImpl |
| // Returns the source that use a device with |device.session_id| |
| // and |device.device.id|. NULL if such source doesn't exist. |
| const blink::WebMediaStreamSource* FindLocalSource( |
| + const StreamDeviceInfo& device) const { |
| + return FindLocalSource(local_sources_, device); |
| + } |
| + const blink::WebMediaStreamSource* FindPendingLocalSource( |
| + const StreamDeviceInfo& device) const { |
| + return FindLocalSource(pending_local_sources_, device); |
| + } |
| + const blink::WebMediaStreamSource* FindLocalSource( |
| + const LocalStreamSources& sources, |
| const StreamDeviceInfo& device) const; |
| + // Looks up a local source and returns it if found. If not found, prepares |
| + // a new WebMediaStreamSource with a NULL extraData pointer. |
| + blink::WebMediaStreamSource FindOrInitializeSourceObject( |
| + const StreamDeviceInfo& device); |
| + |
| // Returns true if we do find and remove the |source|. |
| // Otherwise returns false. |
| bool RemoveLocalSource(const blink::WebMediaStreamSource& source); |
| @@ -274,6 +312,7 @@ class CONTENT_EXPORT UserMediaClientImpl |
| ::mojom::MediaDevicesDispatcherHostPtr media_devices_dispatcher_; |
| LocalStreamSources local_sources_; |
| + LocalStreamSources pending_local_sources_; |
| UserMediaRequests user_media_requests_; |
| MediaDevicesEventDispatcher::SubscriptionIdList |