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

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

Issue 1646253004: Split out dscp option from VideoOptions to new struct MediaChannelOptions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename DscpValue --> MediaTypeDscpValue. 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 * 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 585
586 voe_wrapper_->base()->Terminate(); 586 voe_wrapper_->base()->Terminate();
587 } 587 }
588 588
589 rtc::scoped_refptr<webrtc::AudioState> 589 rtc::scoped_refptr<webrtc::AudioState>
590 WebRtcVoiceEngine::GetAudioState() const { 590 WebRtcVoiceEngine::GetAudioState() const {
591 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 591 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
592 return audio_state_; 592 return audio_state_;
593 } 593 }
594 594
595 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(webrtc::Call* call, 595 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(
596 const AudioOptions& options) { 596 webrtc::Call* call,
597 const MediaChannelOptions& options,
598 const AudioOptions& audio_options) {
597 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 599 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
598 return new WebRtcVoiceMediaChannel(this, options, call); 600 return new WebRtcVoiceMediaChannel(this, options, audio_options, call);
599 } 601 }
600 602
601 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { 603 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
602 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 604 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
603 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString(); 605 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString();
604 AudioOptions options = options_in; // The options are modified below. 606 AudioOptions options = options_in; // The options are modified below.
605 607
606 // kEcConference is AEC with high suppression. 608 // kEcConference is AEC with high suppression.
607 webrtc::EcModes ec_mode = webrtc::kEcConference; 609 webrtc::EcModes ec_mode = webrtc::kEcConference;
608 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; 610 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone;
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 rtc::ThreadChecker worker_thread_checker_; 1284 rtc::ThreadChecker worker_thread_checker_;
1283 webrtc::Call* call_ = nullptr; 1285 webrtc::Call* call_ = nullptr;
1284 webrtc::AudioReceiveStream::Config config_; 1286 webrtc::AudioReceiveStream::Config config_;
1285 // The stream is owned by WebRtcAudioReceiveStream and may be reallocated if 1287 // The stream is owned by WebRtcAudioReceiveStream and may be reallocated if
1286 // configuration changes. 1288 // configuration changes.
1287 webrtc::AudioReceiveStream* stream_ = nullptr; 1289 webrtc::AudioReceiveStream* stream_ = nullptr;
1288 1290
1289 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream); 1291 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream);
1290 }; 1292 };
1291 1293
1292 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, 1294 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(
1293 const AudioOptions& options, 1295 WebRtcVoiceEngine* engine,
1294 webrtc::Call* call) 1296 const MediaChannelOptions& options,
1295 : engine_(engine), call_(call) { 1297 const AudioOptions& audio_options,
1298 webrtc::Call* call)
1299 : VoiceMediaChannel(options), engine_(engine), call_(call) {
1296 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel"; 1300 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel";
1297 RTC_DCHECK(call); 1301 RTC_DCHECK(call);
1298 engine->RegisterChannel(this); 1302 engine->RegisterChannel(this);
1299 SetOptions(options); 1303 SetOptions(audio_options);
1300 } 1304 }
1301 1305
1302 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { 1306 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() {
1303 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1307 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1304 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel"; 1308 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel";
1305 // TODO(solenberg): Should be able to delete the streams directly, without 1309 // TODO(solenberg): Should be able to delete the streams directly, without
1306 // going through RemoveNnStream(), once stream objects handle 1310 // going through RemoveNnStream(), once stream objects handle
1307 // all (de)configuration. 1311 // all (de)configuration.
1308 while (!send_streams_.empty()) { 1312 while (!send_streams_.empty()) {
1309 RemoveSendStream(send_streams_.begin()->first); 1313 RemoveSendStream(send_streams_.begin()->first);
1310 } 1314 }
1311 while (!recv_streams_.empty()) { 1315 while (!recv_streams_.empty()) {
1312 RemoveRecvStream(recv_streams_.begin()->first); 1316 RemoveRecvStream(recv_streams_.begin()->first);
1313 } 1317 }
1314 engine()->UnregisterChannel(this); 1318 engine()->UnregisterChannel(this);
1315 } 1319 }
1316 1320
1321 rtc::DiffServCodePoint WebRtcVoiceMediaChannel::MediaTypeDscpValue() const {
1322 return kAudioDscpValue;
1323 }
1324
1317 bool WebRtcVoiceMediaChannel::SetSendParameters( 1325 bool WebRtcVoiceMediaChannel::SetSendParameters(
1318 const AudioSendParameters& params) { 1326 const AudioSendParameters& params) {
1319 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1327 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1320 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " 1328 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: "
1321 << params.ToString(); 1329 << params.ToString();
1322 // TODO(pthatcher): Refactor this to be more clean now that we have 1330 // TODO(pthatcher): Refactor this to be more clean now that we have
1323 // all the information at once. 1331 // all the information at once.
1324 1332
1325 if (!SetSendCodecs(params.codecs)) { 1333 if (!SetSendCodecs(params.codecs)) {
1326 return false; 1334 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 } 1379 }
1372 1380
1373 return true; 1381 return true;
1374 } 1382 }
1375 1383
1376 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { 1384 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) {
1377 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1385 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1378 LOG(LS_INFO) << "Setting voice channel options: " 1386 LOG(LS_INFO) << "Setting voice channel options: "
1379 << options.ToString(); 1387 << options.ToString();
1380 1388
1381 // Check if DSCP value is changed from previous.
1382 bool dscp_option_changed = (options_.dscp != options.dscp);
1383
1384 // We retain all of the existing options, and apply the given ones 1389 // We retain all of the existing options, and apply the given ones
1385 // on top. This means there is no way to "clear" options such that 1390 // on top. This means there is no way to "clear" options such that
1386 // they go back to the engine default. 1391 // they go back to the engine default.
1387 options_.SetAll(options); 1392 options_.SetAll(options);
1388 if (!engine()->ApplyOptions(options_)) { 1393 if (!engine()->ApplyOptions(options_)) {
1389 LOG(LS_WARNING) << 1394 LOG(LS_WARNING) <<
1390 "Failed to apply engine options during channel SetOptions."; 1395 "Failed to apply engine options during channel SetOptions.";
1391 return false; 1396 return false;
1392 } 1397 }
1393 1398
1394 if (dscp_option_changed) {
1395 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT;
1396 if (options_.dscp.value_or(false)) {
1397 dscp = kAudioDscpValue;
1398 }
1399 if (MediaChannel::SetDscp(dscp) != 0) {
1400 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel";
1401 }
1402 }
1403
1404 // TODO(solenberg): Don't recreate unless options changed. 1399 // TODO(solenberg): Don't recreate unless options changed.
1405 for (auto& it : recv_streams_) { 1400 for (auto& it : recv_streams_) {
1406 it.second->RecreateAudioReceiveStream( 1401 it.second->RecreateAudioReceiveStream(
1407 options_.combined_audio_video_bwe.value_or(false)); 1402 options_.combined_audio_video_bwe.value_or(false));
1408 } 1403 }
1409 1404
1410 LOG(LS_INFO) << "Set voice channel options. Current options: " 1405 LOG(LS_INFO) << "Set voice channel options. Current options: "
1411 << options_.ToString(); 1406 << options_.ToString();
1412 return true; 1407 return true;
1413 } 1408 }
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 } 2525 }
2531 } else { 2526 } else {
2532 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2527 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2533 engine()->voe()->base()->StopPlayout(channel); 2528 engine()->voe()->base()->StopPlayout(channel);
2534 } 2529 }
2535 return true; 2530 return true;
2536 } 2531 }
2537 } // namespace cricket 2532 } // namespace cricket
2538 2533
2539 #endif // HAVE_WEBRTC_VOICE 2534 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698