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 // Add an ECDSA certificate to |config| in case it contains no certificate. | 70 // Add an ECDSA certificate to |config| in case it contains no certificate. |
75 static void SetDefaultCertificate( | 71 static void SetDefaultCertificate( |
76 webrtc::PeerConnectionInterface::RTCConfiguration* config); | 72 webrtc::PeerConnectionInterface::RTCConfiguration* config); |
77 | 73 |
78 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate(); | 74 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate(); |
79 | 75 |
80 // Asks the PeerConnection factory to create a Local MediaStream object. | 76 // Asks the PeerConnection factory to create a Local MediaStream object. |
81 virtual scoped_refptr<webrtc::MediaStreamInterface> | 77 virtual scoped_refptr<webrtc::MediaStreamInterface> |
82 CreateLocalMediaStream(const std::string& label); | 78 CreateLocalMediaStream(const std::string& label); |
83 | 79 |
84 // InitializeMediaStreamAudioSource initialize a MediaStream source object | |
85 // for audio input. | |
86 bool InitializeMediaStreamAudioSource( | |
87 int render_frame_id, | |
88 const blink::WebMediaConstraints& audio_constraints, | |
89 MediaStreamAudioSource* source_data); | |
90 | |
91 // Creates an implementation of a cricket::VideoCapturer object that can be | 80 // Creates an implementation of a cricket::VideoCapturer object that can be |
92 // used when creating a libjingle webrtc::VideoTrackSourceInterface object. | 81 // used when creating a libjingle webrtc::VideoTrackSourceInterface object. |
93 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer( | 82 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer( |
94 bool is_screen_capture); | 83 bool is_screen_capture); |
95 | 84 |
96 // Creates an instance of WebRtcLocalAudioTrack and stores it | |
97 // in the extraData field of |track|. | |
98 void CreateLocalAudioTrack(const blink::WebMediaStreamTrack& track); | |
99 | |
100 // Creates an instance of MediaStreamRemoteAudioTrack and associates with the | |
101 // |track| object. | |
102 void CreateRemoteAudioTrack(const blink::WebMediaStreamTrack& track); | |
103 | |
104 // Asks the PeerConnection factory to create a Local VideoTrack object. | 85 // Asks the PeerConnection factory to create a Local VideoTrack object. |
105 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( | 86 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( |
106 const std::string& id, | 87 const std::string& id, |
107 webrtc::VideoTrackSourceInterface* source); | 88 webrtc::VideoTrackSourceInterface* source); |
108 | 89 |
109 // Asks the PeerConnection factory to create a Video Source. | 90 // Asks the PeerConnection factory to create a Video Source. |
110 // The video source takes ownership of |capturer|. | 91 // The video source takes ownership of |capturer|. |
111 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource( | 92 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource( |
112 cricket::VideoCapturer* capturer); | 93 cricket::VideoCapturer* capturer); |
113 | 94 |
(...skipping 24 matching lines...) Expand all Loading... |
138 | 119 |
139 // Starts recording an RTC event log. | 120 // Starts recording an RTC event log. |
140 virtual void StopRtcEventLog(); | 121 virtual void StopRtcEventLog(); |
141 | 122 |
142 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); | 123 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); |
143 | 124 |
144 void EnsureInitialized(); | 125 void EnsureInitialized(); |
145 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; | 126 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; |
146 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const; | 127 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const; |
147 | 128 |
148 protected: | 129 // Called by ProcessedLocalAudioSource to have the PeerConnection factory |
149 // Asks the PeerConnection factory to create a Local Audio Source. | 130 // create the corresponding WebRtc-internal instance. |
150 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource( | 131 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource( |
151 const cricket::AudioOptions& options); | 132 const cricket::AudioOptions& options); |
152 | 133 |
153 // Creates a media::AudioCapturerSource with an implementation that is | 134 protected: |
154 // specific for a WebAudio source. The created WebAudioCapturerSource | |
155 // instance will function as audio source instead of the default | |
156 // WebRtcAudioCapturer. Ownership of the new WebAudioCapturerSource is | |
157 // transferred to |source|. | |
158 virtual void CreateWebAudioSource(blink::WebMediaStreamSource* source); | |
159 | |
160 // Asks the PeerConnection factory to create a Local VideoTrack object with | 135 // Asks the PeerConnection factory to create a Local VideoTrack object with |
161 // the video source using |capturer|. | 136 // the video source using |capturer|. |
162 virtual scoped_refptr<webrtc::VideoTrackInterface> | 137 virtual scoped_refptr<webrtc::VideoTrackInterface> |
163 CreateLocalVideoTrack(const std::string& id, | 138 CreateLocalVideoTrack(const std::string& id, |
164 cricket::VideoCapturer* capturer); | 139 cricket::VideoCapturer* capturer); |
165 | 140 |
166 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& | 141 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& |
167 GetPcFactory(); | 142 GetPcFactory(); |
168 virtual bool PeerConnectionFactoryCreated(); | 143 virtual bool PeerConnectionFactoryCreated(); |
169 | 144 |
170 // Returns a new capturer or existing capturer based on the |render_frame_id| | |
171 // and |device_info|; if both are valid, it reuses existing capture if any -- | |
172 // otherwise it creates a new capturer. | |
173 virtual std::unique_ptr<WebRtcAudioCapturer> CreateAudioCapturer( | |
174 int render_frame_id, | |
175 const StreamDeviceInfo& device_info, | |
176 const blink::WebMediaConstraints& constraints, | |
177 MediaStreamAudioSource* audio_source); | |
178 | |
179 private: | 145 private: |
180 // Implement base::MessageLoop::DestructionObserver. | 146 // Implement base::MessageLoop::DestructionObserver. |
181 // This makes sure the libjingle PeerConnectionFactory is released before | 147 // This makes sure the libjingle PeerConnectionFactory is released before |
182 // the renderer message loop is destroyed. | 148 // the renderer message loop is destroyed. |
183 void WillDestroyCurrentMessageLoop() override; | 149 void WillDestroyCurrentMessageLoop() override; |
184 | 150 |
185 // Functions related to Stun probing trial to determine how fast we could send | 151 // Functions related to Stun probing trial to determine how fast we could send |
186 // Stun request without being dropped by NAT. | 152 // Stun request without being dropped by NAT. |
187 void TryScheduleStunProbeTrial(); | 153 void TryScheduleStunProbeTrial(); |
188 void StartStunProbeTrialOnWorkerThread(const std::string& params); | 154 void StartStunProbeTrialOnWorkerThread(const std::string& params); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 rtc::Thread* worker_thread_; | 189 rtc::Thread* worker_thread_; |
224 base::Thread chrome_signaling_thread_; | 190 base::Thread chrome_signaling_thread_; |
225 base::Thread chrome_worker_thread_; | 191 base::Thread chrome_worker_thread_; |
226 | 192 |
227 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); | 193 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); |
228 }; | 194 }; |
229 | 195 |
230 } // namespace content | 196 } // namespace content |
231 | 197 |
232 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ | 198 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ |
OLD | NEW |