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

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

Issue 2516993002: Pass SdpAudioFormat through Channel, without converting to CodecInst (Closed)
Patch Set: add TODO Created 3 years, 11 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') | webrtc/voice_engine/channel_proxy.h » ('j') | 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 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 ACMVADMode& mode, 1365 ACMVADMode& mode,
1366 bool& disabledDTX) { 1366 bool& disabledDTX) {
1367 const auto* params = codec_manager_.GetStackParams(); 1367 const auto* params = codec_manager_.GetStackParams();
1368 enabledVAD = params->use_cng; 1368 enabledVAD = params->use_cng;
1369 mode = params->vad_mode; 1369 mode = params->vad_mode;
1370 disabledDTX = !params->use_cng; 1370 disabledDTX = !params->use_cng;
1371 return 0; 1371 return 0;
1372 } 1372 }
1373 1373
1374 int32_t Channel::SetRecPayloadType(const CodecInst& codec) { 1374 int32_t Channel::SetRecPayloadType(const CodecInst& codec) {
1375 return SetRecPayloadType(codec.pltype, CodecInstToSdp(codec));
1376 }
1377
1378 int32_t Channel::SetRecPayloadType(int payload_type,
1379 const SdpAudioFormat& format) {
1375 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1380 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1376 "Channel::SetRecPayloadType()"); 1381 "Channel::SetRecPayloadType()");
1377 1382
1378 if (channel_state_.Get().playing) { 1383 if (channel_state_.Get().playing) {
1379 _engineStatisticsPtr->SetLastError( 1384 _engineStatisticsPtr->SetLastError(
1380 VE_ALREADY_PLAYING, kTraceError, 1385 VE_ALREADY_PLAYING, kTraceError,
1381 "SetRecPayloadType() unable to set PT while playing"); 1386 "SetRecPayloadType() unable to set PT while playing");
1382 return -1; 1387 return -1;
1383 } 1388 }
1384 1389
1385 if (codec.pltype == -1) { 1390 const CodecInst codec = [&] {
1391 CodecInst c = SdpToCodecInst(payload_type, format);
1392
1393 // Bug 6986: Emulate an old bug that caused us to always choose to decode
1394 // Opus in stereo. To be able to remove this, we first need to fix the
1395 // other half of bug 6986, which is about losing the Opus "stereo"
1396 // parameter.
1397 // TODO(kwiberg): Remove this special case, a.k.a. fix bug 6986.
1398 if (STR_CASE_CMP(codec.plname, "opus") == 0) {
1399 c.channels = 2;
1400 }
1401
1402 return c;
1403 }();
1404
1405 if (payload_type == -1) {
1386 // De-register the selected codec (RTP/RTCP module and ACM) 1406 // De-register the selected codec (RTP/RTCP module and ACM)
1387 1407
1388 int8_t pltype(-1); 1408 int8_t pltype(-1);
1389 CodecInst rxCodec = codec; 1409 CodecInst rxCodec = codec;
1390 1410
1391 // Get payload type for the given codec 1411 // Get payload type for the given codec
1392 rtp_payload_registry_->ReceivePayloadType(rxCodec, &pltype); 1412 rtp_payload_registry_->ReceivePayloadType(rxCodec, &pltype);
1393 rxCodec.pltype = pltype; 1413 rxCodec.pltype = pltype;
1394 1414
1395 if (rtp_receiver_->DeRegisterReceivePayload(pltype) != 0) { 1415 if (rtp_receiver_->DeRegisterReceivePayload(pltype) != 0) {
(...skipping 17 matching lines...) Expand all
1413 // TODO(kwiberg): Retrying is probably not necessary, since 1433 // TODO(kwiberg): Retrying is probably not necessary, since
1414 // AcmReceiver::AddCodec also retries. 1434 // AcmReceiver::AddCodec also retries.
1415 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); 1435 rtp_receiver_->DeRegisterReceivePayload(codec.pltype);
1416 if (rtp_receiver_->RegisterReceivePayload(codec) != 0) { 1436 if (rtp_receiver_->RegisterReceivePayload(codec) != 0) {
1417 _engineStatisticsPtr->SetLastError( 1437 _engineStatisticsPtr->SetLastError(
1418 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 1438 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
1419 "SetRecPayloadType() RTP/RTCP-module registration failed"); 1439 "SetRecPayloadType() RTP/RTCP-module registration failed");
1420 return -1; 1440 return -1;
1421 } 1441 }
1422 } 1442 }
1423 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, 1443 if (!audio_coding_->RegisterReceiveCodec(payload_type, format)) {
1424 CodecInstToSdp(codec))) { 1444 audio_coding_->UnregisterReceiveCodec(payload_type);
1425 audio_coding_->UnregisterReceiveCodec(codec.pltype); 1445 if (!audio_coding_->RegisterReceiveCodec(payload_type, format)) {
1426 if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
1427 CodecInstToSdp(codec))) {
1428 _engineStatisticsPtr->SetLastError( 1446 _engineStatisticsPtr->SetLastError(
1429 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1447 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1430 "SetRecPayloadType() ACM registration failed - 1"); 1448 "SetRecPayloadType() ACM registration failed - 1");
1431 return -1; 1449 return -1;
1432 } 1450 }
1433 } 1451 }
1434 return 0; 1452 return 0;
1435 } 1453 }
1436 1454
1437 int32_t Channel::GetRecPayloadType(CodecInst& codec) { 1455 int32_t Channel::GetRecPayloadType(CodecInst& codec) {
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 int64_t min_rtt = 0; 3295 int64_t min_rtt = 0;
3278 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3296 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3279 0) { 3297 0) {
3280 return 0; 3298 return 0;
3281 } 3299 }
3282 return rtt; 3300 return rtt;
3283 } 3301 }
3284 3302
3285 } // namespace voe 3303 } // namespace voe
3286 } // namespace webrtc 3304 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698