Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: talk/session/media/channelmanager.cc

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nullptr Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 capture_manager_.reset(NULL); 301 capture_manager_.reset(NULL);
302 } 302 }
303 303
304 void ChannelManager::Terminate_w() { 304 void ChannelManager::Terminate_w() {
305 ASSERT(worker_thread_ == rtc::Thread::Current()); 305 ASSERT(worker_thread_ == rtc::Thread::Current());
306 // Need to destroy the voice/video channels 306 // Need to destroy the voice/video channels
307 while (!video_channels_.empty()) { 307 while (!video_channels_.empty()) {
308 DestroyVideoChannel_w(video_channels_.back()); 308 DestroyVideoChannel_w(video_channels_.back());
309 } 309 }
310 while (!voice_channels_.empty()) { 310 while (!voice_channels_.empty()) {
311 DestroyVoiceChannel_w(voice_channels_.back(), nullptr); 311 DestroyVoiceChannel_w(voice_channels_.back());
312 } 312 }
313 if (!SetCaptureDevice_w(NULL)) { 313 if (!SetCaptureDevice_w(NULL)) {
314 LOG(LS_WARNING) << "failed to delete video capturer"; 314 LOG(LS_WARNING) << "failed to delete video capturer";
315 } 315 }
316 media_engine_->Terminate(); 316 media_engine_->Terminate();
317 } 317 }
318 318
319 VoiceChannel* ChannelManager::CreateVoiceChannel( 319 VoiceChannel* ChannelManager::CreateVoiceChannel(
320 BaseSession* session, 320 BaseSession* session,
321 const std::string& content_name, 321 const std::string& content_name,
322 bool rtcp, 322 bool rtcp,
323 webrtc::Call* call,
323 const AudioOptions& options) { 324 const AudioOptions& options) {
324 return worker_thread_->Invoke<VoiceChannel*>( 325 return worker_thread_->Invoke<VoiceChannel*>(
325 Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name, 326 Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name,
326 rtcp, options)); 327 rtcp, call, options));
327 } 328 }
328 329
329 VoiceChannel* ChannelManager::CreateVoiceChannel_w( 330 VoiceChannel* ChannelManager::CreateVoiceChannel_w(
330 BaseSession* session, 331 BaseSession* session,
331 const std::string& content_name, 332 const std::string& content_name,
332 bool rtcp, 333 bool rtcp,
334 webrtc::Call* call,
333 const AudioOptions& options) { 335 const AudioOptions& options) {
334 ASSERT(initialized_); 336 ASSERT(initialized_);
335 ASSERT(worker_thread_ == rtc::Thread::Current()); 337 ASSERT(worker_thread_ == rtc::Thread::Current());
336 VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options); 338 VoiceMediaChannel* media_channel =
339 media_engine_->CreateChannel(call, options);
337 if (!media_channel) 340 if (!media_channel)
338 return nullptr; 341 return nullptr;
339 342
340 VoiceChannel* voice_channel = new VoiceChannel( 343 VoiceChannel* voice_channel = new VoiceChannel(
341 worker_thread_, media_engine_.get(), media_channel, 344 worker_thread_, media_engine_.get(), media_channel,
342 session, content_name, rtcp); 345 session, content_name, rtcp);
343 if (!voice_channel->Init()) { 346 if (!voice_channel->Init()) {
344 delete voice_channel; 347 delete voice_channel;
345 return nullptr; 348 return nullptr;
346 } 349 }
347 voice_channels_.push_back(voice_channel); 350 voice_channels_.push_back(voice_channel);
348 return voice_channel; 351 return voice_channel;
349 } 352 }
350 353
351 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel, 354 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) {
352 VideoChannel* video_channel) {
353 if (voice_channel) { 355 if (voice_channel) {
354 worker_thread_->Invoke<void>( 356 worker_thread_->Invoke<void>(
355 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel, 357 Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel));
356 video_channel));
357 } 358 }
358 } 359 }
359 360
360 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel, 361 void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) {
361 VideoChannel* video_channel) {
362 // Destroy voice channel. 362 // Destroy voice channel.
363 ASSERT(initialized_); 363 ASSERT(initialized_);
364 ASSERT(worker_thread_ == rtc::Thread::Current()); 364 ASSERT(worker_thread_ == rtc::Thread::Current());
365 VoiceChannels::iterator it = std::find(voice_channels_.begin(), 365 VoiceChannels::iterator it = std::find(voice_channels_.begin(),
366 voice_channels_.end(), voice_channel); 366 voice_channels_.end(), voice_channel);
367 ASSERT(it != voice_channels_.end()); 367 ASSERT(it != voice_channels_.end());
368 if (it == voice_channels_.end()) 368 if (it == voice_channels_.end())
369 return; 369 return;
370
371 if (video_channel) {
372 video_channel->media_channel()->DetachVoiceChannel();
373 }
374 voice_channels_.erase(it); 370 voice_channels_.erase(it);
375 delete voice_channel; 371 delete voice_channel;
376 } 372 }
377 373
378 VideoChannel* ChannelManager::CreateVideoChannel( 374 VideoChannel* ChannelManager::CreateVideoChannel(
379 BaseSession* session, 375 BaseSession* session,
380 const std::string& content_name, 376 const std::string& content_name,
381 bool rtcp, 377 bool rtcp,
382 VoiceChannel* voice_channel) { 378 webrtc::Call* call,
379 const VideoOptions& options) {
383 return worker_thread_->Invoke<VideoChannel*>( 380 return worker_thread_->Invoke<VideoChannel*>(
384 Bind(&ChannelManager::CreateVideoChannel_w, 381 Bind(&ChannelManager::CreateVideoChannel_w,
385 this, 382 this,
386 session, 383 session,
387 content_name, 384 content_name,
388 rtcp, 385 rtcp,
389 VideoOptions(), 386 call,
390 voice_channel)); 387 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 } 388 }
408 389
409 VideoChannel* ChannelManager::CreateVideoChannel_w( 390 VideoChannel* ChannelManager::CreateVideoChannel_w(
410 BaseSession* session, 391 BaseSession* session,
411 const std::string& content_name, 392 const std::string& content_name,
412 bool rtcp, 393 bool rtcp,
413 const VideoOptions& options, 394 webrtc::Call* call,
414 VoiceChannel* voice_channel) { 395 const VideoOptions& options) {
415 ASSERT(initialized_); 396 ASSERT(initialized_);
416 ASSERT(worker_thread_ == rtc::Thread::Current()); 397 ASSERT(worker_thread_ == rtc::Thread::Current());
417 VideoMediaChannel* media_channel = 398 VideoMediaChannel* media_channel =
418 // voice_channel can be NULL in case of NullVoiceEngine. 399 media_engine_->CreateVideoChannel(call, options);
419 media_engine_->CreateVideoChannel(
420 options, voice_channel ? voice_channel->media_channel() : NULL);
421 if (media_channel == NULL) 400 if (media_channel == NULL)
422 return NULL; 401 return NULL;
423 402
424 VideoChannel* video_channel = new VideoChannel( 403 VideoChannel* video_channel = new VideoChannel(
425 worker_thread_, media_channel, 404 worker_thread_, media_channel,
426 session, content_name, rtcp); 405 session, content_name, rtcp);
427 if (!video_channel->Init()) { 406 if (!video_channel->Init()) {
428 delete video_channel; 407 delete video_channel;
429 return NULL; 408 return NULL;
430 } 409 }
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 const VideoFormat& max_format) { 897 const VideoFormat& max_format) {
919 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); 898 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format);
920 } 899 }
921 900
922 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { 901 bool ChannelManager::StartAecDump(rtc::PlatformFile file) {
923 return worker_thread_->Invoke<bool>( 902 return worker_thread_->Invoke<bool>(
924 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); 903 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file));
925 } 904 }
926 905
927 } // namespace cricket 906 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698