Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: content/renderer/media/webrtc/peer_connection_dependency_factory.h

Issue 1966043006: Revert of MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
50 class WebRtcAudioDeviceImpl; 53 class WebRtcAudioDeviceImpl;
54 class WebRtcLocalAudioTrack;
51 class WebRtcLoggingHandlerImpl; 55 class WebRtcLoggingHandlerImpl;
52 class WebRtcLoggingMessageFilter; 56 class WebRtcLoggingMessageFilter;
53 class WebRtcVideoCapturerAdapter; 57 class WebRtcVideoCapturerAdapter;
54 struct StreamDeviceInfo; 58 struct StreamDeviceInfo;
55 59
56 // Object factory for RTC PeerConnections. 60 // Object factory for RTC PeerConnections.
57 class CONTENT_EXPORT PeerConnectionDependencyFactory 61 class CONTENT_EXPORT PeerConnectionDependencyFactory
58 : NON_EXPORTED_BASE(base::MessageLoop::DestructionObserver), 62 : NON_EXPORTED_BASE(base::MessageLoop::DestructionObserver),
59 NON_EXPORTED_BASE(public base::NonThreadSafe) { 63 NON_EXPORTED_BASE(public base::NonThreadSafe) {
60 public: 64 public:
61 PeerConnectionDependencyFactory( 65 PeerConnectionDependencyFactory(
62 P2PSocketDispatcher* p2p_socket_dispatcher); 66 P2PSocketDispatcher* p2p_socket_dispatcher);
63 ~PeerConnectionDependencyFactory() override; 67 ~PeerConnectionDependencyFactory() override;
64 68
65 // Create a RTCPeerConnectionHandler object that implements the 69 // Create a RTCPeerConnectionHandler object that implements the
66 // WebKit WebRTCPeerConnectionHandler interface. 70 // WebKit WebRTCPeerConnectionHandler interface.
67 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( 71 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler(
68 blink::WebRTCPeerConnectionHandlerClient* client); 72 blink::WebRTCPeerConnectionHandlerClient* client);
69 73
70 // Generate an ECDSA certificate. 74 // Generate an ECDSA certificate.
71 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate(); 75 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateDefaultCertificate();
72 76
73 // Asks the PeerConnection factory to create a Local MediaStream object. 77 // Asks the PeerConnection factory to create a Local MediaStream object.
74 virtual scoped_refptr<webrtc::MediaStreamInterface> 78 virtual scoped_refptr<webrtc::MediaStreamInterface>
75 CreateLocalMediaStream(const std::string& label); 79 CreateLocalMediaStream(const std::string& label);
76 80
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
77 // Creates an implementation of a cricket::VideoCapturer object that can be 88 // Creates an implementation of a cricket::VideoCapturer object that can be
78 // used when creating a libjingle webrtc::VideoTrackSourceInterface object. 89 // used when creating a libjingle webrtc::VideoTrackSourceInterface object.
79 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer( 90 virtual WebRtcVideoCapturerAdapter* CreateVideoCapturer(
80 bool is_screen_capture); 91 bool is_screen_capture);
81 92
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
82 // Asks the PeerConnection factory to create a Local VideoTrack object. 101 // Asks the PeerConnection factory to create a Local VideoTrack object.
83 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( 102 virtual scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack(
84 const std::string& id, 103 const std::string& id,
85 webrtc::VideoTrackSourceInterface* source); 104 webrtc::VideoTrackSourceInterface* source);
86 105
87 // Asks the PeerConnection factory to create a Video Source. 106 // Asks the PeerConnection factory to create a Video Source.
88 // The video source takes ownership of |capturer|. 107 // The video source takes ownership of |capturer|.
89 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource( 108 virtual scoped_refptr<webrtc::VideoTrackSourceInterface> CreateVideoSource(
90 cricket::VideoCapturer* capturer); 109 cricket::VideoCapturer* capturer);
91 110
(...skipping 22 matching lines...) Expand all
114 // Starts recording an RTC event log. 133 // Starts recording an RTC event log.
115 virtual bool StartRtcEventLog(base::PlatformFile file); 134 virtual bool StartRtcEventLog(base::PlatformFile file);
116 135
117 // Starts recording an RTC event log. 136 // Starts recording an RTC event log.
118 virtual void StopRtcEventLog(); 137 virtual void StopRtcEventLog();
119 138
120 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); 139 WebRtcAudioDeviceImpl* GetWebRtcAudioDevice();
121 140
122 void EnsureInitialized(); 141 void EnsureInitialized();
123 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; 142 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const;
124 virtual scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() 143 scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const;
125 const;
126 144
127 // Called by ProcessedLocalAudioSource to have the PeerConnection factory 145 protected:
128 // create the corresponding WebRtc-internal instance. 146 // Asks the PeerConnection factory to create a Local Audio Source.
129 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource( 147 virtual scoped_refptr<webrtc::AudioSourceInterface> CreateLocalAudioSource(
130 const cricket::AudioOptions& options); 148 const cricket::AudioOptions& options);
131 149
132 protected: 150 // Creates a media::AudioCapturerSource with an implementation that is
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
133 // Asks the PeerConnection factory to create a Local VideoTrack object with 157 // Asks the PeerConnection factory to create a Local VideoTrack object with
134 // the video source using |capturer|. 158 // the video source using |capturer|.
135 virtual scoped_refptr<webrtc::VideoTrackInterface> 159 virtual scoped_refptr<webrtc::VideoTrackInterface>
136 CreateLocalVideoTrack(const std::string& id, 160 CreateLocalVideoTrack(const std::string& id,
137 cricket::VideoCapturer* capturer); 161 cricket::VideoCapturer* capturer);
138 162
139 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& 163 virtual const scoped_refptr<webrtc::PeerConnectionFactoryInterface>&
140 GetPcFactory(); 164 GetPcFactory();
141 virtual bool PeerConnectionFactoryCreated(); 165 virtual bool PeerConnectionFactoryCreated();
142 166
143 // Helper method to create a WebRtcAudioDeviceImpl. 167 // Returns a new capturer or existing capturer based on the |render_frame_id|
144 void EnsureWebRtcAudioDeviceImpl(); 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);
145 175
146 private: 176 private:
147 // Implement base::MessageLoop::DestructionObserver. 177 // Implement base::MessageLoop::DestructionObserver.
148 // This makes sure the libjingle PeerConnectionFactory is released before 178 // This makes sure the libjingle PeerConnectionFactory is released before
149 // the renderer message loop is destroyed. 179 // the renderer message loop is destroyed.
150 void WillDestroyCurrentMessageLoop() override; 180 void WillDestroyCurrentMessageLoop() override;
151 181
152 // Functions related to Stun probing trial to determine how fast we could send 182 // Functions related to Stun probing trial to determine how fast we could send
153 // Stun request without being dropped by NAT. 183 // Stun request without being dropped by NAT.
154 void TryScheduleStunProbeTrial(); 184 void TryScheduleStunProbeTrial();
155 void StartStunProbeTrialOnWorkerThread(const std::string& params); 185 void StartStunProbeTrialOnWorkerThread(const std::string& params);
156 186
157 // Creates |pc_factory_|, which in turn is used for 187 // Creates |pc_factory_|, which in turn is used for
158 // creating PeerConnection objects. 188 // creating PeerConnection objects.
159 void CreatePeerConnectionFactory(); 189 void CreatePeerConnectionFactory();
160 190
161 void InitializeSignalingThread( 191 void InitializeSignalingThread(
162 media::GpuVideoAcceleratorFactories* gpu_factories, 192 media::GpuVideoAcceleratorFactories* gpu_factories,
163 base::WaitableEvent* event); 193 base::WaitableEvent* event);
164 194
165 void InitializeWorkerThread(rtc::Thread** thread, 195 void InitializeWorkerThread(rtc::Thread** thread,
166 base::WaitableEvent* event); 196 base::WaitableEvent* event);
167 197
168 void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event); 198 void CreateIpcNetworkManagerOnWorkerThread(base::WaitableEvent* event);
169 void DeleteIpcNetworkManager(); 199 void DeleteIpcNetworkManager();
170 void CleanupPeerConnectionFactory(); 200 void CleanupPeerConnectionFactory();
171 201
202 // Helper method to create a WebRtcAudioDeviceImpl.
203 void EnsureWebRtcAudioDeviceImpl();
204
172 // We own network_manager_, must be deleted on the worker thread. 205 // We own network_manager_, must be deleted on the worker thread.
173 // The network manager uses |p2p_socket_dispatcher_|. 206 // The network manager uses |p2p_socket_dispatcher_|.
174 IpcNetworkManager* network_manager_; 207 IpcNetworkManager* network_manager_;
175 std::unique_ptr<IpcPacketSocketFactory> socket_factory_; 208 std::unique_ptr<IpcPacketSocketFactory> socket_factory_;
176 209
177 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; 210 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
178 211
179 scoped_refptr<P2PSocketDispatcher> p2p_socket_dispatcher_; 212 scoped_refptr<P2PSocketDispatcher> p2p_socket_dispatcher_;
180 scoped_refptr<WebRtcAudioDeviceImpl> audio_device_; 213 scoped_refptr<WebRtcAudioDeviceImpl> audio_device_;
181 214
182 std::unique_ptr<StunProberTrial> stun_trial_; 215 std::unique_ptr<StunProberTrial> stun_trial_;
183 216
184 // PeerConnection threads. signaling_thread_ is created from the 217 // PeerConnection threads. signaling_thread_ is created from the
185 // "current" chrome thread. 218 // "current" chrome thread.
186 rtc::Thread* signaling_thread_; 219 rtc::Thread* signaling_thread_;
187 rtc::Thread* worker_thread_; 220 rtc::Thread* worker_thread_;
188 base::Thread chrome_signaling_thread_; 221 base::Thread chrome_signaling_thread_;
189 base::Thread chrome_worker_thread_; 222 base::Thread chrome_worker_thread_;
190 223
191 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory); 224 DISALLOW_COPY_AND_ASSIGN(PeerConnectionDependencyFactory);
192 }; 225 };
193 226
194 } // namespace content 227 } // namespace content
195 228
196 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_ 229 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_DEPENDENCY_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698