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

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

Issue 1500633002: Refactor handling of AudioOptions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years 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
« no previous file with comments | « talk/session/media/channelmanager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void ChannelManager::Construct(MediaEngineInterface* me, 94 void ChannelManager::Construct(MediaEngineInterface* me,
95 DataEngineInterface* dme, 95 DataEngineInterface* dme,
96 CaptureManager* cm, 96 CaptureManager* cm,
97 rtc::Thread* worker_thread) { 97 rtc::Thread* worker_thread) {
98 media_engine_.reset(me); 98 media_engine_.reset(me);
99 data_media_engine_.reset(dme); 99 data_media_engine_.reset(dme);
100 capture_manager_.reset(cm); 100 capture_manager_.reset(cm);
101 initialized_ = false; 101 initialized_ = false;
102 main_thread_ = rtc::Thread::Current(); 102 main_thread_ = rtc::Thread::Current();
103 worker_thread_ = worker_thread; 103 worker_thread_ = worker_thread;
104 // Get the default audio options from the media engine.
105 audio_options_ = media_engine_->GetAudioOptions();
106 audio_output_volume_ = kNotSetOutputVolume; 104 audio_output_volume_ = kNotSetOutputVolume;
107 local_renderer_ = NULL; 105 local_renderer_ = NULL;
108 capturing_ = false; 106 capturing_ = false;
109 enable_rtx_ = false; 107 enable_rtx_ = false;
110 108
111 capture_manager_->SignalCapturerStateChange.connect( 109 capture_manager_->SignalCapturerStateChange.connect(
112 this, &ChannelManager::OnVideoCaptureStateChange); 110 this, &ChannelManager::OnVideoCaptureStateChange);
113 } 111 }
114 112
115 ChannelManager::~ChannelManager() { 113 ChannelManager::~ChannelManager() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 &rtc::Thread::SetAllowBlockingCalls, worker_thread_, false)); 196 &rtc::Thread::SetAllowBlockingCalls, worker_thread_, false));
199 } 197 }
200 198
201 initialized_ = worker_thread_->Invoke<bool>(Bind( 199 initialized_ = worker_thread_->Invoke<bool>(Bind(
202 &ChannelManager::InitMediaEngine_w, this)); 200 &ChannelManager::InitMediaEngine_w, this));
203 ASSERT(initialized_); 201 ASSERT(initialized_);
204 if (!initialized_) { 202 if (!initialized_) {
205 return false; 203 return false;
206 } 204 }
207 205
208 if (!SetAudioOptions(audio_options_)) {
209 LOG(LS_WARNING) << "Failed to SetAudioOptions with options: "
210 << audio_options_.ToString();
211 }
212
213 // If audio_output_volume_ has been set via SetOutputVolume(), set the 206 // If audio_output_volume_ has been set via SetOutputVolume(), set the
214 // audio output volume of the engine. 207 // audio output volume of the engine.
215 if (kNotSetOutputVolume != audio_output_volume_ && 208 if (kNotSetOutputVolume != audio_output_volume_ &&
216 !SetOutputVolume(audio_output_volume_)) { 209 !SetOutputVolume(audio_output_volume_)) {
217 LOG(LS_WARNING) << "Failed to SetOutputVolume to " 210 LOG(LS_WARNING) << "Failed to SetOutputVolume to "
218 << audio_output_volume_; 211 << audio_output_volume_;
219 } 212 }
220 213
221 // Now apply the default video codec that has been set earlier. 214 // Now apply the default video codec that has been set earlier.
222 if (default_video_encoder_config_.max_codec.id != 0) { 215 if (default_video_encoder_config_.max_codec.id != 0) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 DataChannels::iterator it = std::find(data_channels_.begin(), 413 DataChannels::iterator it = std::find(data_channels_.begin(),
421 data_channels_.end(), data_channel); 414 data_channels_.end(), data_channel);
422 ASSERT(it != data_channels_.end()); 415 ASSERT(it != data_channels_.end());
423 if (it == data_channels_.end()) 416 if (it == data_channels_.end())
424 return; 417 return;
425 418
426 data_channels_.erase(it); 419 data_channels_.erase(it);
427 delete data_channel; 420 delete data_channel;
428 } 421 }
429 422
430 bool ChannelManager::SetAudioOptions(const AudioOptions& options) {
431 // "Get device ids from DeviceManager" - these are the defaults returned.
432 Device in_dev("", -1);
433 Device out_dev("", -1);
434
435 // If we're initialized, pass the settings to the media engine.
436 bool ret = true;
437 if (initialized_) {
438 ret = worker_thread_->Invoke<bool>(
439 Bind(&ChannelManager::SetAudioOptions_w, this,
440 options, &in_dev, &out_dev));
441 }
442
443 // If all worked well, save the values for use in GetAudioOptions.
444 if (ret) {
445 audio_options_ = options;
446 }
447 return ret;
448 }
449
450 bool ChannelManager::SetAudioOptions_w(
451 const AudioOptions& options,
452 const Device* in_dev, const Device* out_dev) {
453 ASSERT(worker_thread_ == rtc::Thread::Current());
454 ASSERT(initialized_);
455
456 // Set audio options
457 bool ret = media_engine_->SetAudioOptions(options);
458
459 // Set the audio devices
460 if (ret) {
461 ret = media_engine_->SetSoundDevices(in_dev, out_dev);
462 }
463
464 return ret;
465 }
466
467 bool ChannelManager::GetOutputVolume(int* level) { 423 bool ChannelManager::GetOutputVolume(int* level) {
468 if (!initialized_) { 424 if (!initialized_) {
469 return false; 425 return false;
470 } 426 }
471 return worker_thread_->Invoke<bool>( 427 return worker_thread_->Invoke<bool>(
472 Bind(&MediaEngineInterface::GetOutputVolume, media_engine_.get(), level)); 428 Bind(&MediaEngineInterface::GetOutputVolume, media_engine_.get(), level));
473 } 429 }
474 430
475 bool ChannelManager::SetOutputVolume(int level) { 431 bool ChannelManager::SetOutputVolume(int level) {
476 bool ret = level >= 0 && level <= 255; 432 bool ret = level >= 0 && level <= 255;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return worker_thread_->Invoke<bool>( 575 return worker_thread_->Invoke<bool>(
620 Bind(&MediaEngineInterface::StartRtcEventLog, media_engine_.get(), file)); 576 Bind(&MediaEngineInterface::StartRtcEventLog, media_engine_.get(), file));
621 } 577 }
622 578
623 void ChannelManager::StopRtcEventLog() { 579 void ChannelManager::StopRtcEventLog() {
624 worker_thread_->Invoke<void>( 580 worker_thread_->Invoke<void>(
625 Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get())); 581 Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get()));
626 } 582 }
627 583
628 } // namespace cricket 584 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/channelmanager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698