| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004--2011 Google Inc. | 3 * Copyright 2004--2011 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 namespace webrtc { | 48 namespace webrtc { |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 // Passes down the calls to |store_|. See usage in CreatePeerConnection. | 52 // Passes down the calls to |store_|. See usage in CreatePeerConnection. |
| 53 class DtlsIdentityStoreWrapper : public DtlsIdentityStoreInterface { | 53 class DtlsIdentityStoreWrapper : public DtlsIdentityStoreInterface { |
| 54 public: | 54 public: |
| 55 DtlsIdentityStoreWrapper( | 55 DtlsIdentityStoreWrapper( |
| 56 const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store) | 56 const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store) |
| 57 : store_(store) { | 57 : store_(store) { |
| 58 DCHECK(store_); | 58 RTC_DCHECK(store_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void RequestIdentity( | 61 void RequestIdentity( |
| 62 rtc::KeyType key_type, | 62 rtc::KeyType key_type, |
| 63 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& | 63 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& |
| 64 observer) override { | 64 observer) override { |
| 65 store_->RequestIdentity(key_type, observer); | 65 store_->RequestIdentity(key_type, observer); |
| 66 } | 66 } |
| 67 | 67 |
| 68 private: | 68 private: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 video_encoder_factory_(video_encoder_factory), | 144 video_encoder_factory_(video_encoder_factory), |
| 145 video_decoder_factory_(video_decoder_factory) { | 145 video_decoder_factory_(video_decoder_factory) { |
| 146 ASSERT(worker_thread != NULL); | 146 ASSERT(worker_thread != NULL); |
| 147 ASSERT(signaling_thread != NULL); | 147 ASSERT(signaling_thread != NULL); |
| 148 // TODO: Currently there is no way creating an external adm in | 148 // TODO: Currently there is no way creating an external adm in |
| 149 // libjingle source tree. So we can 't currently assert if this is NULL. | 149 // libjingle source tree. So we can 't currently assert if this is NULL. |
| 150 // ASSERT(default_adm != NULL); | 150 // ASSERT(default_adm != NULL); |
| 151 } | 151 } |
| 152 | 152 |
| 153 PeerConnectionFactory::~PeerConnectionFactory() { | 153 PeerConnectionFactory::~PeerConnectionFactory() { |
| 154 DCHECK(signaling_thread_->IsCurrent()); | 154 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 155 channel_manager_.reset(nullptr); | 155 channel_manager_.reset(nullptr); |
| 156 default_allocator_factory_ = nullptr; | 156 default_allocator_factory_ = nullptr; |
| 157 | 157 |
| 158 // Make sure |worker_thread_| and |signaling_thread_| outlive | 158 // Make sure |worker_thread_| and |signaling_thread_| outlive |
| 159 // |dtls_identity_store_|. | 159 // |dtls_identity_store_|. |
| 160 dtls_identity_store_ = nullptr; | 160 dtls_identity_store_ = nullptr; |
| 161 | 161 |
| 162 if (owns_ptrs_) { | 162 if (owns_ptrs_) { |
| 163 if (wraps_current_thread_) | 163 if (wraps_current_thread_) |
| 164 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); | 164 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); |
| 165 delete worker_thread_; | 165 delete worker_thread_; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool PeerConnectionFactory::Initialize() { | 169 bool PeerConnectionFactory::Initialize() { |
| 170 DCHECK(signaling_thread_->IsCurrent()); | 170 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 171 rtc::InitRandom(rtc::Time()); | 171 rtc::InitRandom(rtc::Time()); |
| 172 | 172 |
| 173 default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_); | 173 default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_); |
| 174 if (!default_allocator_factory_) | 174 if (!default_allocator_factory_) |
| 175 return false; | 175 return false; |
| 176 | 176 |
| 177 cricket::DummyDeviceManager* device_manager( | 177 cricket::DummyDeviceManager* device_manager( |
| 178 new cricket::DummyDeviceManager()); | 178 new cricket::DummyDeviceManager()); |
| 179 | 179 |
| 180 // TODO: Need to make sure only one VoE is created inside | 180 // TODO: Need to make sure only one VoE is created inside |
| (...skipping 12 matching lines...) Expand all Loading... |
| 193 | 193 |
| 194 dtls_identity_store_ = new RefCountedDtlsIdentityStore( | 194 dtls_identity_store_ = new RefCountedDtlsIdentityStore( |
| 195 signaling_thread_, worker_thread_); | 195 signaling_thread_, worker_thread_); |
| 196 | 196 |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 rtc::scoped_refptr<AudioSourceInterface> | 200 rtc::scoped_refptr<AudioSourceInterface> |
| 201 PeerConnectionFactory::CreateAudioSource( | 201 PeerConnectionFactory::CreateAudioSource( |
| 202 const MediaConstraintsInterface* constraints) { | 202 const MediaConstraintsInterface* constraints) { |
| 203 DCHECK(signaling_thread_->IsCurrent()); | 203 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 204 rtc::scoped_refptr<LocalAudioSource> source( | 204 rtc::scoped_refptr<LocalAudioSource> source( |
| 205 LocalAudioSource::Create(options_, constraints)); | 205 LocalAudioSource::Create(options_, constraints)); |
| 206 return source; | 206 return source; |
| 207 } | 207 } |
| 208 | 208 |
| 209 rtc::scoped_refptr<VideoSourceInterface> | 209 rtc::scoped_refptr<VideoSourceInterface> |
| 210 PeerConnectionFactory::CreateVideoSource( | 210 PeerConnectionFactory::CreateVideoSource( |
| 211 cricket::VideoCapturer* capturer, | 211 cricket::VideoCapturer* capturer, |
| 212 const MediaConstraintsInterface* constraints) { | 212 const MediaConstraintsInterface* constraints) { |
| 213 DCHECK(signaling_thread_->IsCurrent()); | 213 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 214 rtc::scoped_refptr<VideoSource> source( | 214 rtc::scoped_refptr<VideoSource> source( |
| 215 VideoSource::Create(channel_manager_.get(), capturer, constraints)); | 215 VideoSource::Create(channel_manager_.get(), capturer, constraints)); |
| 216 return VideoSourceProxy::Create(signaling_thread_, source); | 216 return VideoSourceProxy::Create(signaling_thread_, source); |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) { | 219 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) { |
| 220 DCHECK(signaling_thread_->IsCurrent()); | 220 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 221 return channel_manager_->StartAecDump(file); | 221 return channel_manager_->StartAecDump(file); |
| 222 } | 222 } |
| 223 | 223 |
| 224 rtc::scoped_refptr<PeerConnectionInterface> | 224 rtc::scoped_refptr<PeerConnectionInterface> |
| 225 PeerConnectionFactory::CreatePeerConnection( | 225 PeerConnectionFactory::CreatePeerConnection( |
| 226 const PeerConnectionInterface::RTCConfiguration& configuration, | 226 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 227 const MediaConstraintsInterface* constraints, | 227 const MediaConstraintsInterface* constraints, |
| 228 PortAllocatorFactoryInterface* allocator_factory, | 228 PortAllocatorFactoryInterface* allocator_factory, |
| 229 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 229 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 230 PeerConnectionObserver* observer) { | 230 PeerConnectionObserver* observer) { |
| 231 DCHECK(signaling_thread_->IsCurrent()); | 231 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 232 DCHECK(allocator_factory || default_allocator_factory_); | 232 RTC_DCHECK(allocator_factory || default_allocator_factory_); |
| 233 | 233 |
| 234 if (!dtls_identity_store.get()) { | 234 if (!dtls_identity_store.get()) { |
| 235 // Because |pc|->Initialize takes ownership of the store we need a new | 235 // Because |pc|->Initialize takes ownership of the store we need a new |
| 236 // wrapper object that can be deleted without deleting the underlying | 236 // wrapper object that can be deleted without deleting the underlying |
| 237 // |dtls_identity_store_|, protecting it from being deleted multiple times. | 237 // |dtls_identity_store_|, protecting it from being deleted multiple times. |
| 238 dtls_identity_store.reset( | 238 dtls_identity_store.reset( |
| 239 new DtlsIdentityStoreWrapper(dtls_identity_store_)); | 239 new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 PortAllocatorFactoryInterface* chosen_allocator_factory = | 242 PortAllocatorFactoryInterface* chosen_allocator_factory = |
| 243 allocator_factory ? allocator_factory : default_allocator_factory_.get(); | 243 allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
| 244 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); | 244 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
| 245 | 245 |
| 246 rtc::scoped_refptr<PeerConnection> pc( | 246 rtc::scoped_refptr<PeerConnection> pc( |
| 247 new rtc::RefCountedObject<PeerConnection>(this)); | 247 new rtc::RefCountedObject<PeerConnection>(this)); |
| 248 if (!pc->Initialize( | 248 if (!pc->Initialize( |
| 249 configuration, | 249 configuration, |
| 250 constraints, | 250 constraints, |
| 251 chosen_allocator_factory, | 251 chosen_allocator_factory, |
| 252 dtls_identity_store.Pass(), | 252 dtls_identity_store.Pass(), |
| 253 observer)) { | 253 observer)) { |
| 254 return NULL; | 254 return NULL; |
| 255 } | 255 } |
| 256 return PeerConnectionProxy::Create(signaling_thread(), pc); | 256 return PeerConnectionProxy::Create(signaling_thread(), pc); |
| 257 } | 257 } |
| 258 | 258 |
| 259 rtc::scoped_refptr<MediaStreamInterface> | 259 rtc::scoped_refptr<MediaStreamInterface> |
| 260 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 260 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
| 261 DCHECK(signaling_thread_->IsCurrent()); | 261 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 262 return MediaStreamProxy::Create(signaling_thread_, | 262 return MediaStreamProxy::Create(signaling_thread_, |
| 263 MediaStream::Create(label)); | 263 MediaStream::Create(label)); |
| 264 } | 264 } |
| 265 | 265 |
| 266 rtc::scoped_refptr<VideoTrackInterface> | 266 rtc::scoped_refptr<VideoTrackInterface> |
| 267 PeerConnectionFactory::CreateVideoTrack( | 267 PeerConnectionFactory::CreateVideoTrack( |
| 268 const std::string& id, | 268 const std::string& id, |
| 269 VideoSourceInterface* source) { | 269 VideoSourceInterface* source) { |
| 270 DCHECK(signaling_thread_->IsCurrent()); | 270 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 271 rtc::scoped_refptr<VideoTrackInterface> track( | 271 rtc::scoped_refptr<VideoTrackInterface> track( |
| 272 VideoTrack::Create(id, source)); | 272 VideoTrack::Create(id, source)); |
| 273 return VideoTrackProxy::Create(signaling_thread_, track); | 273 return VideoTrackProxy::Create(signaling_thread_, track); |
| 274 } | 274 } |
| 275 | 275 |
| 276 rtc::scoped_refptr<AudioTrackInterface> | 276 rtc::scoped_refptr<AudioTrackInterface> |
| 277 PeerConnectionFactory::CreateAudioTrack(const std::string& id, | 277 PeerConnectionFactory::CreateAudioTrack(const std::string& id, |
| 278 AudioSourceInterface* source) { | 278 AudioSourceInterface* source) { |
| 279 DCHECK(signaling_thread_->IsCurrent()); | 279 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 280 rtc::scoped_refptr<AudioTrackInterface> track( | 280 rtc::scoped_refptr<AudioTrackInterface> track( |
| 281 AudioTrack::Create(id, source)); | 281 AudioTrack::Create(id, source)); |
| 282 return AudioTrackProxy::Create(signaling_thread_, track); | 282 return AudioTrackProxy::Create(signaling_thread_, track); |
| 283 } | 283 } |
| 284 | 284 |
| 285 cricket::ChannelManager* PeerConnectionFactory::channel_manager() { | 285 cricket::ChannelManager* PeerConnectionFactory::channel_manager() { |
| 286 DCHECK(signaling_thread_->IsCurrent()); | 286 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 287 return channel_manager_.get(); | 287 return channel_manager_.get(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 rtc::Thread* PeerConnectionFactory::signaling_thread() { | 290 rtc::Thread* PeerConnectionFactory::signaling_thread() { |
| 291 // This method can be called on a different thread when the factory is | 291 // This method can be called on a different thread when the factory is |
| 292 // created in CreatePeerConnectionFactory(). | 292 // created in CreatePeerConnectionFactory(). |
| 293 return signaling_thread_; | 293 return signaling_thread_; |
| 294 } | 294 } |
| 295 | 295 |
| 296 rtc::Thread* PeerConnectionFactory::worker_thread() { | 296 rtc::Thread* PeerConnectionFactory::worker_thread() { |
| 297 DCHECK(signaling_thread_->IsCurrent()); | 297 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 298 return worker_thread_; | 298 return worker_thread_; |
| 299 } | 299 } |
| 300 | 300 |
| 301 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 301 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
| 302 ASSERT(worker_thread_ == rtc::Thread::Current()); | 302 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 303 return cricket::WebRtcMediaEngineFactory::Create( | 303 return cricket::WebRtcMediaEngineFactory::Create( |
| 304 default_adm_.get(), video_encoder_factory_.get(), | 304 default_adm_.get(), video_encoder_factory_.get(), |
| 305 video_decoder_factory_.get()); | 305 video_decoder_factory_.get()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace webrtc | 308 } // namespace webrtc |
| OLD | NEW |