| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = new VoiceChannel( |
| 341 worker_thread_, media_engine_.get(), media_channel, | 341 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 Loading... |
| 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, |
| 385 this, | 385 this, |
| 386 session, | 386 transport_controller, |
| 387 content_name, | 387 content_name, |
| 388 rtcp, | 388 rtcp, |
| 389 VideoOptions(), | 389 VideoOptions(), |
| 390 voice_channel)); | 390 voice_channel)); |
| 391 } | 391 } |
| 392 | 392 |
| 393 VideoChannel* ChannelManager::CreateVideoChannel( | 393 VideoChannel* ChannelManager::CreateVideoChannel( |
| 394 BaseSession* session, | 394 TransportController* transport_controller, |
| 395 const std::string& content_name, | 395 const std::string& content_name, |
| 396 bool rtcp, | 396 bool rtcp, |
| 397 const VideoOptions& options, | 397 const VideoOptions& options, |
| 398 VoiceChannel* voice_channel) { | 398 VoiceChannel* voice_channel) { |
| 399 return worker_thread_->Invoke<VideoChannel*>( | 399 return worker_thread_->Invoke<VideoChannel*>( |
| 400 Bind(&ChannelManager::CreateVideoChannel_w, | 400 Bind(&ChannelManager::CreateVideoChannel_w, |
| 401 this, | 401 this, |
| 402 session, | 402 transport_controller, |
| 403 content_name, | 403 content_name, |
| 404 rtcp, | 404 rtcp, |
| 405 options, | 405 options, |
| 406 voice_channel)); | 406 voice_channel)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 VideoChannel* ChannelManager::CreateVideoChannel_w( | 409 VideoChannel* ChannelManager::CreateVideoChannel_w( |
| 410 BaseSession* session, | 410 TransportController* transport_controller, |
| 411 const std::string& content_name, | 411 const std::string& content_name, |
| 412 bool rtcp, | 412 bool rtcp, |
| 413 const VideoOptions& options, | 413 const VideoOptions& options, |
| 414 VoiceChannel* voice_channel) { | 414 VoiceChannel* voice_channel) { |
| 415 ASSERT(initialized_); | 415 ASSERT(initialized_); |
| 416 ASSERT(worker_thread_ == rtc::Thread::Current()); | 416 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 417 VideoMediaChannel* media_channel = | 417 VideoMediaChannel* media_channel = |
| 418 // voice_channel can be NULL in case of NullVoiceEngine. | 418 // voice_channel can be NULL in case of NullVoiceEngine. |
| 419 media_engine_->CreateVideoChannel( | 419 media_engine_->CreateVideoChannel( |
| 420 options, voice_channel ? voice_channel->media_channel() : NULL); | 420 options, voice_channel ? voice_channel->media_channel() : NULL); |
| 421 if (media_channel == NULL) | 421 if (media_channel == NULL) { |
| 422 return NULL; | 422 return NULL; |
| 423 } |
| 423 | 424 |
| 424 VideoChannel* video_channel = new VideoChannel( | 425 VideoChannel* video_channel = new VideoChannel( |
| 425 worker_thread_, media_channel, | 426 worker_thread_, media_channel, |
| 426 session, content_name, rtcp); | 427 transport_controller, content_name, rtcp); |
| 427 if (!video_channel->Init()) { | 428 if (!video_channel->Init()) { |
| 428 delete video_channel; | 429 delete video_channel; |
| 429 return NULL; | 430 return NULL; |
| 430 } | 431 } |
| 431 video_channels_.push_back(video_channel); | 432 video_channels_.push_back(video_channel); |
| 432 return video_channel; | 433 return video_channel; |
| 433 } | 434 } |
| 434 | 435 |
| 435 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { | 436 void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { |
| 436 if (video_channel) { | 437 if (video_channel) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 447 video_channels_.end(), video_channel); | 448 video_channels_.end(), video_channel); |
| 448 ASSERT(it != video_channels_.end()); | 449 ASSERT(it != video_channels_.end()); |
| 449 if (it == video_channels_.end()) | 450 if (it == video_channels_.end()) |
| 450 return; | 451 return; |
| 451 | 452 |
| 452 video_channels_.erase(it); | 453 video_channels_.erase(it); |
| 453 delete video_channel; | 454 delete video_channel; |
| 454 } | 455 } |
| 455 | 456 |
| 456 DataChannel* ChannelManager::CreateDataChannel( | 457 DataChannel* ChannelManager::CreateDataChannel( |
| 457 BaseSession* session, const std::string& content_name, | 458 TransportController* transport_controller, const std::string& content_name, |
| 458 bool rtcp, DataChannelType channel_type) { | 459 bool rtcp, DataChannelType channel_type) { |
| 459 return worker_thread_->Invoke<DataChannel*>( | 460 return worker_thread_->Invoke<DataChannel*>( |
| 460 Bind(&ChannelManager::CreateDataChannel_w, this, session, content_name, | 461 Bind(&ChannelManager::CreateDataChannel_w, this, transport_controller, |
| 461 rtcp, channel_type)); | 462 content_name, rtcp, channel_type)); |
| 462 } | 463 } |
| 463 | 464 |
| 464 DataChannel* ChannelManager::CreateDataChannel_w( | 465 DataChannel* ChannelManager::CreateDataChannel_w( |
| 465 BaseSession* session, const std::string& content_name, | 466 TransportController* transport_controller, const std::string& content_name, |
| 466 bool rtcp, DataChannelType data_channel_type) { | 467 bool rtcp, DataChannelType data_channel_type) { |
| 467 // This is ok to alloc from a thread other than the worker thread. | 468 // This is ok to alloc from a thread other than the worker thread. |
| 468 ASSERT(initialized_); | 469 ASSERT(initialized_); |
| 469 DataMediaChannel* media_channel = data_media_engine_->CreateChannel( | 470 DataMediaChannel* media_channel = data_media_engine_->CreateChannel( |
| 470 data_channel_type); | 471 data_channel_type); |
| 471 if (!media_channel) { | 472 if (!media_channel) { |
| 472 LOG(LS_WARNING) << "Failed to create data channel of type " | 473 LOG(LS_WARNING) << "Failed to create data channel of type " |
| 473 << data_channel_type; | 474 << data_channel_type; |
| 474 return NULL; | 475 return NULL; |
| 475 } | 476 } |
| 476 | 477 |
| 477 DataChannel* data_channel = new DataChannel( | 478 DataChannel* data_channel = new DataChannel( |
| 478 worker_thread_, media_channel, | 479 worker_thread_, media_channel, |
| 479 session, content_name, rtcp); | 480 transport_controller, content_name, rtcp); |
| 480 if (!data_channel->Init()) { | 481 if (!data_channel->Init()) { |
| 481 LOG(LS_WARNING) << "Failed to init data channel."; | 482 LOG(LS_WARNING) << "Failed to init data channel."; |
| 482 delete data_channel; | 483 delete data_channel; |
| 483 return NULL; | 484 return NULL; |
| 484 } | 485 } |
| 485 data_channels_.push_back(data_channel); | 486 data_channels_.push_back(data_channel); |
| 486 return data_channel; | 487 return data_channel; |
| 487 } | 488 } |
| 488 | 489 |
| 489 void ChannelManager::DestroyDataChannel(DataChannel* data_channel) { | 490 void ChannelManager::DestroyDataChannel(DataChannel* data_channel) { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 const VideoFormat& max_format) { | 947 const VideoFormat& max_format) { |
| 947 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); | 948 device_manager_->SetVideoCaptureDeviceMaxFormat(usb_id, max_format); |
| 948 } | 949 } |
| 949 | 950 |
| 950 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { | 951 bool ChannelManager::StartAecDump(rtc::PlatformFile file) { |
| 951 return worker_thread_->Invoke<bool>( | 952 return worker_thread_->Invoke<bool>( |
| 952 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); | 953 Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file)); |
| 953 } | 954 } |
| 954 | 955 |
| 955 } // namespace cricket | 956 } // namespace cricket |
| OLD | NEW |