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( |
| 321 webrtc::MediaControllerInterface* media_controller, |
320 BaseSession* session, | 322 BaseSession* session, |
321 const std::string& content_name, | 323 const std::string& content_name, |
322 bool rtcp, | 324 bool rtcp, |
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, |
326 rtcp, options)); | 328 this, |
| 329 media_controller, |
| 330 session, |
| 331 content_name, |
| 332 rtcp, |
| 333 options)); |
327 } | 334 } |
328 | 335 |
329 VoiceChannel* ChannelManager::CreateVoiceChannel_w( | 336 VoiceChannel* ChannelManager::CreateVoiceChannel_w( |
| 337 webrtc::MediaControllerInterface* media_controller, |
330 BaseSession* session, | 338 BaseSession* session, |
331 const std::string& content_name, | 339 const std::string& content_name, |
332 bool rtcp, | 340 bool rtcp, |
333 const AudioOptions& options) { | 341 const AudioOptions& options) { |
334 ASSERT(initialized_); | 342 ASSERT(initialized_); |
335 ASSERT(worker_thread_ == rtc::Thread::Current()); | 343 ASSERT(worker_thread_ == rtc::Thread::Current()); |
336 VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options); | 344 ASSERT(nullptr != media_controller); |
| 345 VoiceMediaChannel* media_channel = |
| 346 media_engine_->CreateChannel(media_controller->call_w(), options); |
337 if (!media_channel) | 347 if (!media_channel) |
338 return nullptr; | 348 return nullptr; |
339 | 349 |
340 VoiceChannel* voice_channel = new VoiceChannel( | 350 VoiceChannel* voice_channel = new VoiceChannel( |
341 worker_thread_, media_engine_.get(), media_channel, | 351 worker_thread_, media_engine_.get(), media_channel, |
342 session, content_name, rtcp); | 352 session, content_name, rtcp); |
343 if (!voice_channel->Init()) { | 353 if (!voice_channel->Init()) { |
344 delete voice_channel; | 354 delete voice_channel; |
345 return nullptr; | 355 return nullptr; |
346 } | 356 } |
347 voice_channels_.push_back(voice_channel); | 357 voice_channels_.push_back(voice_channel); |
348 return voice_channel; | 358 return voice_channel; |
349 } | 359 } |
350 | 360 |
351 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel, | 361 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) { |
352 VideoChannel* video_channel) { | |
353 if (voice_channel) { | 362 if (voice_channel) { |
354 worker_thread_->Invoke<void>( | 363 worker_thread_->Invoke<void>( |
355 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel, | 364 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel)); |
356 video_channel)); | |
357 } | 365 } |
358 } | 366 } |
359 | 367 |
360 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel, | 368 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) { |
361 VideoChannel* video_channel) { | |
362 // Destroy voice channel. | 369 // Destroy voice channel. |
363 ASSERT(initialized_); | 370 ASSERT(initialized_); |
364 ASSERT(worker_thread_ == rtc::Thread::Current()); | 371 ASSERT(worker_thread_ == rtc::Thread::Current()); |
365 VoiceChannels::iterator it = std::find(voice_channels_.begin(), | 372 VoiceChannels::iterator it = std::find(voice_channels_.begin(), |
366 voice_channels_.end(), voice_channel); | 373 voice_channels_.end(), voice_channel); |
367 ASSERT(it != voice_channels_.end()); | 374 ASSERT(it != voice_channels_.end()); |
368 if (it == voice_channels_.end()) | 375 if (it == voice_channels_.end()) |
369 return; | 376 return; |
370 | |
371 if (video_channel) { | |
372 video_channel->media_channel()->DetachVoiceChannel(); | |
373 } | |
374 voice_channels_.erase(it); | 377 voice_channels_.erase(it); |
375 delete voice_channel; | 378 delete voice_channel; |
376 } | 379 } |
377 | 380 |
378 VideoChannel* ChannelManager::CreateVideoChannel( | 381 VideoChannel* ChannelManager::CreateVideoChannel( |
| 382 webrtc::MediaControllerInterface* media_controller, |
379 BaseSession* session, | 383 BaseSession* session, |
380 const std::string& content_name, | 384 const std::string& content_name, |
381 bool rtcp, | 385 bool rtcp, |
382 VoiceChannel* voice_channel) { | 386 const VideoOptions& options) { |
383 return worker_thread_->Invoke<VideoChannel*>( | 387 return worker_thread_->Invoke<VideoChannel*>( |
384 Bind(&ChannelManager::CreateVideoChannel_w, | 388 Bind(&ChannelManager::CreateVideoChannel_w, |
385 this, | 389 this, |
| 390 media_controller, |
386 session, | 391 session, |
387 content_name, | 392 content_name, |
388 rtcp, | 393 rtcp, |
389 VideoOptions(), | 394 options)); |
390 voice_channel)); | |
391 } | 395 } |
392 | 396 |
393 VideoChannel* ChannelManager::CreateVideoChannel( | 397 VideoChannel* ChannelManager::CreateVideoChannel_w( |
| 398 webrtc::MediaControllerInterface* media_controller, |
394 BaseSession* session, | 399 BaseSession* session, |
395 const std::string& content_name, | 400 const std::string& content_name, |
396 bool rtcp, | 401 bool rtcp, |
397 const VideoOptions& options, | 402 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 } | |
408 | |
409 VideoChannel* ChannelManager::CreateVideoChannel_w( | |
410 BaseSession* session, | |
411 const std::string& content_name, | |
412 bool rtcp, | |
413 const VideoOptions& options, | |
414 VoiceChannel* voice_channel) { | |
415 ASSERT(initialized_); | 403 ASSERT(initialized_); |
416 ASSERT(worker_thread_ == rtc::Thread::Current()); | 404 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 405 ASSERT(nullptr != media_controller); |
417 VideoMediaChannel* media_channel = | 406 VideoMediaChannel* media_channel = |
418 // voice_channel can be NULL in case of NullVoiceEngine. | 407 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) | 408 if (media_channel == NULL) |
422 return NULL; | 409 return NULL; |
423 | 410 |
424 VideoChannel* video_channel = new VideoChannel( | 411 VideoChannel* video_channel = new VideoChannel( |
425 worker_thread_, media_channel, | 412 worker_thread_, media_channel, |
426 session, content_name, rtcp); | 413 session, content_name, rtcp); |
427 if (!video_channel->Init()) { | 414 if (!video_channel->Init()) { |
428 delete video_channel; | 415 delete video_channel; |
429 return NULL; | 416 return NULL; |
430 } | 417 } |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 const VideoFormat& max_format) { | 905 const VideoFormat& max_format) { |
919 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); | 906 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); |
920 } | 907 } |
921 | 908 |
922 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { | 909 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { |
923 return worker_thread_->Invoke<bool>( | 910 return worker_thread_->Invoke<bool>( |
924 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); | 911 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); |
925 } | 912 } |
926 | 913 |
927 } // namespace cricket | 914 } // namespace cricket |
OLD | NEW |