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

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

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Set media engine on voice channel Created 5 years, 4 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 while (!voice_channels_.empty()) { 310 while (!voice_channels_.empty()) {
311 DestroyVoiceChannel_w(voice_channels_.back(), nullptr); 311 DestroyVoiceChannel_w(voice_channels_.back(), nullptr);
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 TransportController* transport_controller,
321 const std::string& content_name, 321 const std::string& content_name,
322 bool rtcp, 322 bool rtcp,
323 const AudioOptions& options) { 323 const AudioOptions& options) {
324 return worker_thread_->Invoke<VoiceChannel*>( 324 return worker_thread_->Invoke<VoiceChannel*>(
325 Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name, 325 Bind(&ChannelManager::CreateVoiceChannel_w, this, transport_controller,
326 rtcp, options)); 326 content_name, rtcp, options));
327 } 327 }
328 328
329 VoiceChannel* ChannelManager::CreateVoiceChannel_w( 329 VoiceChannel* ChannelManager::CreateVoiceChannel_w(
330 BaseSession* session, 330 TransportController* transport_controller,
331 const std::string& content_name, 331 const std::string& content_name,
332 bool rtcp, 332 bool rtcp,
333 const AudioOptions& options) { 333 const AudioOptions& options) {
334 ASSERT(initialized_); 334 ASSERT(initialized_);
335 ASSERT(worker_thread_ == rtc::Thread::Current()); 335 ASSERT(worker_thread_ == rtc::Thread::Current());
336 VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options); 336 VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options);
337 if (!media_channel) 337 if (!media_channel)
338 return nullptr; 338 return nullptr;
339 339
340 VoiceChannel* voice_channel = new VoiceChannel( 340 VoiceChannel* voice_channel =
341 worker_thread_, media_engine_.get(), media_channel, 341 new VoiceChannel(worker_thread_, media_engine_.get(), media_channel,
342 session, content_name, rtcp); 342 transport_controller, content_name, rtcp);
343 if (!voice_channel->Init()) { 343 if (!voice_channel->Init()) {
344 delete voice_channel; 344 delete voice_channel;
345 return nullptr; 345 return nullptr;
346 } 346 }
347 voice_channels_.push_back(voice_channel); 347 voice_channels_.push_back(voice_channel);
348 return voice_channel; 348 return voice_channel;
349 } 349 }
350 350
351 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel, 351 void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel,
352 VideoChannel* video_channel) { 352 VideoChannel* video_channel) {
(...skipping 16 matching lines...) Expand all
369 return; 369 return;
370 370
371 if (video_channel) { 371 if (video_channel) {
372 video_channel->media_channel()->DetachVoiceChannel(); 372 video_channel->media_channel()->DetachVoiceChannel();
373 } 373 }
374 voice_channels_.erase(it); 374 voice_channels_.erase(it);
375 delete voice_channel; 375 delete voice_channel;
376 } 376 }
377 377
378 VideoChannel* ChannelManager::CreateVideoChannel( 378 VideoChannel* ChannelManager::CreateVideoChannel(
379 BaseSession* session, 379 TransportController* transport_controller,
380 const std::string& content_name, 380 const std::string& content_name,
381 bool rtcp, 381 bool rtcp,
382 VoiceChannel* voice_channel) { 382 VoiceChannel* voice_channel) {
383 return worker_thread_->Invoke<VideoChannel*>( 383 return worker_thread_->Invoke<VideoChannel*>(
384 Bind(&ChannelManager::CreateVideoChannel_w, 384 Bind(&ChannelManager::CreateVideoChannel_w, this, transport_controller,
385 this, 385 content_name, rtcp, VideoOptions(), voice_channel));
386 session,
387 content_name,
388 rtcp,
389 VideoOptions(),
390 voice_channel));
391 } 386 }
392 387
393 VideoChannel* ChannelManager::CreateVideoChannel( 388 VideoChannel* ChannelManager::CreateVideoChannel(
394 BaseSession* session, 389 TransportController* transport_controller,
395 const std::string& content_name, 390 const std::string& content_name,
396 bool rtcp, 391 bool rtcp,
397 const VideoOptions& options, 392 const VideoOptions& options,
398 VoiceChannel* voice_channel) { 393 VoiceChannel* voice_channel) {
399 return worker_thread_->Invoke<VideoChannel*>( 394 return worker_thread_->Invoke<VideoChannel*>(
400 Bind(&ChannelManager::CreateVideoChannel_w, 395 Bind(&ChannelManager::CreateVideoChannel_w, this, transport_controller,
401 this, 396 content_name, rtcp, options, voice_channel));
402 session,
403 content_name,
404 rtcp,
405 options,
406 voice_channel));
407 } 397 }
408 398
409 VideoChannel* ChannelManager::CreateVideoChannel_w( 399 VideoChannel* ChannelManager::CreateVideoChannel_w(
410 BaseSession* session, 400 TransportController* transport_controller,
411 const std::string& content_name, 401 const std::string& content_name,
412 bool rtcp, 402 bool rtcp,
413 const VideoOptions& options, 403 const VideoOptions& options,
414 VoiceChannel* voice_channel) { 404 VoiceChannel* voice_channel) {
415 ASSERT(initialized_); 405 ASSERT(initialized_);
416 ASSERT(worker_thread_ == rtc::Thread::Current()); 406 ASSERT(worker_thread_ == rtc::Thread::Current());
417 VideoMediaChannel* media_channel = 407 VideoMediaChannel* media_channel =
418 // voice_channel can be NULL in case of NullVoiceEngine. 408 // voice_channel can be NULL in case of NullVoiceEngine.
419 media_engine_->CreateVideoChannel( 409 media_engine_->CreateVideoChannel(
420 options, voice_channel ? voice_channel->media_channel() : NULL); 410 options, voice_channel ? voice_channel->media_channel() : NULL);
421 if (media_channel == NULL) 411 if (media_channel == NULL) {
422 return NULL; 412 return NULL;
413 }
423 414
424 VideoChannel* video_channel = new VideoChannel( 415 VideoChannel* video_channel = new VideoChannel(
425 worker_thread_, media_channel, 416 worker_thread_, media_channel, transport_controller, content_name, rtcp);
426 session, content_name, rtcp);
427 if (!video_channel->Init()) { 417 if (!video_channel->Init()) {
428 delete video_channel; 418 delete video_channel;
429 return NULL; 419 return NULL;
430 } 420 }
431 video_channels_.push_back(video_channel); 421 video_channels_.push_back(video_channel);
432 return video_channel; 422 return video_channel;
433 } 423 }
434 424
435 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { 425 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) {
436 if (video_channel) { 426 if (video_channel) {
(...skipping 10 matching lines...) Expand all
447 video_channels_.end(), video_channel); 437 video_channels_.end(), video_channel);
448 ASSERT(it != video_channels_.end()); 438 ASSERT(it != video_channels_.end());
449 if (it == video_channels_.end()) 439 if (it == video_channels_.end())
450 return; 440 return;
451 441
452 video_channels_.erase(it); 442 video_channels_.erase(it);
453 delete video_channel; 443 delete video_channel;
454 } 444 }
455 445
456 DataChannel* ChannelManager::CreateDataChannel( 446 DataChannel* ChannelManager::CreateDataChannel(
457 BaseSession* session, const std::string& content_name, 447 TransportController* transport_controller,
458 bool rtcp, DataChannelType channel_type) { 448 const std::string& content_name,
449 bool rtcp,
450 DataChannelType channel_type) {
459 return worker_thread_->Invoke<DataChannel*>( 451 return worker_thread_->Invoke<DataChannel*>(
460 Bind(&ChannelManager::CreateDataChannel_w, this, session, content_name, 452 Bind(&ChannelManager::CreateDataChannel_w, this, transport_controller,
461 rtcp, channel_type)); 453 content_name, rtcp, channel_type));
462 } 454 }
463 455
464 DataChannel* ChannelManager::CreateDataChannel_w( 456 DataChannel* ChannelManager::CreateDataChannel_w(
465 BaseSession* session, const std::string& content_name, 457 TransportController* transport_controller,
466 bool rtcp, DataChannelType data_channel_type) { 458 const std::string& content_name,
459 bool rtcp,
460 DataChannelType data_channel_type) {
467 // This is ok to alloc from a thread other than the worker thread. 461 // This is ok to alloc from a thread other than the worker thread.
468 ASSERT(initialized_); 462 ASSERT(initialized_);
469 DataMediaChannel* media_channel = data_media_engine_->CreateChannel( 463 DataMediaChannel* media_channel = data_media_engine_->CreateChannel(
470 data_channel_type); 464 data_channel_type);
471 if (!media_channel) { 465 if (!media_channel) {
472 LOG(LS_WARNING) << "Failed to create data channel of type " 466 LOG(LS_WARNING) << "Failed to create data channel of type "
473 << data_channel_type; 467 << data_channel_type;
474 return NULL; 468 return NULL;
475 } 469 }
476 470
477 DataChannel* data_channel = new DataChannel( 471 DataChannel* data_channel = new DataChannel(
478 worker_thread_, media_channel, 472 worker_thread_, media_channel, transport_controller, content_name, rtcp);
479 session, content_name, rtcp);
480 if (!data_channel->Init()) { 473 if (!data_channel->Init()) {
481 LOG(LS_WARNING) << "Failed to init data channel."; 474 LOG(LS_WARNING) << "Failed to init data channel.";
482 delete data_channel; 475 delete data_channel;
483 return NULL; 476 return NULL;
484 } 477 }
485 data_channels_.push_back(data_channel); 478 data_channels_.push_back(data_channel);
486 return data_channel; 479 return data_channel;
487 } 480 }
488 481
489 void ChannelManager::DestroyDataChannel(DataChannel* data_channel) { 482 void ChannelManager::DestroyDataChannel(DataChannel* data_channel) {
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 const VideoFormat& max_format) { 939 const VideoFormat& max_format) {
947 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); 940 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format);
948 } 941 }
949 942
950 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { 943 bool ChannelManager::StartAecDump(rtc::PlatformFile file) {
951 return worker_thread_->Invoke<bool>( 944 return worker_thread_->Invoke<bool>(
952 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); 945 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file));
953 } 946 }
954 947
955 } // namespace cricket 948 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698