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> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "third_party/WebKit/public/platform/WebSourceInfo.h" | 24 #include "third_party/WebKit/public/platform/WebSourceInfo.h" |
25 #include "third_party/WebKit/public/platform/WebVector.h" | 25 #include "third_party/WebKit/public/platform/WebVector.h" |
26 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" | 26 #include "third_party/WebKit/public/web/WebMediaDeviceChangeObserver.h" |
27 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 27 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
28 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 28 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
29 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 29 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
30 #include "third_party/webrtc/api/mediastreaminterface.h" | 30 #include "third_party/webrtc/api/mediastreaminterface.h" |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 class PeerConnectionDependencyFactory; | 33 class PeerConnectionDependencyFactory; |
34 class MediaStreamAudioSource; | |
35 class MediaStreamDispatcher; | 34 class MediaStreamDispatcher; |
36 class MediaStreamVideoSource; | 35 class MediaStreamVideoSource; |
37 class VideoCapturerDelegate; | 36 class VideoCapturerDelegate; |
38 | 37 |
39 // UserMediaClientImpl is a delegate for the Media Stream GetUserMedia API. | 38 // UserMediaClientImpl is a delegate for the Media Stream GetUserMedia API. |
40 // It ties together WebKit and MediaStreamManager | 39 // It ties together WebKit and MediaStreamManager |
41 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 40 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
42 // in the browser process. It must be created, called and destroyed on the | 41 // in the browser process. It must be created, called and destroyed on the |
43 // render thread. | 42 // render thread. |
44 class CONTENT_EXPORT UserMediaClientImpl | 43 class CONTENT_EXPORT UserMediaClientImpl |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 blink::WebUserMediaRequest request_info, | 112 blink::WebUserMediaRequest request_info, |
114 MediaStreamRequestResult result, | 113 MediaStreamRequestResult result, |
115 const blink::WebString& result_name); | 114 const blink::WebString& result_name); |
116 | 115 |
117 virtual void EnumerateDevicesSucceded( | 116 virtual void EnumerateDevicesSucceded( |
118 blink::WebMediaDevicesRequest* request, | 117 blink::WebMediaDevicesRequest* request, |
119 blink::WebVector<blink::WebMediaDeviceInfo>& devices); | 118 blink::WebVector<blink::WebMediaDeviceInfo>& devices); |
120 virtual void EnumerateSourcesSucceded( | 119 virtual void EnumerateSourcesSucceded( |
121 blink::WebMediaStreamTrackSourcesRequest* request, | 120 blink::WebMediaStreamTrackSourcesRequest* request, |
122 blink::WebVector<blink::WebSourceInfo>& sources); | 121 blink::WebVector<blink::WebSourceInfo>& sources); |
123 | 122 // Creates a MediaStreamVideoSource object. |
124 // Creates a MediaStreamAudioSource/MediaStreamVideoSource objects. | 123 // This is virtual for test purposes. |
125 // These are virtual for test purposes. | |
126 virtual MediaStreamAudioSource* CreateAudioSource( | |
127 const StreamDeviceInfo& device, | |
128 const blink::WebMediaConstraints& constraints); | |
129 virtual MediaStreamVideoSource* CreateVideoSource( | 124 virtual MediaStreamVideoSource* CreateVideoSource( |
130 const StreamDeviceInfo& device, | 125 const StreamDeviceInfo& device, |
131 const MediaStreamSource::SourceStoppedCallback& stop_callback); | 126 const MediaStreamSource::SourceStoppedCallback& stop_callback); |
132 | 127 |
133 // Class for storing information about a WebKit request to create a | 128 // Class for storing information about a WebKit request to create a |
134 // MediaStream. | 129 // MediaStream. |
135 class UserMediaRequestInfo | 130 class UserMediaRequestInfo |
136 : public base::SupportsWeakPtr<UserMediaRequestInfo> { | 131 : public base::SupportsWeakPtr<UserMediaRequestInfo> { |
137 public: | 132 public: |
138 typedef base::Callback<void(UserMediaRequestInfo* request_info, | 133 typedef base::Callback<void(UserMediaRequestInfo* request_info, |
139 MediaStreamRequestResult result, | 134 MediaStreamRequestResult result, |
140 const blink::WebString& result_name)> | 135 const blink::WebString& result_name)> |
141 ResourcesReady; | 136 ResourcesReady; |
142 | 137 |
143 UserMediaRequestInfo(int request_id, | 138 UserMediaRequestInfo(int request_id, |
144 const blink::WebUserMediaRequest& request, | 139 const blink::WebUserMediaRequest& request, |
145 bool enable_automatic_output_device_selection); | 140 bool enable_automatic_output_device_selection); |
146 ~UserMediaRequestInfo(); | 141 ~UserMediaRequestInfo(); |
147 int request_id; | 142 int request_id; |
148 // True if MediaStreamDispatcher has generated the stream, see | 143 // True if MediaStreamDispatcher has generated the stream, see |
149 // OnStreamGenerated. | 144 // OnStreamGenerated. |
150 bool generated; | 145 bool generated; |
151 const bool enable_automatic_output_device_selection; | 146 const bool enable_automatic_output_device_selection; |
152 blink::WebMediaStream web_stream; | 147 blink::WebMediaStream web_stream; |
153 blink::WebUserMediaRequest request; | 148 blink::WebUserMediaRequest request; |
154 | 149 |
155 void StartAudioTrack(const blink::WebMediaStreamTrack& track); | 150 void StartAudioTrack(const blink::WebMediaStreamTrack& track, |
| 151 const blink::WebMediaConstraints& constraints); |
156 | 152 |
157 blink::WebMediaStreamTrack CreateAndStartVideoTrack( | 153 blink::WebMediaStreamTrack CreateAndStartVideoTrack( |
158 const blink::WebMediaStreamSource& source, | 154 const blink::WebMediaStreamSource& source, |
159 const blink::WebMediaConstraints& constraints); | 155 const blink::WebMediaConstraints& constraints); |
160 | 156 |
161 // Triggers |callback| when all sources used in this request have either | 157 // Triggers |callback| when all sources used in this request have either |
162 // successfully started, or a source has failed to start. | 158 // successfully started, or a source has failed to start. |
163 void CallbackOnTracksStarted(const ResourcesReady& callback); | 159 void CallbackOnTracksStarted(const ResourcesReady& callback); |
164 | 160 |
165 bool IsSourceUsed(const blink::WebMediaStreamSource& source) const; | 161 bool IsSourceUsed(const blink::WebMediaStreamSource& source) const; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Note: This member must be the last to ensure all outstanding weak pointers | 267 // Note: This member must be the last to ensure all outstanding weak pointers |
272 // are invalidated first. | 268 // are invalidated first. |
273 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; | 269 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; |
274 | 270 |
275 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); | 271 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); |
276 }; | 272 }; |
277 | 273 |
278 } // namespace content | 274 } // namespace content |
279 | 275 |
280 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ | 276 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ |
OLD | NEW |