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