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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 1670153003: Introduce struct MediaConfig, with construction-time settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed test nit; use reference. Created 4 years, 10 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 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 642
643 voe_wrapper_->base()->Terminate(); 643 voe_wrapper_->base()->Terminate();
644 } 644 }
645 645
646 rtc::scoped_refptr<webrtc::AudioState> 646 rtc::scoped_refptr<webrtc::AudioState>
647 WebRtcVoiceEngine::GetAudioState() const { 647 WebRtcVoiceEngine::GetAudioState() const {
648 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 648 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
649 return audio_state_; 649 return audio_state_;
650 } 650 }
651 651
652 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(webrtc::Call* call, 652 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(
653 webrtc::Call* call,
654 const MediaConfig& config,
653 const AudioOptions& options) { 655 const AudioOptions& options) {
654 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 656 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
655 return new WebRtcVoiceMediaChannel(this, options, call); 657 return new WebRtcVoiceMediaChannel(this, config, options, call);
656 } 658 }
657 659
658 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { 660 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
659 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 661 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
660 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString(); 662 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString();
661 AudioOptions options = options_in; // The options are modified below. 663 AudioOptions options = options_in; // The options are modified below.
662 664
663 // kEcConference is AEC with high suppression. 665 // kEcConference is AEC with high suppression.
664 webrtc::EcModes ec_mode = webrtc::kEcConference; 666 webrtc::EcModes ec_mode = webrtc::kEcConference;
665 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; 667 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone;
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 webrtc::Call* call_ = nullptr; 1361 webrtc::Call* call_ = nullptr;
1360 webrtc::AudioReceiveStream::Config config_; 1362 webrtc::AudioReceiveStream::Config config_;
1361 // The stream is owned by WebRtcAudioReceiveStream and may be reallocated if 1363 // The stream is owned by WebRtcAudioReceiveStream and may be reallocated if
1362 // configuration changes. 1364 // configuration changes.
1363 webrtc::AudioReceiveStream* stream_ = nullptr; 1365 webrtc::AudioReceiveStream* stream_ = nullptr;
1364 1366
1365 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream); 1367 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream);
1366 }; 1368 };
1367 1369
1368 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, 1370 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
1371 const MediaConfig& config,
1369 const AudioOptions& options, 1372 const AudioOptions& options,
1370 webrtc::Call* call) 1373 webrtc::Call* call)
1371 : engine_(engine), call_(call) { 1374 : VoiceMediaChannel(config), engine_(engine), call_(call) {
1372 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel"; 1375 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel";
1373 RTC_DCHECK(call); 1376 RTC_DCHECK(call);
1374 engine->RegisterChannel(this); 1377 engine->RegisterChannel(this);
1375 SetOptions(options); 1378 SetOptions(options);
1376 } 1379 }
1377 1380
1378 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { 1381 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() {
1379 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1382 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1380 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel"; 1383 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel";
1381 // TODO(solenberg): Should be able to delete the streams directly, without 1384 // TODO(solenberg): Should be able to delete the streams directly, without
1382 // going through RemoveNnStream(), once stream objects handle 1385 // going through RemoveNnStream(), once stream objects handle
1383 // all (de)configuration. 1386 // all (de)configuration.
1384 while (!send_streams_.empty()) { 1387 while (!send_streams_.empty()) {
1385 RemoveSendStream(send_streams_.begin()->first); 1388 RemoveSendStream(send_streams_.begin()->first);
1386 } 1389 }
1387 while (!recv_streams_.empty()) { 1390 while (!recv_streams_.empty()) {
1388 RemoveRecvStream(recv_streams_.begin()->first); 1391 RemoveRecvStream(recv_streams_.begin()->first);
1389 } 1392 }
1390 engine()->UnregisterChannel(this); 1393 engine()->UnregisterChannel(this);
1391 } 1394 }
1392 1395
1396 rtc::DiffServCodePoint WebRtcVoiceMediaChannel::PreferredDscp() const {
1397 return kAudioDscpValue;
1398 }
1399
1393 bool WebRtcVoiceMediaChannel::SetSendParameters( 1400 bool WebRtcVoiceMediaChannel::SetSendParameters(
1394 const AudioSendParameters& params) { 1401 const AudioSendParameters& params) {
1395 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1402 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1396 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " 1403 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: "
1397 << params.ToString(); 1404 << params.ToString();
1398 // TODO(pthatcher): Refactor this to be more clean now that we have 1405 // TODO(pthatcher): Refactor this to be more clean now that we have
1399 // all the information at once. 1406 // all the information at once.
1400 1407
1401 if (!SetSendCodecs(params.codecs)) { 1408 if (!SetSendCodecs(params.codecs)) {
1402 return false; 1409 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 } 1453 }
1447 } 1454 }
1448 return true; 1455 return true;
1449 } 1456 }
1450 1457
1451 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { 1458 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) {
1452 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1459 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1453 LOG(LS_INFO) << "Setting voice channel options: " 1460 LOG(LS_INFO) << "Setting voice channel options: "
1454 << options.ToString(); 1461 << options.ToString();
1455 1462
1456 // Check if DSCP value is changed from previous.
1457 bool dscp_option_changed = (options_.dscp != options.dscp);
1458
1459 // We retain all of the existing options, and apply the given ones 1463 // We retain all of the existing options, and apply the given ones
1460 // on top. This means there is no way to "clear" options such that 1464 // on top. This means there is no way to "clear" options such that
1461 // they go back to the engine default. 1465 // they go back to the engine default.
1462 options_.SetAll(options); 1466 options_.SetAll(options);
1463 if (!engine()->ApplyOptions(options_)) { 1467 if (!engine()->ApplyOptions(options_)) {
1464 LOG(LS_WARNING) << 1468 LOG(LS_WARNING) <<
1465 "Failed to apply engine options during channel SetOptions."; 1469 "Failed to apply engine options during channel SetOptions.";
1466 return false; 1470 return false;
1467 } 1471 }
1468
1469 if (dscp_option_changed) {
1470 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT;
1471 if (options_.dscp.value_or(false)) {
1472 dscp = kAudioDscpValue;
1473 }
1474 if (MediaChannel::SetDscp(dscp) != 0) {
1475 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel";
1476 }
1477 }
1478
1479 LOG(LS_INFO) << "Set voice channel options. Current options: " 1472 LOG(LS_INFO) << "Set voice channel options. Current options: "
1480 << options_.ToString(); 1473 << options_.ToString();
1481 return true; 1474 return true;
1482 } 1475 }
1483 1476
1484 bool WebRtcVoiceMediaChannel::SetRecvCodecs( 1477 bool WebRtcVoiceMediaChannel::SetRecvCodecs(
1485 const std::vector<AudioCodec>& codecs) { 1478 const std::vector<AudioCodec>& codecs) {
1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1479 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1487 1480
1488 // Set the payload types to be used for incoming media. 1481 // Set the payload types to be used for incoming media.
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 } 2546 }
2554 } else { 2547 } else {
2555 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2548 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2556 engine()->voe()->base()->StopPlayout(channel); 2549 engine()->voe()->base()->StopPlayout(channel);
2557 } 2550 }
2558 return true; 2551 return true;
2559 } 2552 }
2560 } // namespace cricket 2553 } // namespace cricket
2561 2554
2562 #endif // HAVE_WEBRTC_VOICE 2555 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698