| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 class WebMediaStreamSource; | 40 class WebMediaStreamSource; |
| 41 class WebMediaStreamTrack; | 41 class WebMediaStreamTrack; |
| 42 class WebRTCPeerConnectionHandler; | 42 class WebRTCPeerConnectionHandler; |
| 43 class WebRTCPeerConnectionHandlerClient; | 43 class WebRTCPeerConnectionHandlerClient; |
| 44 } | 44 } |
| 45 | 45 |
| 46 namespace content { | 46 namespace content { |
| 47 | 47 |
| 48 class IpcNetworkManager; | 48 class IpcNetworkManager; |
| 49 class IpcPacketSocketFactory; | 49 class IpcPacketSocketFactory; |
| 50 class MediaStreamAudioSource; | |
| 51 class WebAudioCapturerSource; | |
| 52 class WebRtcAudioCapturer; | |
| 53 class WebRtcAudioDeviceImpl; | 50 class WebRtcAudioDeviceImpl; |
| 54 class WebRtcLocalAudioTrack; | |
| 55 class WebRtcLoggingHandlerImpl; | 51 class WebRtcLoggingHandlerImpl; |
| 56 class WebRtcLoggingMessageFilter; | 52 class WebRtcLoggingMessageFilter; |
| 57 class WebRtcVideoCapturerAdapter; | 53 class WebRtcVideoCapturerAdapter; |
| 58 struct StreamDeviceInfo; | 54 struct StreamDeviceInfo; |
| 59 | 55 |
| 60 // Object factory for RTC PeerConnections. | 56 // Object factory for RTC PeerConnections. |
| 61 class CONTENT_EXPORT PeerConnectionDependencyFactory | 57 class CONTENT_EXPORT PeerConnectionDependencyFactory |
| 62 : NON_EXPORTED_BASE(base::MessageLoop::DestructionObserver), | 58 : NON_EXPORTED_BASE(base::MessageLoop::DestructionObserver), |
| 63 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 59 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 64 public: | 60 public: |
| 65 PeerConnectionDependencyFactory( | 61 PeerConnectionDependencyFactory( |
| 66 P2PSocketDispatcher* p2p_socket_dispatcher); | 62 P2PSocketDispatcher* p2p_socket_dispatcher); |
| 67 ~PeerConnectionDependencyFactory() override; | 63 ~PeerConnectionDependencyFactory() override; |
| 68 | 64 |
| 69 // Create a RTCPeerConnectionHandler object that implements the | 65 // Create a RTCPeerConnectionHandler object that implements the |
| 70 // WebKit WebRTCPeerConnectionHandler interface. | 66 // WebKit WebRTCPeerConnectionHandler interface. |
| 71 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 67 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( |
| 72 blink::WebRTCPeerConnectionHandlerClient* client); | 68 blink::WebRTCPeerConnectionHandlerClient* client); |
| 73 | 69 |
| 74 // Generate an ECDSA certificate. | 70 // Generate an ECDSA certificate. |
| 75 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate(); | 71 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate(); |
| 76 | 72 |
| 77 // Asks the PeerConnection factory to create a Local MediaStream object. | 73 // Asks the PeerConnection factory to create a Local MediaStream object. |
| 78 virtual scoped_refptr<webrtc::MediaStreamInterface> | 74 virtual scoped_refptr<webrtc::MediaStreamInterface> |
| 79 CreateLocalMediaStream(const std::string& label); | 75 CreateLocalMediaStream(const std::string& label); |
| 80 | 76 |
| 81 // InitializeMediaStreamAudioSource initialize a MediaStream source object | |
| 82 // for audio input. | |
| 83 bool InitializeMediaStreamAudioSource( | |
| 84 int render_frame_id, | |
| 85 const blink::WebMediaConstraints& audio_constraints, | |
| 86 MediaStreamAudioSource* source_data); | |
| 87 | |
| 88 // Creates an implementation of a cricket::VideoCapturer object that can be | 77 // Creates an implementation of a cricket::VideoCapturer object that can be |
| 89 // used when creating a libjingle webrtc::VideoTrackSourceInterface object. | 78 // used when creating a libjingle webrtc::VideoTrackSourceInterface object. |
| 90 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer( | 79 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer( |
| 91 bool is_screen_capture); | 80 bool is_screen_capture); |
| 92 | 81 |
| 93 // Creates an instance of WebRtcLocalAudioTrack and stores it | |
| 94 // in the extraData field of |track|. | |
| 95 void CreateLocalAudioTrack(const blink::WebMediaStreamTrack& track); | |
| 96 | |
| 97 // Creates an instance of MediaStreamRemoteAudioTrack and associates with the | |
| 98 // |track| object. | |
| 99 void CreateRemoteAudioTrack(const blink::WebMediaStreamTrack& track); | |
| 100 | |
| 101 // Asks the PeerConnection factory to create a Local VideoTrack object. | 82 // Asks the PeerConnection factory to create a Local VideoTrack object. |
| 102 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( | 83 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( |
| 103 const std::string& id, | 84 const std::string& id, |
| 104 webrtc::VideoTrackSourceInterface* source); | 85 webrtc::VideoTrackSourceInterface* source); |
| 105 | 86 |
| 106 // Asks the PeerConnection factory to create a Video Source. | 87 // Asks the PeerConnection factory to create a Video Source. |
| 107 // The video source takes ownership of |capturer|. | 88 // The video source takes ownership of |capturer|. |
| 108 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource( | 89 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource( |
| 109 cricket::VideoCapturer* capturer); | 90 cricket::VideoCapturer* capturer); |
| 110 | 91 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 135 | 116 |
| 136 // Starts recording an RTC event log. | 117 // Starts recording an RTC event log. |
| 137 virtual void StopRtcEventLog(); | 118 virtual void StopRtcEventLog(); |
| 138 | 119 |
| 139 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); | 120 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); |
| 140 | 121 |
| 141 void EnsureInitialized(); | 122 void EnsureInitialized(); |
| 142 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; | 123 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; |
| 143 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const; | 124 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const; |
| 144 | 125 |
| 145 protected: | 126 // Called by ProcessedLocalAudioSource to have the PeerConnection factory |
| 146 // Asks the PeerConnection factory to create a Local Audio Source. | 127 // create the corresponding WebRtc-internal instance. |
| 147 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource( | 128 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource( |
| 148 const cricket::AudioOptions& options); | 129 const cricket::AudioOptions& options); |
| 149 | 130 |
| 150 // Creates a media::AudioCapturerSource with an implementation that is | 131 protected: |
| 151 // specific for a WebAudio source. The created WebAudioCapturerSource | |
| 152 // instance will function as audio source instead of the default | |
| 153 // WebRtcAudioCapturer. Ownership of the new WebAudioCapturerSource is | |
| 154 // transferred to |source|. | |
| 155 virtual void CreateWebAudioSource(blink::WebMediaStreamSource* source); | |
| 156 | |
| 157 // Asks the PeerConnection factory to create a Local VideoTrack object with | 132 // Asks the PeerConnection factory to create a Local VideoTrack object with |
| 158 // the video source using |capturer|. | 133 // the video source using |capturer|. |
| 159 virtual scoped_refptr<webrtc::VideoTrackInterface> | 134 virtual scoped_refptr<webrtc::VideoTrackInterface> |
| 160 CreateLocalVideoTrack(const std::string& id, | 135 CreateLocalVideoTrack(const std::string& id, |
| 161 cricket::VideoCapturer* capturer); | 136 cricket::VideoCapturer* capturer); |
| 162 | 137 |
| 163 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& | 138 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& |
| 164 GetPcFactory(); | 139 GetPcFactory(); |
| 165 virtual bool PeerConnectionFactoryCreated(); | 140 virtual bool PeerConnectionFactoryCreated(); |
| 166 | 141 |
| 167 // Returns a new capturer or existing capturer based on the |render_frame_id| | |
| 168 // and |device_info|; if both are valid, it reuses existing capture if any -- | |
| 169 // otherwise it creates a new capturer. | |
| 170 virtual std::unique_ptr<WebRtcAudioCapturer> CreateAudioCapturer( | |
| 171 int render_frame_id, | |
| 172 const StreamDeviceInfo& device_info, | |
| 173 const blink::WebMediaConstraints& constraints, | |
| 174 MediaStreamAudioSource* audio_source); | |
| 175 | |
| 176 private: | 142 private: |
| 177 // Implement base::MessageLoop::DestructionObserver. | 143 // Implement base::MessageLoop::DestructionObserver. |
| 178 // This makes sure the libjingle PeerConnectionFactory is released before | 144 // This makes sure the libjingle PeerConnectionFactory is released before |
| 179 // the renderer message loop is destroyed. | 145 // the renderer message loop is destroyed. |
| 180 void WillDestroyCurrentMessageLoop() override; | 146 void WillDestroyCurrentMessageLoop() override; |
| 181 | 147 |
| 182 // Functions related to Stun probing trial to determine how fast we could send | 148 // Functions related to Stun probing trial to determine how fast we could send |
| 183 // Stun request without being dropped by NAT. | 149 // Stun request without being dropped by NAT. |
| 184 void TryScheduleStunProbeTrial(); | 150 void TryScheduleStunProbeTrial(); |
| 185 void StartStunProbeTrialOnWorkerThread(const std::string& params); | 151 void StartStunProbeTrialOnWorkerThread(const std::string& params); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 rtc::Thread* worker_thread_; | 186 rtc::Thread* worker_thread_; |
| 221 base::Thread chrome_signaling_thread_; | 187 base::Thread chrome_signaling_thread_; |
| 222 base::Thread chrome_worker_thread_; | 188 base::Thread chrome_worker_thread_; |
| 223 | 189 |
| 224 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); | 190 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); |
| 225 }; | 191 }; |
| 226 | 192 |
| 227 } // namespace content | 193 } // namespace content |
| 228 | 194 |
| 229 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 195 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ |
| OLD | NEW |