OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/media/base/device.h" | 21 #include "webrtc/media/base/device.h" |
22 #include "webrtc/media/base/rtpdataengine.h" | 22 #include "webrtc/media/base/rtpdataengine.h" |
23 #include "webrtc/pc/srtpfilter.h" | 23 #include "webrtc/pc/srtpfilter.h" |
24 #include "webrtc/pc/mediacontroller.h" | 24 #include "webrtc/pc/mediacontroller.h" |
25 | 25 |
26 namespace cricket { | 26 namespace cricket { |
27 | 27 |
28 | 28 |
29 using rtc::Bind; | 29 using rtc::Bind; |
30 | 30 |
31 static DataEngineInterface* ConstructDataEngine() { | 31 ChannelManager::ChannelManager(std::unique_ptr<MediaEngineInterface> me, |
32 return new RtpDataEngine(); | 32 std::unique_ptr<DataEngineInterface> dme, |
| 33 rtc::Thread* thread) { |
| 34 Construct(std::move(me), std::move(dme), thread, thread); |
33 } | 35 } |
34 | 36 |
35 ChannelManager::ChannelManager(MediaEngineInterface* me, | 37 ChannelManager::ChannelManager(std::unique_ptr<MediaEngineInterface> me, |
36 DataEngineInterface* dme, | 38 rtc::Thread* worker_thread, |
37 rtc::Thread* thread) { | 39 rtc::Thread* network_thread) { |
38 Construct(me, dme, thread, thread); | 40 Construct(std::move(me), |
| 41 std::unique_ptr<DataEngineInterface>(new RtpDataEngine()), |
| 42 worker_thread, network_thread); |
39 } | 43 } |
40 | 44 |
41 ChannelManager::ChannelManager(MediaEngineInterface* me, | 45 void ChannelManager::Construct(std::unique_ptr<MediaEngineInterface> me, |
| 46 std::unique_ptr<DataEngineInterface> dme, |
42 rtc::Thread* worker_thread, | 47 rtc::Thread* worker_thread, |
43 rtc::Thread* network_thread) { | 48 rtc::Thread* network_thread) { |
44 Construct(me, ConstructDataEngine(), worker_thread, network_thread); | 49 media_engine_ = std::move(me); |
45 } | 50 data_media_engine_ = std::move(dme); |
46 | |
47 void ChannelManager::Construct(MediaEngineInterface* me, | |
48 DataEngineInterface* dme, | |
49 rtc::Thread* worker_thread, | |
50 rtc::Thread* network_thread) { | |
51 media_engine_.reset(me); | |
52 data_media_engine_.reset(dme); | |
53 initialized_ = false; | 51 initialized_ = false; |
54 main_thread_ = rtc::Thread::Current(); | 52 main_thread_ = rtc::Thread::Current(); |
55 worker_thread_ = worker_thread; | 53 worker_thread_ = worker_thread; |
56 network_thread_ = network_thread; | 54 network_thread_ = network_thread; |
57 capturing_ = false; | 55 capturing_ = false; |
58 enable_rtx_ = false; | 56 enable_rtx_ = false; |
59 crypto_options_ = rtc::CryptoOptions::NoGcm(); | 57 crypto_options_ = rtc::CryptoOptions::NoGcm(); |
60 } | 58 } |
61 | 59 |
62 ChannelManager::~ChannelManager() { | 60 ChannelManager::~ChannelManager() { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 DestroyVoiceChannel_w(voice_channels_.back()); | 201 DestroyVoiceChannel_w(voice_channels_.back()); |
204 } | 202 } |
205 } | 203 } |
206 | 204 |
207 VoiceChannel* ChannelManager::CreateVoiceChannel( | 205 VoiceChannel* ChannelManager::CreateVoiceChannel( |
208 webrtc::MediaControllerInterface* media_controller, | 206 webrtc::MediaControllerInterface* media_controller, |
209 DtlsTransportInternal* rtp_transport, | 207 DtlsTransportInternal* rtp_transport, |
210 DtlsTransportInternal* rtcp_transport, | 208 DtlsTransportInternal* rtcp_transport, |
211 rtc::Thread* signaling_thread, | 209 rtc::Thread* signaling_thread, |
212 const std::string& content_name, | 210 const std::string& content_name, |
213 const std::string* bundle_transport_name, | |
214 bool rtcp_mux_required, | |
215 bool srtp_required, | 211 bool srtp_required, |
216 const AudioOptions& options) { | 212 const AudioOptions& options) { |
217 return worker_thread_->Invoke<VoiceChannel*>( | 213 return worker_thread_->Invoke<VoiceChannel*>( |
218 RTC_FROM_HERE, | 214 RTC_FROM_HERE, |
219 Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, | 215 Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, |
220 rtp_transport, rtcp_transport, signaling_thread, content_name, | 216 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, |
221 bundle_transport_name, rtcp_mux_required, srtp_required, options)); | 217 signaling_thread, content_name, srtp_required, options)); |
| 218 } |
| 219 |
| 220 VoiceChannel* ChannelManager::CreateVoiceChannel( |
| 221 webrtc::MediaControllerInterface* media_controller, |
| 222 rtc::PacketTransportInternal* rtp_transport, |
| 223 rtc::PacketTransportInternal* rtcp_transport, |
| 224 rtc::Thread* signaling_thread, |
| 225 const std::string& content_name, |
| 226 bool srtp_required, |
| 227 const AudioOptions& options) { |
| 228 return worker_thread_->Invoke<VoiceChannel*>( |
| 229 RTC_FROM_HERE, |
| 230 Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, |
| 231 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, |
| 232 content_name, srtp_required, options)); |
222 } | 233 } |
223 | 234 |
224 VoiceChannel* ChannelManager::CreateVoiceChannel_w( | 235 VoiceChannel* ChannelManager::CreateVoiceChannel_w( |
225 webrtc::MediaControllerInterface* media_controller, | 236 webrtc::MediaControllerInterface* media_controller, |
226 DtlsTransportInternal* rtp_transport, | 237 DtlsTransportInternal* rtp_dtls_transport, |
227 DtlsTransportInternal* rtcp_transport, | 238 DtlsTransportInternal* rtcp_dtls_transport, |
| 239 rtc::PacketTransportInternal* rtp_packet_transport, |
| 240 rtc::PacketTransportInternal* rtcp_packet_transport, |
228 rtc::Thread* signaling_thread, | 241 rtc::Thread* signaling_thread, |
229 const std::string& content_name, | 242 const std::string& content_name, |
230 const std::string* bundle_transport_name, | |
231 bool rtcp_mux_required, | |
232 bool srtp_required, | 243 bool srtp_required, |
233 const AudioOptions& options) { | 244 const AudioOptions& options) { |
234 RTC_DCHECK(initialized_); | 245 RTC_DCHECK(initialized_); |
235 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 246 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
236 RTC_DCHECK(nullptr != media_controller); | 247 RTC_DCHECK(nullptr != media_controller); |
237 | 248 |
238 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( | 249 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( |
239 media_controller->call_w(), media_controller->config(), options); | 250 media_controller->call_w(), media_controller->config(), options); |
240 if (!media_channel) | 251 if (!media_channel) |
241 return nullptr; | 252 return nullptr; |
242 | 253 |
243 VoiceChannel* voice_channel = new VoiceChannel( | 254 VoiceChannel* voice_channel = |
244 worker_thread_, network_thread_, signaling_thread, media_engine_.get(), | 255 new VoiceChannel(worker_thread_, network_thread_, signaling_thread, |
245 media_channel, content_name, rtcp_mux_required, srtp_required); | 256 media_engine_.get(), media_channel, content_name, |
| 257 rtcp_packet_transport == nullptr, srtp_required); |
246 voice_channel->SetCryptoOptions(crypto_options_); | 258 voice_channel->SetCryptoOptions(crypto_options_); |
247 | 259 |
248 if (!voice_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, | 260 if (!voice_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, |
249 rtcp_transport)) { | 261 rtp_packet_transport, rtcp_packet_transport)) { |
250 delete voice_channel; | 262 delete voice_channel; |
251 return nullptr; | 263 return nullptr; |
252 } | 264 } |
253 voice_channels_.push_back(voice_channel); | 265 voice_channels_.push_back(voice_channel); |
254 return voice_channel; | 266 return voice_channel; |
255 } | 267 } |
256 | 268 |
257 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) { | 269 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) { |
258 TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel"); | 270 TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel"); |
259 if (voice_channel) { | 271 if (voice_channel) { |
(...skipping 16 matching lines...) Expand all Loading... |
276 voice_channels_.erase(it); | 288 voice_channels_.erase(it); |
277 delete voice_channel; | 289 delete voice_channel; |
278 } | 290 } |
279 | 291 |
280 VideoChannel* ChannelManager::CreateVideoChannel( | 292 VideoChannel* ChannelManager::CreateVideoChannel( |
281 webrtc::MediaControllerInterface* media_controller, | 293 webrtc::MediaControllerInterface* media_controller, |
282 DtlsTransportInternal* rtp_transport, | 294 DtlsTransportInternal* rtp_transport, |
283 DtlsTransportInternal* rtcp_transport, | 295 DtlsTransportInternal* rtcp_transport, |
284 rtc::Thread* signaling_thread, | 296 rtc::Thread* signaling_thread, |
285 const std::string& content_name, | 297 const std::string& content_name, |
286 const std::string* bundle_transport_name, | |
287 bool rtcp_mux_required, | |
288 bool srtp_required, | 298 bool srtp_required, |
289 const VideoOptions& options) { | 299 const VideoOptions& options) { |
290 return worker_thread_->Invoke<VideoChannel*>( | 300 return worker_thread_->Invoke<VideoChannel*>( |
291 RTC_FROM_HERE, | 301 RTC_FROM_HERE, |
292 Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, | 302 Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, |
293 rtp_transport, rtcp_transport, signaling_thread, content_name, | 303 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, |
294 bundle_transport_name, rtcp_mux_required, srtp_required, options)); | 304 signaling_thread, content_name, srtp_required, options)); |
| 305 } |
| 306 |
| 307 VideoChannel* ChannelManager::CreateVideoChannel( |
| 308 webrtc::MediaControllerInterface* media_controller, |
| 309 rtc::PacketTransportInternal* rtp_transport, |
| 310 rtc::PacketTransportInternal* rtcp_transport, |
| 311 rtc::Thread* signaling_thread, |
| 312 const std::string& content_name, |
| 313 bool srtp_required, |
| 314 const VideoOptions& options) { |
| 315 return worker_thread_->Invoke<VideoChannel*>( |
| 316 RTC_FROM_HERE, |
| 317 Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, |
| 318 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, |
| 319 content_name, srtp_required, options)); |
295 } | 320 } |
296 | 321 |
297 VideoChannel* ChannelManager::CreateVideoChannel_w( | 322 VideoChannel* ChannelManager::CreateVideoChannel_w( |
298 webrtc::MediaControllerInterface* media_controller, | 323 webrtc::MediaControllerInterface* media_controller, |
299 DtlsTransportInternal* rtp_transport, | 324 DtlsTransportInternal* rtp_dtls_transport, |
300 DtlsTransportInternal* rtcp_transport, | 325 DtlsTransportInternal* rtcp_dtls_transport, |
| 326 rtc::PacketTransportInternal* rtp_packet_transport, |
| 327 rtc::PacketTransportInternal* rtcp_packet_transport, |
301 rtc::Thread* signaling_thread, | 328 rtc::Thread* signaling_thread, |
302 const std::string& content_name, | 329 const std::string& content_name, |
303 const std::string* bundle_transport_name, | |
304 bool rtcp_mux_required, | |
305 bool srtp_required, | 330 bool srtp_required, |
306 const VideoOptions& options) { | 331 const VideoOptions& options) { |
307 RTC_DCHECK(initialized_); | 332 RTC_DCHECK(initialized_); |
308 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 333 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
309 RTC_DCHECK(nullptr != media_controller); | 334 RTC_DCHECK(nullptr != media_controller); |
310 VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( | 335 VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( |
311 media_controller->call_w(), media_controller->config(), options); | 336 media_controller->call_w(), media_controller->config(), options); |
312 if (media_channel == NULL) { | 337 if (media_channel == NULL) { |
313 return NULL; | 338 return NULL; |
314 } | 339 } |
315 | 340 |
316 VideoChannel* video_channel = new VideoChannel( | 341 VideoChannel* video_channel = new VideoChannel( |
317 worker_thread_, network_thread_, signaling_thread, media_channel, | 342 worker_thread_, network_thread_, signaling_thread, media_channel, |
318 content_name, rtcp_mux_required, srtp_required); | 343 content_name, rtcp_packet_transport == nullptr, srtp_required); |
319 video_channel->SetCryptoOptions(crypto_options_); | 344 video_channel->SetCryptoOptions(crypto_options_); |
320 if (!video_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, | 345 if (!video_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, |
321 rtcp_transport)) { | 346 rtp_packet_transport, rtcp_packet_transport)) { |
322 delete video_channel; | 347 delete video_channel; |
323 return NULL; | 348 return NULL; |
324 } | 349 } |
325 video_channels_.push_back(video_channel); | 350 video_channels_.push_back(video_channel); |
326 return video_channel; | 351 return video_channel; |
327 } | 352 } |
328 | 353 |
329 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { | 354 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { |
330 TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel"); | 355 TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel"); |
331 if (video_channel) { | 356 if (video_channel) { |
(...skipping 17 matching lines...) Expand all Loading... |
349 video_channels_.erase(it); | 374 video_channels_.erase(it); |
350 delete video_channel; | 375 delete video_channel; |
351 } | 376 } |
352 | 377 |
353 RtpDataChannel* ChannelManager::CreateRtpDataChannel( | 378 RtpDataChannel* ChannelManager::CreateRtpDataChannel( |
354 webrtc::MediaControllerInterface* media_controller, | 379 webrtc::MediaControllerInterface* media_controller, |
355 DtlsTransportInternal* rtp_transport, | 380 DtlsTransportInternal* rtp_transport, |
356 DtlsTransportInternal* rtcp_transport, | 381 DtlsTransportInternal* rtcp_transport, |
357 rtc::Thread* signaling_thread, | 382 rtc::Thread* signaling_thread, |
358 const std::string& content_name, | 383 const std::string& content_name, |
359 const std::string* bundle_transport_name, | |
360 bool rtcp_mux_required, | |
361 bool srtp_required) { | 384 bool srtp_required) { |
362 return worker_thread_->Invoke<RtpDataChannel*>( | 385 return worker_thread_->Invoke<RtpDataChannel*>( |
363 RTC_FROM_HERE, | 386 RTC_FROM_HERE, Bind(&ChannelManager::CreateRtpDataChannel_w, this, |
364 Bind(&ChannelManager::CreateRtpDataChannel_w, this, media_controller, | 387 media_controller, rtp_transport, rtcp_transport, |
365 rtp_transport, rtcp_transport, signaling_thread, content_name, | 388 signaling_thread, content_name, srtp_required)); |
366 bundle_transport_name, rtcp_mux_required, srtp_required)); | |
367 } | 389 } |
368 | 390 |
369 RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( | 391 RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( |
370 webrtc::MediaControllerInterface* media_controller, | 392 webrtc::MediaControllerInterface* media_controller, |
371 DtlsTransportInternal* rtp_transport, | 393 DtlsTransportInternal* rtp_transport, |
372 DtlsTransportInternal* rtcp_transport, | 394 DtlsTransportInternal* rtcp_transport, |
373 rtc::Thread* signaling_thread, | 395 rtc::Thread* signaling_thread, |
374 const std::string& content_name, | 396 const std::string& content_name, |
375 const std::string* bundle_transport_name, | |
376 bool rtcp_mux_required, | |
377 bool srtp_required) { | 397 bool srtp_required) { |
378 // This is ok to alloc from a thread other than the worker thread. | 398 // This is ok to alloc from a thread other than the worker thread. |
379 RTC_DCHECK(initialized_); | 399 RTC_DCHECK(initialized_); |
380 MediaConfig config; | 400 MediaConfig config; |
381 if (media_controller) { | 401 if (media_controller) { |
382 config = media_controller->config(); | 402 config = media_controller->config(); |
383 } | 403 } |
384 DataMediaChannel* media_channel = data_media_engine_->CreateChannel(config); | 404 DataMediaChannel* media_channel = data_media_engine_->CreateChannel(config); |
385 if (!media_channel) { | 405 if (!media_channel) { |
386 LOG(LS_WARNING) << "Failed to create RTP data channel."; | 406 LOG(LS_WARNING) << "Failed to create RTP data channel."; |
387 return nullptr; | 407 return nullptr; |
388 } | 408 } |
389 | 409 |
390 RtpDataChannel* data_channel = new RtpDataChannel( | 410 RtpDataChannel* data_channel = new RtpDataChannel( |
391 worker_thread_, network_thread_, signaling_thread, media_channel, | 411 worker_thread_, network_thread_, signaling_thread, media_channel, |
392 content_name, rtcp_mux_required, srtp_required); | 412 content_name, rtcp_transport == nullptr, srtp_required); |
393 data_channel->SetCryptoOptions(crypto_options_); | 413 data_channel->SetCryptoOptions(crypto_options_); |
394 if (!data_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, | 414 if (!data_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, |
395 rtcp_transport)) { | 415 rtcp_transport)) { |
396 LOG(LS_WARNING) << "Failed to init data channel."; | 416 LOG(LS_WARNING) << "Failed to init data channel."; |
397 delete data_channel; | 417 delete data_channel; |
398 return nullptr; | 418 return nullptr; |
399 } | 419 } |
400 data_channels_.push_back(data_channel); | 420 data_channels_.push_back(data_channel); |
401 return data_channel; | 421 return data_channel; |
402 } | 422 } |
(...skipping 28 matching lines...) Expand all Loading... |
431 media_engine_.get(), file, max_size_bytes)); | 451 media_engine_.get(), file, max_size_bytes)); |
432 } | 452 } |
433 | 453 |
434 void ChannelManager::StopAecDump() { | 454 void ChannelManager::StopAecDump() { |
435 worker_thread_->Invoke<void>( | 455 worker_thread_->Invoke<void>( |
436 RTC_FROM_HERE, | 456 RTC_FROM_HERE, |
437 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); | 457 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); |
438 } | 458 } |
439 | 459 |
440 } // namespace cricket | 460 } // namespace cricket |
OLD | NEW |