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