| 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_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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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/WebUserMediaClient.h" | 26 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
| 27 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 27 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| 28 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 28 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class MediaStreamAudioRenderer; | 31 class MediaStreamAudioRenderer; |
| 32 class MediaStreamDependencyFactory; | 32 class PeerConnectionDependencyFactory; |
| 33 class MediaStreamDispatcher; | 33 class MediaStreamDispatcher; |
| 34 class MediaStreamVideoSource; | 34 class MediaStreamVideoSource; |
| 35 class VideoCapturerDelegate; | 35 class VideoCapturerDelegate; |
| 36 class WebRtcAudioRenderer; | 36 class WebRtcAudioRenderer; |
| 37 class WebRtcLocalAudioRenderer; | 37 class WebRtcLocalAudioRenderer; |
| 38 | 38 |
| 39 // MediaStreamImpl is a delegate for the Media Stream API messages used by | 39 // MediaStreamImpl is a delegate for the Media Stream API messages used by |
| 40 // WebKit. It ties together WebKit, native PeerConnection in libjingle and | 40 // WebKit. It ties together WebKit, native PeerConnection in libjingle and |
| 41 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 41 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
| 42 // in the browser process. It must be created, called and destroyed on the | 42 // in the browser process. It must be created, called and destroyed on the |
| 43 // render thread. | 43 // render thread. |
| 44 // MediaStreamImpl have weak pointers to a MediaStreamDispatcher. | 44 // MediaStreamImpl have weak pointers to a MediaStreamDispatcher. |
| 45 class CONTENT_EXPORT MediaStreamImpl | 45 class CONTENT_EXPORT MediaStreamImpl |
| 46 : public RenderViewObserver, | 46 : public RenderViewObserver, |
| 47 NON_EXPORTED_BASE(public blink::WebUserMediaClient), | 47 NON_EXPORTED_BASE(public blink::WebUserMediaClient), |
| 48 NON_EXPORTED_BASE(public MediaStreamClient), | 48 NON_EXPORTED_BASE(public MediaStreamClient), |
| 49 public MediaStreamDispatcherEventHandler, | 49 public MediaStreamDispatcherEventHandler, |
| 50 public base::SupportsWeakPtr<MediaStreamImpl>, | 50 public base::SupportsWeakPtr<MediaStreamImpl>, |
| 51 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 51 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 52 public: | 52 public: |
| 53 MediaStreamImpl( | 53 MediaStreamImpl( |
| 54 RenderView* render_view, | 54 RenderView* render_view, |
| 55 MediaStreamDispatcher* media_stream_dispatcher, | 55 MediaStreamDispatcher* media_stream_dispatcher, |
| 56 MediaStreamDependencyFactory* dependency_factory); | 56 PeerConnectionDependencyFactory* dependency_factory); |
| 57 virtual ~MediaStreamImpl(); | 57 virtual ~MediaStreamImpl(); |
| 58 | 58 |
| 59 // blink::WebUserMediaClient implementation | 59 // blink::WebUserMediaClient implementation |
| 60 virtual void requestUserMedia( | 60 virtual void requestUserMedia( |
| 61 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; | 61 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; |
| 62 virtual void cancelUserMediaRequest( | 62 virtual void cancelUserMediaRequest( |
| 63 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; | 63 const blink::WebUserMediaRequest& user_media_request) OVERRIDE; |
| 64 | 64 |
| 65 // MediaStreamClient implementation. | 65 // MediaStreamClient implementation. |
| 66 virtual bool IsMediaStream(const GURL& url) OVERRIDE; | 66 virtual bool IsMediaStream(const GURL& url) OVERRIDE; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const bool enable_automatic_output_device_selection; | 142 const bool enable_automatic_output_device_selection; |
| 143 blink::WebFrame* frame; // WebFrame that requested the MediaStream. | 143 blink::WebFrame* frame; // WebFrame that requested the MediaStream. |
| 144 blink::WebMediaStream web_stream; | 144 blink::WebMediaStream web_stream; |
| 145 blink::WebUserMediaRequest request; | 145 blink::WebUserMediaRequest request; |
| 146 | 146 |
| 147 void StartAudioTrack(const blink::WebMediaStreamTrack& track, | 147 void StartAudioTrack(const blink::WebMediaStreamTrack& track, |
| 148 const blink::WebMediaConstraints& constraints); | 148 const blink::WebMediaConstraints& constraints); |
| 149 | 149 |
| 150 blink::WebMediaStreamTrack CreateAndStartVideoTrack( | 150 blink::WebMediaStreamTrack CreateAndStartVideoTrack( |
| 151 const blink::WebMediaStreamSource& source, | 151 const blink::WebMediaStreamSource& source, |
| 152 const blink::WebMediaConstraints& constraints, | 152 const blink::WebMediaConstraints& constraints); |
| 153 MediaStreamDependencyFactory* factory); | |
| 154 | 153 |
| 155 // Triggers |callback| when all sources used in this request have either | 154 // Triggers |callback| when all sources used in this request have either |
| 156 // successfully started, or a source has failed to start. | 155 // successfully started, or a source has failed to start. |
| 157 void CallbackOnTracksStarted(const ResourcesReady& callback); | 156 void CallbackOnTracksStarted(const ResourcesReady& callback); |
| 158 | 157 |
| 159 bool IsSourceUsed(const blink::WebMediaStreamSource& source) const; | 158 bool IsSourceUsed(const blink::WebMediaStreamSource& source) const; |
| 160 void RemoveSource(const blink::WebMediaStreamSource& source); | 159 void RemoveSource(const blink::WebMediaStreamSource& source); |
| 161 | 160 |
| 162 bool AreAllSourcesRemoved() const { return sources_.empty(); }; | 161 bool AreAllSourcesRemoved() const { return sources_.empty(); }; |
| 163 | 162 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // Returns a valid session id if a single capture device is currently open | 233 // Returns a valid session id if a single capture device is currently open |
| 235 // (and then the matching session_id), otherwise -1. | 234 // (and then the matching session_id), otherwise -1. |
| 236 // This is used to pass on a session id to a webrtc audio renderer (either | 235 // This is used to pass on a session id to a webrtc audio renderer (either |
| 237 // local or remote), so that audio will be rendered to a matching output | 236 // local or remote), so that audio will be rendered to a matching output |
| 238 // device, should one exist. | 237 // device, should one exist. |
| 239 // Note that if there are more than one open capture devices the function | 238 // Note that if there are more than one open capture devices the function |
| 240 // will not be able to pick an appropriate device and return false. | 239 // will not be able to pick an appropriate device and return false. |
| 241 bool GetAuthorizedDeviceInfoForAudioRenderer( | 240 bool GetAuthorizedDeviceInfoForAudioRenderer( |
| 242 int* session_id, int* output_sample_rate, int* output_buffer_size); | 241 int* session_id, int* output_sample_rate, int* output_buffer_size); |
| 243 | 242 |
| 244 // Weak ref to a MediaStreamDependencyFactory, owned by the RenderThread. | 243 // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. |
| 245 // It's valid for the lifetime of RenderThread. | 244 // It's valid for the lifetime of RenderThread. |
| 246 MediaStreamDependencyFactory* dependency_factory_; | 245 // TODO(xians): Remove this dependency once audio do not need it for local |
| 246 // audio. |
| 247 PeerConnectionDependencyFactory* dependency_factory_; |
| 247 | 248 |
| 248 // media_stream_dispatcher_ is a weak reference, owned by RenderView. It's | 249 // media_stream_dispatcher_ is a weak reference, owned by RenderView. It's |
| 249 // valid for the lifetime of RenderView. | 250 // valid for the lifetime of RenderView. |
| 250 MediaStreamDispatcher* media_stream_dispatcher_; | 251 MediaStreamDispatcher* media_stream_dispatcher_; |
| 251 | 252 |
| 252 LocalStreamSources local_sources_; | 253 LocalStreamSources local_sources_; |
| 253 | 254 |
| 254 UserMediaRequests user_media_requests_; | 255 UserMediaRequests user_media_requests_; |
| 255 | 256 |
| 256 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); | 257 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); |
| 257 }; | 258 }; |
| 258 | 259 |
| 259 } // namespace content | 260 } // namespace content |
| 260 | 261 |
| 261 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 262 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
| OLD | NEW |