| 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 12 matching lines...) Expand all Loading... |
| 23 namespace talk_base { | 23 namespace talk_base { |
| 24 class NetworkManager; | 24 class NetworkManager; |
| 25 class PacketSocketFactory; | 25 class PacketSocketFactory; |
| 26 class Thread; | 26 class Thread; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace webrtc { | 29 namespace webrtc { |
| 30 class PeerConnection; | 30 class PeerConnection; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace WebKit { | 33 namespace blink { |
| 34 class WebFrame; | 34 class WebFrame; |
| 35 class WebMediaConstraints; | 35 class WebMediaConstraints; |
| 36 class WebMediaStream; | 36 class WebMediaStream; |
| 37 class WebRTCPeerConnectionHandler; | 37 class WebRTCPeerConnectionHandler; |
| 38 class WebRTCPeerConnectionHandlerClient; | 38 class WebRTCPeerConnectionHandlerClient; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace content { | 41 namespace content { |
| 42 | 42 |
| 43 class IpcNetworkManager; | 43 class IpcNetworkManager; |
| 44 class IpcPacketSocketFactory; | 44 class IpcPacketSocketFactory; |
| 45 class RTCMediaConstraints; | 45 class RTCMediaConstraints; |
| 46 class VideoCaptureImplManager; | 46 class VideoCaptureImplManager; |
| 47 class WebAudioCapturerSource; | 47 class WebAudioCapturerSource; |
| 48 class WebRtcAudioCapturer; | 48 class WebRtcAudioCapturer; |
| 49 class WebRtcAudioDeviceImpl; | 49 class WebRtcAudioDeviceImpl; |
| 50 class WebRtcLoggingHandlerImpl; | 50 class WebRtcLoggingHandlerImpl; |
| 51 class WebRtcLoggingMessageFilter; | 51 class WebRtcLoggingMessageFilter; |
| 52 struct StreamDeviceInfo; | 52 struct StreamDeviceInfo; |
| 53 | 53 |
| 54 #if defined(GOOGLE_TV) | 54 #if defined(GOOGLE_TV) |
| 55 class RTCVideoDecoderFactoryTv; | 55 class RTCVideoDecoderFactoryTv; |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 // Object factory for RTC MediaStreams and RTC PeerConnections. | 58 // Object factory for RTC MediaStreams and RTC PeerConnections. |
| 59 class CONTENT_EXPORT MediaStreamDependencyFactory | 59 class CONTENT_EXPORT MediaStreamDependencyFactory |
| 60 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 60 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 61 public: | 61 public: |
| 62 // MediaSourcesCreatedCallback is used in CreateNativeMediaSources. | 62 // MediaSourcesCreatedCallback is used in CreateNativeMediaSources. |
| 63 typedef base::Callback<void(WebKit::WebMediaStream* web_stream, | 63 typedef base::Callback<void(blink::WebMediaStream* web_stream, |
| 64 bool live)> MediaSourcesCreatedCallback; | 64 bool live)> MediaSourcesCreatedCallback; |
| 65 MediaStreamDependencyFactory( | 65 MediaStreamDependencyFactory( |
| 66 VideoCaptureImplManager* vc_manager, | 66 VideoCaptureImplManager* vc_manager, |
| 67 P2PSocketDispatcher* p2p_socket_dispatcher); | 67 P2PSocketDispatcher* p2p_socket_dispatcher); |
| 68 virtual ~MediaStreamDependencyFactory(); | 68 virtual ~MediaStreamDependencyFactory(); |
| 69 | 69 |
| 70 // Create a RTCPeerConnectionHandler object that implements the | 70 // Create a RTCPeerConnectionHandler object that implements the |
| 71 // WebKit WebRTCPeerConnectionHandler interface. | 71 // WebKit WebRTCPeerConnectionHandler interface. |
| 72 WebKit::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 72 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( |
| 73 WebKit::WebRTCPeerConnectionHandlerClient* client); | 73 blink::WebRTCPeerConnectionHandlerClient* client); |
| 74 | 74 |
| 75 // CreateNativeMediaSources creates libjingle representations of | 75 // CreateNativeMediaSources creates libjingle representations of |
| 76 // the underlying sources to the tracks in |web_stream|. | 76 // the underlying sources to the tracks in |web_stream|. |
| 77 // |sources_created| is invoked when the sources have either been created and | 77 // |sources_created| is invoked when the sources have either been created and |
| 78 // transitioned to a live state or failed. | 78 // transitioned to a live state or failed. |
| 79 // The libjingle sources is stored in the extra data field of | 79 // The libjingle sources is stored in the extra data field of |
| 80 // WebMediaStreamSource. | 80 // WebMediaStreamSource. |
| 81 // |audio_constraints| and |video_constraints| set parameters for the sources. | 81 // |audio_constraints| and |video_constraints| set parameters for the sources. |
| 82 void CreateNativeMediaSources( | 82 void CreateNativeMediaSources( |
| 83 int render_view_id, | 83 int render_view_id, |
| 84 const WebKit::WebMediaConstraints& audio_constraints, | 84 const blink::WebMediaConstraints& audio_constraints, |
| 85 const WebKit::WebMediaConstraints& video_constraints, | 85 const blink::WebMediaConstraints& video_constraints, |
| 86 WebKit::WebMediaStream* web_stream, | 86 blink::WebMediaStream* web_stream, |
| 87 const MediaSourcesCreatedCallback& sources_created); | 87 const MediaSourcesCreatedCallback& sources_created); |
| 88 | 88 |
| 89 // Creates a libjingle representation of a MediaStream and stores | 89 // Creates a libjingle representation of a MediaStream and stores |
| 90 // it in the extra data field of |web_stream|. | 90 // it in the extra data field of |web_stream|. |
| 91 void CreateNativeLocalMediaStream( | 91 void CreateNativeLocalMediaStream( |
| 92 WebKit::WebMediaStream* web_stream); | 92 blink::WebMediaStream* web_stream); |
| 93 | 93 |
| 94 // Creates a libjingle representation of a MediaStream and stores | 94 // Creates a libjingle representation of a MediaStream and stores |
| 95 // it in the extra data field of |web_stream|. | 95 // it in the extra data field of |web_stream|. |
| 96 // |stream_stopped| is a callback that is run when a MediaStream have been | 96 // |stream_stopped| is a callback that is run when a MediaStream have been |
| 97 // stopped. | 97 // stopped. |
| 98 void CreateNativeLocalMediaStream( | 98 void CreateNativeLocalMediaStream( |
| 99 WebKit::WebMediaStream* web_stream, | 99 blink::WebMediaStream* web_stream, |
| 100 const MediaStreamExtraData::StreamStopCallback& stream_stop); | 100 const MediaStreamExtraData::StreamStopCallback& stream_stop); |
| 101 | 101 |
| 102 // Adds a libjingle representation of a MediaStreamTrack to |stream| based | 102 // Adds a libjingle representation of a MediaStreamTrack to |stream| based |
| 103 // on the source of |track|. | 103 // on the source of |track|. |
| 104 bool AddNativeMediaStreamTrack(const WebKit::WebMediaStream& stream, | 104 bool AddNativeMediaStreamTrack(const blink::WebMediaStream& stream, |
| 105 const WebKit::WebMediaStreamTrack& track); | 105 const blink::WebMediaStreamTrack& track); |
| 106 | 106 |
| 107 // Creates and adds libjingle representation of a MediaStreamTrack to |stream| | 107 // Creates and adds libjingle representation of a MediaStreamTrack to |stream| |
| 108 // based on the desired |track_id| and |capturer|. | 108 // based on the desired |track_id| and |capturer|. |
| 109 bool AddNativeVideoMediaTrack(const std::string& track_id, | 109 bool AddNativeVideoMediaTrack(const std::string& track_id, |
| 110 WebKit::WebMediaStream* stream, | 110 blink::WebMediaStream* stream, |
| 111 cricket::VideoCapturer* capturer); | 111 cricket::VideoCapturer* capturer); |
| 112 | 112 |
| 113 bool RemoveNativeMediaStreamTrack(const WebKit::WebMediaStream& stream, | 113 bool RemoveNativeMediaStreamTrack(const blink::WebMediaStream& stream, |
| 114 const WebKit::WebMediaStreamTrack& track); | 114 const blink::WebMediaStreamTrack& track); |
| 115 | 115 |
| 116 // Asks the libjingle PeerConnection factory to create a libjingle | 116 // Asks the libjingle PeerConnection factory to create a libjingle |
| 117 // PeerConnection object. | 117 // PeerConnection object. |
| 118 // The PeerConnection object is owned by PeerConnectionHandler. | 118 // The PeerConnection object is owned by PeerConnectionHandler. |
| 119 virtual scoped_refptr<webrtc::PeerConnectionInterface> | 119 virtual scoped_refptr<webrtc::PeerConnectionInterface> |
| 120 CreatePeerConnection( | 120 CreatePeerConnection( |
| 121 const webrtc::PeerConnectionInterface::IceServers& ice_servers, | 121 const webrtc::PeerConnectionInterface::IceServers& ice_servers, |
| 122 const webrtc::MediaConstraintsInterface* constraints, | 122 const webrtc::MediaConstraintsInterface* constraints, |
| 123 WebKit::WebFrame* web_frame, | 123 blink::WebFrame* web_frame, |
| 124 webrtc::PeerConnectionObserver* observer); | 124 webrtc::PeerConnectionObserver* observer); |
| 125 | 125 |
| 126 // Creates a libjingle representation of a Session description. Used by a | 126 // Creates a libjingle representation of a Session description. Used by a |
| 127 // RTCPeerConnectionHandler instance. | 127 // RTCPeerConnectionHandler instance. |
| 128 virtual webrtc::SessionDescriptionInterface* CreateSessionDescription( | 128 virtual webrtc::SessionDescriptionInterface* CreateSessionDescription( |
| 129 const std::string& type, | 129 const std::string& type, |
| 130 const std::string& sdp, | 130 const std::string& sdp, |
| 131 webrtc::SdpParseError* error); | 131 webrtc::SdpParseError* error); |
| 132 | 132 |
| 133 // Creates a libjingle representation of an ice candidate. | 133 // Creates a libjingle representation of an ice candidate. |
| 134 virtual webrtc::IceCandidateInterface* CreateIceCandidate( | 134 virtual webrtc::IceCandidateInterface* CreateIceCandidate( |
| 135 const std::string& sdp_mid, | 135 const std::string& sdp_mid, |
| 136 int sdp_mline_index, | 136 int sdp_mline_index, |
| 137 const std::string& sdp); | 137 const std::string& sdp); |
| 138 | 138 |
| 139 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); | 139 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); |
| 140 | 140 |
| 141 #if defined(GOOGLE_TV) | 141 #if defined(GOOGLE_TV) |
| 142 RTCVideoDecoderFactoryTv* decoder_factory_tv() { return decoder_factory_tv_; } | 142 RTCVideoDecoderFactoryTv* decoder_factory_tv() { return decoder_factory_tv_; } |
| 143 #endif | 143 #endif |
| 144 | 144 |
| 145 static void AddNativeTrackToBlinkTrack( | 145 static void AddNativeTrackToBlinkTrack( |
| 146 webrtc::MediaStreamTrackInterface* native_track, | 146 webrtc::MediaStreamTrackInterface* native_track, |
| 147 const WebKit::WebMediaStreamTrack& webkit_track); | 147 const blink::WebMediaStreamTrack& webkit_track); |
| 148 | 148 |
| 149 static webrtc::MediaStreamInterface* GetNativeMediaStream( | 149 static webrtc::MediaStreamInterface* GetNativeMediaStream( |
| 150 const WebKit::WebMediaStream& stream); | 150 const blink::WebMediaStream& stream); |
| 151 | 151 |
| 152 static webrtc::MediaStreamTrackInterface* GetNativeMediaStreamTrack( | 152 static webrtc::MediaStreamTrackInterface* GetNativeMediaStreamTrack( |
| 153 const WebKit::WebMediaStreamTrack& track); | 153 const blink::WebMediaStreamTrack& track); |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 // Asks the PeerConnection factory to create a Local MediaStream object. | 156 // Asks the PeerConnection factory to create a Local MediaStream object. |
| 157 virtual scoped_refptr<webrtc::MediaStreamInterface> | 157 virtual scoped_refptr<webrtc::MediaStreamInterface> |
| 158 CreateLocalMediaStream(const std::string& label); | 158 CreateLocalMediaStream(const std::string& label); |
| 159 | 159 |
| 160 // Asks the PeerConnection factory to create a Local Audio Source. | 160 // Asks the PeerConnection factory to create a Local Audio Source. |
| 161 virtual scoped_refptr<webrtc::AudioSourceInterface> | 161 virtual scoped_refptr<webrtc::AudioSourceInterface> |
| 162 CreateLocalAudioSource( | 162 CreateLocalAudioSource( |
| 163 const webrtc::MediaConstraintsInterface* constraints); | 163 const webrtc::MediaConstraintsInterface* constraints); |
| 164 | 164 |
| 165 // Asks the PeerConnection factory to create a Local Video Source. | 165 // Asks the PeerConnection factory to create a Local Video Source. |
| 166 virtual scoped_refptr<webrtc::VideoSourceInterface> | 166 virtual scoped_refptr<webrtc::VideoSourceInterface> |
| 167 CreateLocalVideoSource( | 167 CreateLocalVideoSource( |
| 168 int video_session_id, | 168 int video_session_id, |
| 169 bool is_screen_cast, | 169 bool is_screen_cast, |
| 170 const webrtc::MediaConstraintsInterface* constraints); | 170 const webrtc::MediaConstraintsInterface* constraints); |
| 171 | 171 |
| 172 // Creates a media::AudioCapturerSource with an implementation that is | 172 // Creates a media::AudioCapturerSource with an implementation that is |
| 173 // specific for a WebAudio source. The created WebAudioCapturerSource | 173 // specific for a WebAudio source. The created WebAudioCapturerSource |
| 174 // instance will function as audio source instead of the default | 174 // instance will function as audio source instead of the default |
| 175 // WebRtcAudioCapturer. | 175 // WebRtcAudioCapturer. |
| 176 // The |constraints| will be modified to include the default, mandatory | 176 // The |constraints| will be modified to include the default, mandatory |
| 177 // WebAudio constraints. | 177 // WebAudio constraints. |
| 178 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( | 178 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( |
| 179 WebKit::WebMediaStreamSource* source, RTCMediaConstraints* constraints); | 179 blink::WebMediaStreamSource* source, RTCMediaConstraints* constraints); |
| 180 | 180 |
| 181 // Asks the PeerConnection factory to create a Local AudioTrack object. | 181 // Asks the PeerConnection factory to create a Local AudioTrack object. |
| 182 virtual scoped_refptr<webrtc::AudioTrackInterface> | 182 virtual scoped_refptr<webrtc::AudioTrackInterface> |
| 183 CreateLocalAudioTrack( | 183 CreateLocalAudioTrack( |
| 184 const std::string& id, | 184 const std::string& id, |
| 185 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 185 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
| 186 WebAudioCapturerSource* webaudio_source, | 186 WebAudioCapturerSource* webaudio_source, |
| 187 webrtc::AudioSourceInterface* source, | 187 webrtc::AudioSourceInterface* source, |
| 188 const webrtc::MediaConstraintsInterface* constraints); | 188 const webrtc::MediaConstraintsInterface* constraints); |
| 189 | 189 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 talk_base::Thread* signaling_thread_; | 241 talk_base::Thread* signaling_thread_; |
| 242 talk_base::Thread* worker_thread_; | 242 talk_base::Thread* worker_thread_; |
| 243 base::Thread chrome_worker_thread_; | 243 base::Thread chrome_worker_thread_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); | 245 DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace content | 248 } // namespace content |
| 249 | 249 |
| 250 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ | 250 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ |
| OLD | NEW |