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