OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/session/media/channelmanager.h" | 28 #include "talk/session/media/channelmanager.h" |
29 | 29 |
30 #ifdef HAVE_CONFIG_H | 30 #ifdef HAVE_CONFIG_H |
31 #include <config.h> | 31 #include <config.h> |
32 #endif | 32 #endif |
33 | 33 |
34 #include <algorithm> | 34 #include <algorithm> |
35 | 35 |
| 36 #include "talk/app/webrtc/mediacontroller.h" |
36 #include "talk/media/base/capturemanager.h" | 37 #include "talk/media/base/capturemanager.h" |
37 #include "talk/media/base/hybriddataengine.h" | 38 #include "talk/media/base/hybriddataengine.h" |
38 #include "talk/media/base/rtpdataengine.h" | 39 #include "talk/media/base/rtpdataengine.h" |
39 #include "talk/media/base/videocapturer.h" | 40 #include "talk/media/base/videocapturer.h" |
40 #include "talk/media/devices/devicemanager.h" | 41 #include "talk/media/devices/devicemanager.h" |
41 #ifdef HAVE_SCTP | 42 #ifdef HAVE_SCTP |
42 #include "talk/media/sctp/sctpdataengine.h" | 43 #include "talk/media/sctp/sctpdataengine.h" |
43 #endif | 44 #endif |
44 #include "talk/session/media/srtpfilter.h" | 45 #include "talk/session/media/srtpfilter.h" |
45 #include "webrtc/base/bind.h" | 46 #include "webrtc/base/bind.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 capture_manager_.reset(NULL); | 302 capture_manager_.reset(NULL); |
302 } | 303 } |
303 | 304 |
304 void ChannelManager::Terminate_w() { | 305 void ChannelManager::Terminate_w() { |
305 ASSERT(worker_thread_ == rtc::Thread::Current()); | 306 ASSERT(worker_thread_ == rtc::Thread::Current()); |
306 // Need to destroy the voice/video channels | 307 // Need to destroy the voice/video channels |
307 while (!video_channels_.empty()) { | 308 while (!video_channels_.empty()) { |
308 DestroyVideoChannel_w(video_channels_.back()); | 309 DestroyVideoChannel_w(video_channels_.back()); |
309 } | 310 } |
310 while (!voice_channels_.empty()) { | 311 while (!voice_channels_.empty()) { |
311 DestroyVoiceChannel_w(voice_channels_.back(), nullptr); | 312 DestroyVoiceChannel_w(voice_channels_.back()); |
312 } | 313 } |
313 if (!SetCaptureDevice_w(NULL)) { | 314 if (!SetCaptureDevice_w(NULL)) { |
314 LOG(LS_WARNING) << "failed to delete video capturer"; | 315 LOG(LS_WARNING) << "failed to delete video capturer"; |
315 } | 316 } |
316 media_engine_->Terminate(); | 317 media_engine_->Terminate(); |
317 } | 318 } |
318 | 319 |
319 VoiceChannel* ChannelManager::CreateVoiceChannel( | 320 VoiceChannel* ChannelManager::CreateVoiceChannel( |
320 BaseSession* session, | 321 BaseSession* session, |
321 const std::string& content_name, | 322 const std::string& content_name, |
322 bool rtcp, | 323 bool rtcp, |
| 324 webrtc::MediaController* media_controller, |
323 const AudioOptions& options) { | 325 const AudioOptions& options) { |
324 return worker_thread_->Invoke<VoiceChannel*>( | 326 return worker_thread_->Invoke<VoiceChannel*>( |
325 Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name, | 327 Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name, |
326 rtcp, options)); | 328 rtcp, media_controller, options)); |
327 } | 329 } |
328 | 330 |
329 VoiceChannel* ChannelManager::CreateVoiceChannel_w( | 331 VoiceChannel* ChannelManager::CreateVoiceChannel_w( |
330 BaseSession* session, | 332 BaseSession* session, |
331 const std::string& content_name, | 333 const std::string& content_name, |
332 bool rtcp, | 334 bool rtcp, |
| 335 webrtc::MediaController* media_controller, |
333 const AudioOptions& options) { | 336 const AudioOptions& options) { |
334 ASSERT(initialized_); | 337 ASSERT(initialized_); |
335 ASSERT(worker_thread_ == rtc::Thread::Current()); | 338 ASSERT(worker_thread_ == rtc::Thread::Current()); |
336 VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options); | 339 ASSERT(nullptr != media_controller); |
| 340 VoiceMediaChannel* media_channel = |
| 341 media_engine_->CreateChannel(media_controller->call_w(), options); |
337 if (!media_channel) | 342 if (!media_channel) |
338 return nullptr; | 343 return nullptr; |
339 | 344 |
340 VoiceChannel* voice_channel = new VoiceChannel( | 345 VoiceChannel* voice_channel = new VoiceChannel( |
341 worker_thread_, media_engine_.get(), media_channel, | 346 worker_thread_, media_engine_.get(), media_channel, |
342 session, content_name, rtcp); | 347 session, content_name, rtcp); |
343 if (!voice_channel->Init()) { | 348 if (!voice_channel->Init()) { |
344 delete voice_channel; | 349 delete voice_channel; |
345 return nullptr; | 350 return nullptr; |
346 } | 351 } |
347 voice_channels_.push_back(voice_channel); | 352 voice_channels_.push_back(voice_channel); |
348 return voice_channel; | 353 return voice_channel; |
349 } | 354 } |
350 | 355 |
351 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel, | 356 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) { |
352 VideoChannel* video_channel) { | |
353 if (voice_channel) { | 357 if (voice_channel) { |
354 worker_thread_->Invoke<void>( | 358 worker_thread_->Invoke<void>( |
355 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel, | 359 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel)); |
356 video_channel)); | |
357 } | 360 } |
358 } | 361 } |
359 | 362 |
360 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel, | 363 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) { |
361 VideoChannel* video_channel) { | |
362 // Destroy voice channel. | 364 // Destroy voice channel. |
363 ASSERT(initialized_); | 365 ASSERT(initialized_); |
364 ASSERT(worker_thread_ == rtc::Thread::Current()); | 366 ASSERT(worker_thread_ == rtc::Thread::Current()); |
365 VoiceChannels::iterator it = std::find(voice_channels_.begin(), | 367 VoiceChannels::iterator it = std::find(voice_channels_.begin(), |
366 voice_channels_.end(), voice_channel); | 368 voice_channels_.end(), voice_channel); |
367 ASSERT(it != voice_channels_.end()); | 369 ASSERT(it != voice_channels_.end()); |
368 if (it == voice_channels_.end()) | 370 if (it == voice_channels_.end()) |
369 return; | 371 return; |
370 | |
371 if (video_channel) { | |
372 video_channel->media_channel()->DetachVoiceChannel(); | |
373 } | |
374 voice_channels_.erase(it); | 372 voice_channels_.erase(it); |
375 delete voice_channel; | 373 delete voice_channel; |
376 } | 374 } |
377 | 375 |
378 VideoChannel* ChannelManager::CreateVideoChannel( | 376 VideoChannel* ChannelManager::CreateVideoChannel( |
379 BaseSession* session, | 377 BaseSession* session, |
380 const std::string& content_name, | 378 const std::string& content_name, |
381 bool rtcp, | 379 bool rtcp, |
382 VoiceChannel* voice_channel) { | 380 webrtc::MediaController* media_controller, |
| 381 const VideoOptions& options) { |
383 return worker_thread_->Invoke<VideoChannel*>( | 382 return worker_thread_->Invoke<VideoChannel*>( |
384 Bind(&ChannelManager::CreateVideoChannel_w, | 383 Bind(&ChannelManager::CreateVideoChannel_w, |
385 this, | 384 this, |
386 session, | 385 session, |
387 content_name, | 386 content_name, |
388 rtcp, | 387 rtcp, |
389 VideoOptions(), | 388 media_controller, |
390 voice_channel)); | 389 options)); |
391 } | |
392 | |
393 VideoChannel* ChannelManager::CreateVideoChannel( | |
394 BaseSession* session, | |
395 const std::string& content_name, | |
396 bool rtcp, | |
397 const VideoOptions& options, | |
398 VoiceChannel* voice_channel) { | |
399 return worker_thread_->Invoke<VideoChannel*>( | |
400 Bind(&ChannelManager::CreateVideoChannel_w, | |
401 this, | |
402 session, | |
403 content_name, | |
404 rtcp, | |
405 options, | |
406 voice_channel)); | |
407 } | 390 } |
408 | 391 |
409 VideoChannel* ChannelManager::CreateVideoChannel_w( | 392 VideoChannel* ChannelManager::CreateVideoChannel_w( |
410 BaseSession* session, | 393 BaseSession* session, |
411 const std::string& content_name, | 394 const std::string& content_name, |
412 bool rtcp, | 395 bool rtcp, |
413 const VideoOptions& options, | 396 webrtc::MediaController* media_controller, |
414 VoiceChannel* voice_channel) { | 397 const VideoOptions& options) { |
415 ASSERT(initialized_); | 398 ASSERT(initialized_); |
416 ASSERT(worker_thread_ == rtc::Thread::Current()); | 399 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 400 ASSERT(nullptr != media_controller); |
417 VideoMediaChannel* media_channel = | 401 VideoMediaChannel* media_channel = |
418 // voice_channel can be NULL in case of NullVoiceEngine. | 402 media_engine_->CreateVideoChannel(media_controller->call_w(), options); |
419 media_engine_->CreateVideoChannel( | |
420 options, voice_channel ? voice_channel->media_channel() : NULL); | |
421 if (media_channel == NULL) | 403 if (media_channel == NULL) |
422 return NULL; | 404 return NULL; |
423 | 405 |
424 VideoChannel* video_channel = new VideoChannel( | 406 VideoChannel* video_channel = new VideoChannel( |
425 worker_thread_, media_channel, | 407 worker_thread_, media_channel, |
426 session, content_name, rtcp); | 408 session, content_name, rtcp); |
427 if (!video_channel->Init()) { | 409 if (!video_channel->Init()) { |
428 delete video_channel; | 410 delete video_channel; |
429 return NULL; | 411 return NULL; |
430 } | 412 } |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 const VideoFormat& max_format) { | 900 const VideoFormat& max_format) { |
919 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); | 901 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); |
920 } | 902 } |
921 | 903 |
922 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { | 904 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { |
923 return worker_thread_->Invoke<bool>( | 905 return worker_thread_->Invoke<bool>( |
924 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); | 906 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); |
925 } | 907 } |
926 | 908 |
927 } // namespace cricket | 909 } // namespace cricket |
OLD | NEW |