| 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_DEPENDENCY_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class WebMediaConstraints; | 38 class WebMediaConstraints; |
| 39 class WebMediaStream; | 39 class WebMediaStream; |
| 40 class WebRTCPeerConnectionHandler; | 40 class WebRTCPeerConnectionHandler; |
| 41 class WebRTCPeerConnectionHandlerClient; | 41 class WebRTCPeerConnectionHandlerClient; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace content { | 44 namespace content { |
| 45 | 45 |
| 46 class IpcNetworkManager; | 46 class IpcNetworkManager; |
| 47 class IpcPacketSocketFactory; | 47 class IpcPacketSocketFactory; |
| 48 class MediaStreamAudioSource; |
| 48 class RTCMediaConstraints; | 49 class RTCMediaConstraints; |
| 49 class WebAudioCapturerSource; | 50 class WebAudioCapturerSource; |
| 50 class WebRtcAudioCapturer; | 51 class WebRtcAudioCapturer; |
| 51 class WebRtcAudioDeviceImpl; | 52 class WebRtcAudioDeviceImpl; |
| 52 class WebRtcLoggingHandlerImpl; | 53 class WebRtcLoggingHandlerImpl; |
| 53 class WebRtcLoggingMessageFilter; | 54 class WebRtcLoggingMessageFilter; |
| 54 struct StreamDeviceInfo; | 55 struct StreamDeviceInfo; |
| 55 | 56 |
| 56 // Object factory for RTC MediaStreams and RTC PeerConnections. | 57 // Object factory for RTC MediaStreams and RTC PeerConnections. |
| 57 class CONTENT_EXPORT MediaStreamDependencyFactory | 58 class CONTENT_EXPORT MediaStreamDependencyFactory |
| 58 : NON_EXPORTED_BASE(public base::NonThreadSafe), | 59 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 59 public RenderProcessObserver { | 60 public RenderProcessObserver { |
| 60 public: | 61 public: |
| 61 // MediaSourcesCreatedCallback is used in CreateNativeMediaSources. | 62 // MediaSourcesCreatedCallback is used in CreateNativeMediaSources. |
| 62 typedef base::Callback<void(blink::WebMediaStream* web_stream, | 63 typedef base::Callback<void(blink::WebMediaStream* web_stream, |
| 63 bool live)> MediaSourcesCreatedCallback; | 64 bool live)> MediaSourcesCreatedCallback; |
| 64 MediaStreamDependencyFactory( | 65 MediaStreamDependencyFactory( |
| 65 P2PSocketDispatcher* p2p_socket_dispatcher); | 66 P2PSocketDispatcher* p2p_socket_dispatcher); |
| 66 virtual ~MediaStreamDependencyFactory(); | 67 virtual ~MediaStreamDependencyFactory(); |
| 67 | 68 |
| 68 // Create a RTCPeerConnectionHandler object that implements the | 69 // Create a RTCPeerConnectionHandler object that implements the |
| 69 // WebKit WebRTCPeerConnectionHandler interface. | 70 // WebKit WebRTCPeerConnectionHandler interface. |
| 70 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 71 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( |
| 71 blink::WebRTCPeerConnectionHandlerClient* client); | 72 blink::WebRTCPeerConnectionHandlerClient* client); |
| 72 | 73 |
| 73 // CreateNativeMediaSources creates libjingle representations of | 74 // InitializeMediaStreamAudioSource initialize a MediaStream source object |
| 74 // the underlying sources to the tracks in |web_stream|. | 75 // for audio input. |
| 75 // |sources_created| is invoked when the sources have either been created and | 76 bool InitializeMediaStreamAudioSource( |
| 76 // transitioned to a live state or failed. | |
| 77 // The libjingle sources is stored in the extra data field of | |
| 78 // WebMediaStreamSource. | |
| 79 // |audio_constraints| and |video_constraints| set parameters for the sources. | |
| 80 void CreateNativeMediaSources( | |
| 81 int render_view_id, | 77 int render_view_id, |
| 82 const blink::WebMediaConstraints& audio_constraints, | 78 const blink::WebMediaConstraints& audio_constraints, |
| 83 const blink::WebMediaConstraints& video_constraints, | 79 MediaStreamAudioSource* source_data); |
| 84 blink::WebMediaStream* web_stream, | 80 |
| 85 const MediaSourcesCreatedCallback& sources_created); | 81 // Creates an implementation of a cricket::VideoCapturer object that can be |
| 82 // used when creating a libjingle webrtc::VideoSourceInterface object. |
| 83 virtual cricket::VideoCapturer* CreateVideoCapturer( |
| 84 const StreamDeviceInfo& info); |
| 86 | 85 |
| 87 // Creates a libjingle representation of a MediaStream and stores | 86 // Creates a libjingle representation of a MediaStream and stores |
| 88 // it in the extra data field of |web_stream|. | 87 // it in the extra data field of |web_stream|. |
| 89 void CreateNativeLocalMediaStream( | 88 void CreateNativeLocalMediaStream( |
| 90 blink::WebMediaStream* web_stream); | 89 blink::WebMediaStream* web_stream); |
| 91 | 90 |
| 92 // Creates a libjingle representation of a MediaStream and stores | 91 // Creates a libjingle representation of a MediaStream and stores |
| 93 // it in the extra data field of |web_stream|. | 92 // it in the extra data field of |web_stream|. |
| 94 // |stream_stopped| is a callback that is run when a MediaStream have been | 93 // |stream_stopped| is a callback that is run when a MediaStream have been |
| 95 // stopped. | 94 // stopped. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 protected: | 160 protected: |
| 162 // Asks the PeerConnection factory to create a Local MediaStream object. | 161 // Asks the PeerConnection factory to create a Local MediaStream object. |
| 163 virtual scoped_refptr<webrtc::MediaStreamInterface> | 162 virtual scoped_refptr<webrtc::MediaStreamInterface> |
| 164 CreateLocalMediaStream(const std::string& label); | 163 CreateLocalMediaStream(const std::string& label); |
| 165 | 164 |
| 166 // Asks the PeerConnection factory to create a Local Audio Source. | 165 // Asks the PeerConnection factory to create a Local Audio Source. |
| 167 virtual scoped_refptr<webrtc::AudioSourceInterface> | 166 virtual scoped_refptr<webrtc::AudioSourceInterface> |
| 168 CreateLocalAudioSource( | 167 CreateLocalAudioSource( |
| 169 const webrtc::MediaConstraintsInterface* constraints); | 168 const webrtc::MediaConstraintsInterface* constraints); |
| 170 | 169 |
| 171 // Asks the PeerConnection factory to create a Local Video Source. | |
| 172 virtual scoped_refptr<webrtc::VideoSourceInterface> | |
| 173 CreateLocalVideoSource( | |
| 174 int video_session_id, | |
| 175 bool is_screen_cast, | |
| 176 const webrtc::MediaConstraintsInterface* constraints); | |
| 177 | |
| 178 // Creates a media::AudioCapturerSource with an implementation that is | 170 // Creates a media::AudioCapturerSource with an implementation that is |
| 179 // specific for a WebAudio source. The created WebAudioCapturerSource | 171 // specific for a WebAudio source. The created WebAudioCapturerSource |
| 180 // instance will function as audio source instead of the default | 172 // instance will function as audio source instead of the default |
| 181 // WebRtcAudioCapturer. | 173 // WebRtcAudioCapturer. |
| 182 // The |constraints| will be modified to include the default, mandatory | 174 // The |constraints| will be modified to include the default, mandatory |
| 183 // WebAudio constraints. | 175 // WebAudio constraints. |
| 184 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( | 176 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( |
| 185 blink::WebMediaStreamSource* source, | 177 blink::WebMediaStreamSource* source, |
| 186 const RTCMediaConstraints& constraints); | 178 const RTCMediaConstraints& constraints); |
| 187 | 179 |
| 188 // Asks the PeerConnection factory to create a Local AudioTrack object. | 180 // Asks the PeerConnection factory to create a Local AudioTrack object. |
| 189 virtual scoped_refptr<webrtc::AudioTrackInterface> | 181 virtual scoped_refptr<webrtc::AudioTrackInterface> |
| 190 CreateLocalAudioTrack( | 182 CreateLocalAudioTrack( |
| 191 const std::string& id, | 183 const std::string& id, |
| 192 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 184 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
| 193 WebAudioCapturerSource* webaudio_source, | 185 WebAudioCapturerSource* webaudio_source, |
| 194 webrtc::AudioSourceInterface* source); | 186 webrtc::AudioSourceInterface* source); |
| 195 | 187 |
| 196 // Asks the PeerConnection factory to create a Local VideoTrack object. | 188 // Asks the PeerConnection factory to create a Local VideoTrack object. |
| 197 virtual scoped_refptr<webrtc::VideoTrackInterface> | 189 virtual scoped_refptr<webrtc::VideoTrackInterface> |
| 198 CreateLocalVideoTrack(const std::string& id, | 190 CreateLocalVideoTrack(const std::string& id, |
| 199 webrtc::VideoSourceInterface* source); | 191 webrtc::VideoSourceInterface* source); |
| 200 | 192 |
| 201 // Asks the PeerConnection factory to create a Local VideoTrack object with | 193 // Asks the PeerConnection factory to create a Local VideoTrack object with |
| 202 // the video source using |capturer|. | 194 // the video source using |capturer|. |
| 203 virtual scoped_refptr<webrtc::VideoTrackInterface> | 195 virtual scoped_refptr<webrtc::VideoTrackInterface> |
| 204 CreateLocalVideoTrack(const std::string& id, | 196 CreateLocalVideoTrack(const std::string& id, |
| 205 cricket::VideoCapturer* capturer); | 197 cricket::VideoCapturer* capturer); |
| 206 | 198 |
| 207 virtual bool EnsurePeerConnectionFactory(); | 199 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& |
| 200 GetPcFactory(); |
| 208 virtual bool PeerConnectionFactoryCreated(); | 201 virtual bool PeerConnectionFactoryCreated(); |
| 209 | 202 |
| 210 // Returns a new capturer or existing capturer based on the |render_view_id| | 203 // Returns a new capturer or existing capturer based on the |render_view_id| |
| 211 // and |device_info|. When the |render_view_id| and |device_info| are valid, | 204 // and |device_info|. When the |render_view_id| and |device_info| are valid, |
| 212 // it reuses existing capture if any; otherwise it creates a new capturer. | 205 // it reuses existing capture if any; otherwise it creates a new capturer. |
| 213 virtual scoped_refptr<WebRtcAudioCapturer> CreateAudioCapturer( | 206 virtual scoped_refptr<WebRtcAudioCapturer> CreateAudioCapturer( |
| 214 int render_view_id, const StreamDeviceInfo& device_info, | 207 int render_view_id, const StreamDeviceInfo& device_info, |
| 215 const blink::WebMediaConstraints& constraints); | 208 const blink::WebMediaConstraints& constraints); |
| 216 | 209 |
| 217 private: | 210 private: |
| 218 // Creates and deletes |pc_factory_|, which in turn is used for | 211 // Creates |pc_factory_|, which in turn is used for |
| 219 // creating PeerConnection objects. | 212 // creating PeerConnection objects. |
| 220 bool CreatePeerConnectionFactory(); | 213 void CreatePeerConnectionFactory(); |
| 221 | 214 |
| 222 void InitializeWorkerThread(talk_base::Thread** thread, | 215 void InitializeWorkerThread(talk_base::Thread** thread, |
| 223 base::WaitableEvent* event); | 216 base::WaitableEvent* event); |
| 224 | 217 |
| 225 void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event); | 218 void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event); |
| 226 void DeleteIpcNetworkManager(); | 219 void DeleteIpcNetworkManager(); |
| 227 void CleanupPeerConnectionFactory(); | 220 void CleanupPeerConnectionFactory(); |
| 228 | 221 |
| 229 scoped_refptr<webrtc::AudioTrackInterface> | 222 scoped_refptr<webrtc::AudioTrackInterface> |
| 230 CreateNativeAudioMediaStreamTrack(const blink::WebMediaStreamTrack& track); | 223 CreateNativeAudioMediaStreamTrack(const blink::WebMediaStreamTrack& track); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 257 base::Thread chrome_worker_thread_; | 250 base::Thread chrome_worker_thread_; |
| 258 | 251 |
| 259 base::PlatformFile aec_dump_file_; | 252 base::PlatformFile aec_dump_file_; |
| 260 | 253 |
| 261 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); | 254 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); |
| 262 }; | 255 }; |
| 263 | 256 |
| 264 } // namespace content | 257 } // namespace content |
| 265 | 258 |
| 266 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ | 259 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ |
| OLD | NEW |