Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/renderer/media/media_stream_impl.h

Issue 287383002: Implement getMediaDevices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't clear labels in DRMF. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_MEDIA_STREAM_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.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/public/renderer/render_view_observer.h" 19 #include "content/public/renderer/render_view_observer.h"
20 #include "content/renderer/media/media_stream_client.h" 20 #include "content/renderer/media/media_stream_client.h"
21 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" 21 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
22 #include "content/renderer/media/media_stream_source.h" 22 #include "content/renderer/media/media_stream_source.h"
23 #include "third_party/WebKit/public/platform/WebMediaStream.h" 23 #include "third_party/WebKit/public/platform/WebMediaStream.h"
24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.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/WebUserMediaClient.h" 27 #include "third_party/WebKit/public/web/WebUserMediaClient.h"
27 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" 28 #include "third_party/WebKit/public/web/WebUserMediaRequest.h"
28 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 29 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
29 30
30 namespace content { 31 namespace content {
31 class MediaStreamAudioRenderer; 32 class MediaStreamAudioRenderer;
32 class PeerConnectionDependencyFactory; 33 class PeerConnectionDependencyFactory;
33 class MediaStreamDispatcher; 34 class MediaStreamDispatcher;
34 class MediaStreamVideoSource; 35 class MediaStreamVideoSource;
35 class VideoCapturerDelegate; 36 class VideoCapturerDelegate;
(...skipping 18 matching lines...) Expand all
54 RenderView* render_view, 55 RenderView* render_view,
55 MediaStreamDispatcher* media_stream_dispatcher, 56 MediaStreamDispatcher* media_stream_dispatcher,
56 PeerConnectionDependencyFactory* dependency_factory); 57 PeerConnectionDependencyFactory* dependency_factory);
57 virtual ~MediaStreamImpl(); 58 virtual ~MediaStreamImpl();
58 59
59 // blink::WebUserMediaClient implementation 60 // blink::WebUserMediaClient implementation
60 virtual void requestUserMedia( 61 virtual void requestUserMedia(
61 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; 62 const blink::WebUserMediaRequest& user_media_request) OVERRIDE;
62 virtual void cancelUserMediaRequest( 63 virtual void cancelUserMediaRequest(
63 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; 64 const blink::WebUserMediaRequest& user_media_request) OVERRIDE;
65 virtual void requestMediaDevices(
66 const blink::WebMediaDevicesRequest& media_devices_request) OVERRIDE;
67 virtual void cancelMediaDevicesRequest(
68 const blink::WebMediaDevicesRequest& media_devices_request) OVERRIDE;
64 69
65 // MediaStreamClient implementation. 70 // MediaStreamClient implementation.
66 virtual bool IsMediaStream(const GURL& url) OVERRIDE; 71 virtual bool IsMediaStream(const GURL& url) OVERRIDE;
67 virtual scoped_refptr<VideoFrameProvider> GetVideoFrameProvider( 72 virtual scoped_refptr<VideoFrameProvider> GetVideoFrameProvider(
68 const GURL& url, 73 const GURL& url,
69 const base::Closure& error_cb, 74 const base::Closure& error_cb,
70 const VideoFrameProvider::RepaintCB& repaint_cb) OVERRIDE; 75 const VideoFrameProvider::RepaintCB& repaint_cb) OVERRIDE;
71 virtual scoped_refptr<MediaStreamAudioRenderer> 76 virtual scoped_refptr<MediaStreamAudioRenderer>
72 GetAudioRenderer(const GURL& url, int render_frame_id) OVERRIDE; 77 GetAudioRenderer(const GURL& url, int render_frame_id) OVERRIDE;
73 78
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const blink::WebMediaStreamSource& source) 182 const blink::WebMediaStreamSource& source)
178 : frame(frame), source(source) { 183 : frame(frame), source(source) {
179 } 184 }
180 // |frame| is the WebFrame that requested |source|. NULL in unit tests. 185 // |frame| is the WebFrame that requested |source|. NULL in unit tests.
181 // TODO(perkj): Change so that |frame| is not NULL in unit tests. 186 // TODO(perkj): Change so that |frame| is not NULL in unit tests.
182 blink::WebFrame* frame; 187 blink::WebFrame* frame;
183 blink::WebMediaStreamSource source; 188 blink::WebMediaStreamSource source;
184 }; 189 };
185 typedef std::vector<LocalStreamSource> LocalStreamSources; 190 typedef std::vector<LocalStreamSource> LocalStreamSources;
186 191
192 struct MediaDevicesRequestInfo;
193 typedef ScopedVector<MediaDevicesRequestInfo> MediaDevicesRequests;
194
187 // Creates a WebKit representation of stream sources based on 195 // Creates a WebKit representation of stream sources based on
188 // |devices| from the MediaStreamDispatcher. 196 // |devices| from the MediaStreamDispatcher.
189 void InitializeSourceObject( 197 void InitializeSourceObject(
190 const StreamDeviceInfo& device, 198 const StreamDeviceInfo& device,
191 blink::WebMediaStreamSource::Type type, 199 blink::WebMediaStreamSource::Type type,
192 const blink::WebMediaConstraints& constraints, 200 const blink::WebMediaConstraints& constraints,
193 blink::WebFrame* frame, 201 blink::WebFrame* frame,
194 blink::WebMediaStreamSource* webkit_source); 202 blink::WebMediaStreamSource* webkit_source);
195 203
196 void CreateVideoTracks( 204 void CreateVideoTracks(
(...skipping 12 matching lines...) Expand all
209 // underlying media sources and tracks have been created and started. 217 // underlying media sources and tracks have been created and started.
210 void OnCreateNativeTracksCompleted( 218 void OnCreateNativeTracksCompleted(
211 UserMediaRequestInfo* request, 219 UserMediaRequestInfo* request,
212 content::MediaStreamRequestResult result); 220 content::MediaStreamRequestResult result);
213 221
214 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id); 222 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id);
215 UserMediaRequestInfo* FindUserMediaRequestInfo( 223 UserMediaRequestInfo* FindUserMediaRequestInfo(
216 const blink::WebUserMediaRequest& request); 224 const blink::WebUserMediaRequest& request);
217 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request); 225 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request);
218 226
227 MediaDevicesRequestInfo* FindMediaDevicesRequestInfo(int request_id);
228 MediaDevicesRequestInfo* FindMediaDevicesRequestInfo(
229 const blink::WebMediaDevicesRequest& request);
230 void DeleteMediaDevicesRequestInfo(MediaDevicesRequestInfo* request);
231
219 // Returns the source that use a device with |device.session_id| 232 // Returns the source that use a device with |device.session_id|
220 // and |device.device.id|. NULL if such source doesn't exist. 233 // and |device.device.id|. NULL if such source doesn't exist.
221 const blink::WebMediaStreamSource* FindLocalSource( 234 const blink::WebMediaStreamSource* FindLocalSource(
222 const StreamDeviceInfo& device) const; 235 const StreamDeviceInfo& device) const;
223 236
224 void StopLocalSource(const blink::WebMediaStreamSource& source, 237 void StopLocalSource(const blink::WebMediaStreamSource& source,
225 bool notify_dispatcher); 238 bool notify_dispatcher);
226 239
227 scoped_refptr<WebRtcAudioRenderer> CreateRemoteAudioRenderer( 240 scoped_refptr<WebRtcAudioRenderer> CreateRemoteAudioRenderer(
228 webrtc::MediaStreamInterface* stream, int render_frame_id); 241 webrtc::MediaStreamInterface* stream, int render_frame_id);
(...skipping 18 matching lines...) Expand all
247 PeerConnectionDependencyFactory* dependency_factory_; 260 PeerConnectionDependencyFactory* dependency_factory_;
248 261
249 // media_stream_dispatcher_ is a weak reference, owned by RenderView. It's 262 // media_stream_dispatcher_ is a weak reference, owned by RenderView. It's
250 // valid for the lifetime of RenderView. 263 // valid for the lifetime of RenderView.
251 MediaStreamDispatcher* media_stream_dispatcher_; 264 MediaStreamDispatcher* media_stream_dispatcher_;
252 265
253 LocalStreamSources local_sources_; 266 LocalStreamSources local_sources_;
254 267
255 UserMediaRequests user_media_requests_; 268 UserMediaRequests user_media_requests_;
256 269
270 // Requests to enumerate media devices.
271 MediaDevicesRequests media_devices_requests_;
272
257 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); 273 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl);
258 }; 274 };
259 275
260 } // namespace content 276 } // namespace content
261 277
262 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ 278 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698