henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2004--2011 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "talk/app/webrtc/peerconnectionfactory.h" |
| 29 | |
| 30 | #include "talk/app/webrtc/audiotrack.h" |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 31 | #include "talk/app/webrtc/dtlsidentityservice.h" |
| 32 | #include "talk/app/webrtc/dtlsidentitystore.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | #include "talk/app/webrtc/localaudiosource.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | #include "talk/app/webrtc/mediastreamproxy.h" |
| 35 | #include "talk/app/webrtc/mediastreamtrackproxy.h" |
| 36 | #include "talk/app/webrtc/peerconnection.h" |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 37 | #include "talk/app/webrtc/peerconnectionfactoryproxy.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | #include "talk/app/webrtc/peerconnectionproxy.h" |
| 39 | #include "talk/app/webrtc/portallocatorfactory.h" |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 40 | #include "talk/app/webrtc/videosource.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | #include "talk/app/webrtc/videosourceproxy.h" |
| 42 | #include "talk/app/webrtc/videotrack.h" |
| 43 | #include "talk/media/devices/dummydevicemanager.h" |
| 44 | #include "talk/media/webrtc/webrtcmediaengine.h" |
| 45 | #include "talk/media/webrtc/webrtcvideodecoderfactory.h" |
| 46 | #include "talk/media/webrtc/webrtcvideoencoderfactory.h" |
jiayl@webrtc.org | 3987b6d | 2014-09-24 17:14:05 +0000 | [diff] [blame] | 47 | #include "webrtc/base/bind.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 48 | #include "webrtc/modules/audio_device/include/audio_device.h" |
| 49 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | namespace webrtc { |
| 51 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 52 | rtc::scoped_refptr<PeerConnectionFactoryInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 53 | CreatePeerConnectionFactory() { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 54 | rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
| 55 | new rtc::RefCountedObject<PeerConnectionFactory>()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 56 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 57 | |
| 58 | // Call Initialize synchronously but make sure its executed on |
| 59 | // |signaling_thread|. |
| 60 | MethodCall0<PeerConnectionFactory, bool> call( |
| 61 | pc_factory.get(), |
| 62 | &PeerConnectionFactory::Initialize); |
| 63 | bool result = call.Marshal(pc_factory->signaling_thread()); |
| 64 | |
| 65 | if (!result) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | return NULL; |
| 67 | } |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 68 | return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), |
| 69 | pc_factory); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | } |
| 71 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 72 | rtc::scoped_refptr<PeerConnectionFactoryInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 73 | CreatePeerConnectionFactory( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 74 | rtc::Thread* worker_thread, |
| 75 | rtc::Thread* signaling_thread, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 76 | AudioDeviceModule* default_adm, |
| 77 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 78 | cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 79 | rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
| 80 | new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 81 | signaling_thread, |
| 82 | default_adm, |
| 83 | encoder_factory, |
| 84 | decoder_factory)); |
| 85 | |
| 86 | // Call Initialize synchronously but make sure its executed on |
| 87 | // |signaling_thread|. |
| 88 | MethodCall0<PeerConnectionFactory, bool> call( |
| 89 | pc_factory.get(), |
| 90 | &PeerConnectionFactory::Initialize); |
| 91 | bool result = call.Marshal(signaling_thread); |
| 92 | |
| 93 | if (!result) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 94 | return NULL; |
| 95 | } |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 96 | return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | PeerConnectionFactory::PeerConnectionFactory() |
| 100 | : owns_ptrs_(true), |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 101 | wraps_current_thread_(false), |
| 102 | signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 103 | worker_thread_(new rtc::Thread) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 104 | if (!signaling_thread_) { |
| 105 | signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
| 106 | wraps_current_thread_ = true; |
| 107 | } |
| 108 | worker_thread_->Start(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | PeerConnectionFactory::PeerConnectionFactory( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 112 | rtc::Thread* worker_thread, |
| 113 | rtc::Thread* signaling_thread, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 114 | AudioDeviceModule* default_adm, |
| 115 | cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 116 | cricket::WebRtcVideoDecoderFactory* video_decoder_factory) |
| 117 | : owns_ptrs_(false), |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 118 | wraps_current_thread_(false), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 119 | signaling_thread_(signaling_thread), |
| 120 | worker_thread_(worker_thread), |
| 121 | default_adm_(default_adm), |
| 122 | video_encoder_factory_(video_encoder_factory), |
| 123 | video_decoder_factory_(video_decoder_factory) { |
| 124 | ASSERT(worker_thread != NULL); |
| 125 | ASSERT(signaling_thread != NULL); |
| 126 | // TODO: Currently there is no way creating an external adm in |
| 127 | // libjingle source tree. So we can 't currently assert if this is NULL. |
| 128 | // ASSERT(default_adm != NULL); |
| 129 | } |
| 130 | |
| 131 | PeerConnectionFactory::~PeerConnectionFactory() { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 132 | DCHECK(signaling_thread_->IsCurrent()); |
| 133 | channel_manager_.reset(NULL); |
phoglund@webrtc.org | 006521d | 2015-02-12 09:23:59 +0000 | [diff] [blame] | 134 | default_allocator_factory_ = NULL; |
jiayl@webrtc.org | d83f4ef | 2015-03-13 21:26:12 +0000 | [diff] [blame] | 135 | |
| 136 | // Make sure |worker_thread_| and |signaling_thread_| outlive |
| 137 | // |dtls_identity_store_|. |
| 138 | dtls_identity_store_.reset(NULL); |
| 139 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 140 | if (owns_ptrs_) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 141 | if (wraps_current_thread_) |
| 142 | rtc::ThreadManager::Instance()->UnwrapCurrentThread(); |
fischman@webrtc.org | 29540b1 | 2014-04-17 22:54:30 +0000 | [diff] [blame] | 143 | delete worker_thread_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
| 147 | bool PeerConnectionFactory::Initialize() { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 148 | DCHECK(signaling_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 149 | rtc::InitRandom(rtc::Time()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 150 | |
phoglund@webrtc.org | 006521d | 2015-02-12 09:23:59 +0000 | [diff] [blame] | 151 | default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_); |
| 152 | if (!default_allocator_factory_) |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 153 | return false; |
| 154 | |
| 155 | cricket::DummyDeviceManager* device_manager( |
| 156 | new cricket::DummyDeviceManager()); |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 157 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 158 | // TODO: Need to make sure only one VoE is created inside |
| 159 | // WebRtcMediaEngine. |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 160 | cricket::MediaEngineInterface* media_engine = |
| 161 | worker_thread_->Invoke<cricket::MediaEngineInterface*>(rtc::Bind( |
| 162 | &PeerConnectionFactory::CreateMediaEngine_w, this)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 163 | |
| 164 | channel_manager_.reset(new cricket::ChannelManager( |
henrike@webrtc.org | 0481f15 | 2014-08-19 14:56:59 +0000 | [diff] [blame] | 165 | media_engine, device_manager, worker_thread_)); |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 166 | |
stefan@webrtc.org | 85d2794 | 2014-06-09 12:51:39 +0000 | [diff] [blame] | 167 | channel_manager_->SetVideoRtxEnabled(true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 168 | if (!channel_manager_->Init()) { |
| 169 | return false; |
| 170 | } |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 171 | |
| 172 | dtls_identity_store_.reset( |
| 173 | new DtlsIdentityStore(signaling_thread_, worker_thread_)); |
| 174 | dtls_identity_store_->Initialize(); |
| 175 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 176 | return true; |
| 177 | } |
| 178 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 179 | rtc::scoped_refptr<AudioSourceInterface> |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 180 | PeerConnectionFactory::CreateAudioSource( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 181 | const MediaConstraintsInterface* constraints) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 182 | DCHECK(signaling_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 183 | rtc::scoped_refptr<LocalAudioSource> source( |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 184 | LocalAudioSource::Create(options_, constraints)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 185 | return source; |
| 186 | } |
| 187 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 188 | rtc::scoped_refptr<VideoSourceInterface> |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 189 | PeerConnectionFactory::CreateVideoSource( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 190 | cricket::VideoCapturer* capturer, |
| 191 | const MediaConstraintsInterface* constraints) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 192 | DCHECK(signaling_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 193 | rtc::scoped_refptr<VideoSource> source( |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 194 | VideoSource::Create(channel_manager_.get(), capturer, constraints)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 195 | return VideoSourceProxy::Create(signaling_thread_, source); |
| 196 | } |
| 197 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 198 | bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) { |
| 199 | DCHECK(signaling_thread_->IsCurrent()); |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 200 | return channel_manager_->StartAecDump(file); |
| 201 | } |
| 202 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 203 | rtc::scoped_refptr<PeerConnectionInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 204 | PeerConnectionFactory::CreatePeerConnection( |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 205 | const PeerConnectionInterface::RTCConfiguration& configuration, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 206 | const MediaConstraintsInterface* constraints, |
| 207 | PortAllocatorFactoryInterface* allocator_factory, |
| 208 | DTLSIdentityServiceInterface* dtls_identity_service, |
| 209 | PeerConnectionObserver* observer) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 210 | DCHECK(signaling_thread_->IsCurrent()); |
phoglund@webrtc.org | 006521d | 2015-02-12 09:23:59 +0000 | [diff] [blame] | 211 | DCHECK(allocator_factory || default_allocator_factory_); |
| 212 | |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 213 | if (!dtls_identity_service) { |
| 214 | dtls_identity_service = new DtlsIdentityService(dtls_identity_store_.get()); |
| 215 | } |
| 216 | |
phoglund@webrtc.org | 006521d | 2015-02-12 09:23:59 +0000 | [diff] [blame] | 217 | PortAllocatorFactoryInterface* chosen_allocator_factory = |
| 218 | allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
| 219 | chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
| 220 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 221 | rtc::scoped_refptr<PeerConnection> pc( |
| 222 | new rtc::RefCountedObject<PeerConnection>(this)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 223 | if (!pc->Initialize( |
| 224 | configuration, |
| 225 | constraints, |
phoglund@webrtc.org | 006521d | 2015-02-12 09:23:59 +0000 | [diff] [blame] | 226 | chosen_allocator_factory, |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 227 | dtls_identity_service, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 228 | observer)) { |
| 229 | return NULL; |
| 230 | } |
| 231 | return PeerConnectionProxy::Create(signaling_thread(), pc); |
| 232 | } |
| 233 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 234 | rtc::scoped_refptr<MediaStreamInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 235 | PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 236 | DCHECK(signaling_thread_->IsCurrent()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 237 | return MediaStreamProxy::Create(signaling_thread_, |
| 238 | MediaStream::Create(label)); |
| 239 | } |
| 240 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 241 | rtc::scoped_refptr<VideoTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 242 | PeerConnectionFactory::CreateVideoTrack( |
| 243 | const std::string& id, |
| 244 | VideoSourceInterface* source) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 245 | DCHECK(signaling_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 246 | rtc::scoped_refptr<VideoTrackInterface> track( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 247 | VideoTrack::Create(id, source)); |
| 248 | return VideoTrackProxy::Create(signaling_thread_, track); |
| 249 | } |
| 250 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 251 | rtc::scoped_refptr<AudioTrackInterface> |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 252 | PeerConnectionFactory::CreateAudioTrack(const std::string& id, |
| 253 | AudioSourceInterface* source) { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 254 | DCHECK(signaling_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 255 | rtc::scoped_refptr<AudioTrackInterface> track( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 256 | AudioTrack::Create(id, source)); |
| 257 | return AudioTrackProxy::Create(signaling_thread_, track); |
| 258 | } |
| 259 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 260 | cricket::ChannelManager* PeerConnectionFactory::channel_manager() { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 261 | DCHECK(signaling_thread_->IsCurrent()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 262 | return channel_manager_.get(); |
| 263 | } |
| 264 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 265 | rtc::Thread* PeerConnectionFactory::signaling_thread() { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 266 | // This method can be called on a different thread when the factory is |
| 267 | // created in CreatePeerConnectionFactory(). |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 268 | return signaling_thread_; |
| 269 | } |
| 270 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 271 | rtc::Thread* PeerConnectionFactory::worker_thread() { |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 272 | DCHECK(signaling_thread_->IsCurrent()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 273 | return worker_thread_; |
| 274 | } |
| 275 | |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 276 | cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
| 277 | ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 278 | return cricket::WebRtcMediaEngineFactory::Create( |
Fredrik Solenberg | ccb49e7 | 2015-05-19 11:37:56 +0200 | [diff] [blame^] | 279 | default_adm_.get(), video_encoder_factory_.get(), |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 280 | video_decoder_factory_.get()); |
| 281 | } |
| 282 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 283 | } // namespace webrtc |