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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2924363004: Fix Channel::GetSendCodec when used together with SetEncoder. (Closed)
Patch Set: Remove RTC_DCHECK(false) used for debugging. :) Created 3 years, 6 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
« no previous file with comments | « webrtc/voice_engine/channel.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 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 // TODO(ossu): Make a CodecInst up for now. It seems like very little of this 1281 // TODO(ossu): Make a CodecInst up for now. It seems like very little of this
1282 // information is actually used, possibly only payload type and clock rate. 1282 // information is actually used, possibly only payload type and clock rate.
1283 CodecInst lies; 1283 CodecInst lies;
1284 lies.pltype = payload_type; 1284 lies.pltype = payload_type;
1285 strncpy(lies.plname, "audio", sizeof(lies.plname)); 1285 strncpy(lies.plname, "audio", sizeof(lies.plname));
1286 lies.plname[sizeof(lies.plname) - 1] = 0; 1286 lies.plname[sizeof(lies.plname) - 1] = 0;
1287 // Seems unclear if it should be clock rate or sample rate. CodecInst 1287 // Seems unclear if it should be clock rate or sample rate. CodecInst
1288 // supposedly carries the sample rate, but only clock rate seems sensible to 1288 // supposedly carries the sample rate, but only clock rate seems sensible to
1289 // send to the RTP/RTCP module. 1289 // send to the RTP/RTCP module.
1290 lies.plfreq = encoder->RtpTimestampRateHz(); 1290 lies.plfreq = encoder->RtpTimestampRateHz();
1291 lies.pacsize = 0; 1291 lies.pacsize = rtc::CheckedDivExact(
1292 static_cast<int>(encoder->Max10MsFramesInAPacket() * lies.plfreq), 100);
1292 lies.channels = encoder->NumChannels(); 1293 lies.channels = encoder->NumChannels();
1293 lies.rate = 0; 1294 lies.rate = 0;
1294 1295
1296 // Store a similarily made-up CodecInst for GetSendCodec to return.
henrika_webrtc 2017/06/09 13:50:04 Similar to what?
ossu 2017/06/09 13:54:00 On line 1281 I explain that I'm making a CodecInst
1297 CodecInst send_codec = lies;
1298 send_codec.plfreq = encoder->SampleRateHz();
1299 cached_send_codec_.emplace(send_codec);
1300
1295 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) { 1301 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1296 _rtpRtcpModule->DeRegisterSendPayload(payload_type); 1302 _rtpRtcpModule->DeRegisterSendPayload(payload_type);
1297 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) { 1303 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1298 WEBRTC_TRACE( 1304 WEBRTC_TRACE(
1299 kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1305 kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1300 "SetEncoder() failed to register codec to RTP/RTCP module"); 1306 "SetEncoder() failed to register codec to RTP/RTCP module");
1301 return false; 1307 return false;
1302 } 1308 }
1303 } 1309 }
1304 1310
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 _engineStatisticsPtr->SetLastError( 1342 _engineStatisticsPtr->SetLastError(
1337 VE_INVALID_OPERATION, kTraceWarning, 1343 VE_INVALID_OPERATION, kTraceWarning,
1338 "DeRegisterVoiceEngineObserver() observer already disabled"); 1344 "DeRegisterVoiceEngineObserver() observer already disabled");
1339 return 0; 1345 return 0;
1340 } 1346 }
1341 _voiceEngineObserverPtr = NULL; 1347 _voiceEngineObserverPtr = NULL;
1342 return 0; 1348 return 0;
1343 } 1349 }
1344 1350
1345 int32_t Channel::GetSendCodec(CodecInst& codec) { 1351 int32_t Channel::GetSendCodec(CodecInst& codec) {
1346 { 1352 if (cached_send_codec_) {
1353 codec = *cached_send_codec_;
1354 return 0;
1355 } else {
1347 const CodecInst* send_codec = codec_manager_.GetCodecInst(); 1356 const CodecInst* send_codec = codec_manager_.GetCodecInst();
1348 if (send_codec) { 1357 if (send_codec) {
1349 codec = *send_codec; 1358 codec = *send_codec;
1350 return 0; 1359 return 0;
1351 } 1360 }
1352 } 1361 }
1353 rtc::Optional<CodecInst> acm_send_codec = audio_coding_->SendCodec();
1354 if (acm_send_codec) {
1355 codec = *acm_send_codec;
1356 return 0;
1357 }
1358 return -1; 1362 return -1;
1359 } 1363 }
1360 1364
1361 int32_t Channel::GetRecCodec(CodecInst& codec) { 1365 int32_t Channel::GetRecCodec(CodecInst& codec) {
1362 return (audio_coding_->ReceiveCodec(&codec)); 1366 return (audio_coding_->ReceiveCodec(&codec));
1363 } 1367 }
1364 1368
1365 int32_t Channel::SetSendCodec(const CodecInst& codec) { 1369 int32_t Channel::SetSendCodec(const CodecInst& codec) {
1366 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1370 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1367 "Channel::SetSendCodec()"); 1371 "Channel::SetSendCodec()");
1368 1372
1369 if (!codec_manager_.RegisterEncoder(codec) || 1373 if (!codec_manager_.RegisterEncoder(codec) ||
1370 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) { 1374 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
1371 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1375 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1372 "SetSendCodec() failed to register codec to ACM"); 1376 "SetSendCodec() failed to register codec to ACM");
1373 return -1; 1377 return -1;
1374 } 1378 }
1375 1379
1376 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1380 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1377 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); 1381 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
1378 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1382 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1379 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1383 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1380 "SetSendCodec() failed to register codec to" 1384 "SetSendCodec() failed to register codec to"
1381 " RTP/RTCP module"); 1385 " RTP/RTCP module");
1382 return -1; 1386 return -1;
1383 } 1387 }
1384 } 1388 }
1385 1389
1390 cached_send_codec_.reset();
1391
1386 return 0; 1392 return 0;
1387 } 1393 }
1388 1394
1389 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { 1395 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) {
1390 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1396 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1391 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); 1397 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps);
1392 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1398 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1393 if (*encoder) { 1399 if (*encoder) {
1394 (*encoder)->OnReceivedUplinkBandwidth( 1400 (*encoder)->OnReceivedUplinkBandwidth(
1395 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms)); 1401 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms));
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 int64_t min_rtt = 0; 3135 int64_t min_rtt = 0;
3130 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3136 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3131 0) { 3137 0) {
3132 return 0; 3138 return 0;
3133 } 3139 }
3134 return rtt; 3140 return rtt;
3135 } 3141 }
3136 3142
3137 } // namespace voe 3143 } // namespace voe
3138 } // namespace webrtc 3144 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698