Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1028 | 1028 |
| 1029 // --- Register all supported codecs to the receiving side of the | 1029 // --- Register all supported codecs to the receiving side of the |
| 1030 // RTP/RTCP module | 1030 // RTP/RTCP module |
| 1031 | 1031 |
| 1032 CodecInst codec; | 1032 CodecInst codec; |
| 1033 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); | 1033 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); |
| 1034 | 1034 |
| 1035 for (int idx = 0; idx < nSupportedCodecs; idx++) { | 1035 for (int idx = 0; idx < nSupportedCodecs; idx++) { |
| 1036 // Open up the RTP/RTCP receiver for all supported codecs | 1036 // Open up the RTP/RTCP receiver for all supported codecs |
| 1037 if ((audio_coding_->Codec(idx, &codec) == -1) || | 1037 if ((audio_coding_->Codec(idx, &codec) == -1) || |
| 1038 (rtp_receiver_->RegisterReceivePayload( | 1038 (rtp_receiver_->RegisterReceivePayload(codec) == -1)) { |
|
the sun
2016/11/24 14:27:07
nice to get rid of this duplication
| |
| 1039 codec.plname, codec.pltype, codec.plfreq, codec.channels, | |
| 1040 (codec.rate < 0) ? 0 : codec.rate) == -1)) { | |
| 1041 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1039 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1042 "Channel::Init() unable to register %s " | 1040 "Channel::Init() unable to register %s " |
| 1043 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", | 1041 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", |
| 1044 codec.plname, codec.pltype, codec.plfreq, codec.channels, | 1042 codec.plname, codec.pltype, codec.plfreq, codec.channels, |
| 1045 codec.rate); | 1043 codec.rate); |
| 1046 } else { | 1044 } else { |
| 1047 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1045 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1048 "Channel::Init() %s (%d/%d/%" PRIuS | 1046 "Channel::Init() %s (%d/%d/%" PRIuS |
| 1049 "/%d) has been " | 1047 "/%d) has been " |
| 1050 "added to the RTP/RTCP receiver", | 1048 "added to the RTP/RTCP receiver", |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1355 return -1; | 1353 return -1; |
| 1356 } | 1354 } |
| 1357 | 1355 |
| 1358 if (codec.pltype == -1) { | 1356 if (codec.pltype == -1) { |
| 1359 // De-register the selected codec (RTP/RTCP module and ACM) | 1357 // De-register the selected codec (RTP/RTCP module and ACM) |
| 1360 | 1358 |
| 1361 int8_t pltype(-1); | 1359 int8_t pltype(-1); |
| 1362 CodecInst rxCodec = codec; | 1360 CodecInst rxCodec = codec; |
| 1363 | 1361 |
| 1364 // Get payload type for the given codec | 1362 // Get payload type for the given codec |
| 1365 rtp_payload_registry_->ReceivePayloadType( | 1363 rtp_payload_registry_->ReceivePayloadType(rxCodec, &pltype); |
| 1366 rxCodec.plname, rxCodec.plfreq, rxCodec.channels, | |
| 1367 (rxCodec.rate < 0) ? 0 : rxCodec.rate, &pltype); | |
| 1368 rxCodec.pltype = pltype; | 1364 rxCodec.pltype = pltype; |
| 1369 | 1365 |
| 1370 if (rtp_receiver_->DeRegisterReceivePayload(pltype) != 0) { | 1366 if (rtp_receiver_->DeRegisterReceivePayload(pltype) != 0) { |
| 1371 _engineStatisticsPtr->SetLastError( | 1367 _engineStatisticsPtr->SetLastError( |
| 1372 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 1368 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
| 1373 "SetRecPayloadType() RTP/RTCP-module deregistration " | 1369 "SetRecPayloadType() RTP/RTCP-module deregistration " |
| 1374 "failed"); | 1370 "failed"); |
| 1375 return -1; | 1371 return -1; |
| 1376 } | 1372 } |
| 1377 if (audio_coding_->UnregisterReceiveCodec(rxCodec.pltype) != 0) { | 1373 if (audio_coding_->UnregisterReceiveCodec(rxCodec.pltype) != 0) { |
| 1378 _engineStatisticsPtr->SetLastError( | 1374 _engineStatisticsPtr->SetLastError( |
| 1379 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, | 1375 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, |
| 1380 "SetRecPayloadType() ACM deregistration failed - 1"); | 1376 "SetRecPayloadType() ACM deregistration failed - 1"); |
| 1381 return -1; | 1377 return -1; |
| 1382 } | 1378 } |
| 1383 return 0; | 1379 return 0; |
| 1384 } | 1380 } |
| 1385 | 1381 |
| 1386 if (rtp_receiver_->RegisterReceivePayload( | 1382 if (rtp_receiver_->RegisterReceivePayload(codec) != 0) { |
| 1387 codec.plname, codec.pltype, codec.plfreq, codec.channels, | |
| 1388 (codec.rate < 0) ? 0 : codec.rate) != 0) { | |
| 1389 // First attempt to register failed => de-register and try again | 1383 // First attempt to register failed => de-register and try again |
| 1390 // TODO(kwiberg): Retrying is probably not necessary, since | 1384 // TODO(kwiberg): Retrying is probably not necessary, since |
| 1391 // AcmReceiver::AddCodec also retries. | 1385 // AcmReceiver::AddCodec also retries. |
| 1392 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); | 1386 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); |
| 1393 if (rtp_receiver_->RegisterReceivePayload( | 1387 if (rtp_receiver_->RegisterReceivePayload(codec) != 0) { |
| 1394 codec.plname, codec.pltype, codec.plfreq, codec.channels, | |
| 1395 (codec.rate < 0) ? 0 : codec.rate) != 0) { | |
| 1396 _engineStatisticsPtr->SetLastError( | 1388 _engineStatisticsPtr->SetLastError( |
| 1397 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 1389 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
| 1398 "SetRecPayloadType() RTP/RTCP-module registration failed"); | 1390 "SetRecPayloadType() RTP/RTCP-module registration failed"); |
| 1399 return -1; | 1391 return -1; |
| 1400 } | 1392 } |
| 1401 } | 1393 } |
| 1402 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, | 1394 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, |
| 1403 CodecInstToSdp(codec))) { | 1395 CodecInstToSdp(codec))) { |
| 1404 audio_coding_->UnregisterReceiveCodec(codec.pltype); | 1396 audio_coding_->UnregisterReceiveCodec(codec.pltype); |
| 1405 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, | 1397 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, |
| 1406 CodecInstToSdp(codec))) { | 1398 CodecInstToSdp(codec))) { |
| 1407 _engineStatisticsPtr->SetLastError( | 1399 _engineStatisticsPtr->SetLastError( |
| 1408 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, | 1400 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, |
| 1409 "SetRecPayloadType() ACM registration failed - 1"); | 1401 "SetRecPayloadType() ACM registration failed - 1"); |
| 1410 return -1; | 1402 return -1; |
| 1411 } | 1403 } |
| 1412 } | 1404 } |
| 1413 return 0; | 1405 return 0; |
| 1414 } | 1406 } |
| 1415 | 1407 |
| 1416 int32_t Channel::GetRecPayloadType(CodecInst& codec) { | 1408 int32_t Channel::GetRecPayloadType(CodecInst& codec) { |
| 1417 int8_t payloadType(-1); | 1409 int8_t payloadType(-1); |
| 1418 if (rtp_payload_registry_->ReceivePayloadType( | 1410 if (rtp_payload_registry_->ReceivePayloadType(codec, &payloadType) != 0) { |
| 1419 codec.plname, codec.plfreq, codec.channels, | |
| 1420 (codec.rate < 0) ? 0 : codec.rate, &payloadType) != 0) { | |
| 1421 _engineStatisticsPtr->SetLastError( | 1411 _engineStatisticsPtr->SetLastError( |
| 1422 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, | 1412 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, |
| 1423 "GetRecPayloadType() failed to retrieve RX payload type"); | 1413 "GetRecPayloadType() failed to retrieve RX payload type"); |
| 1424 return -1; | 1414 return -1; |
| 1425 } | 1415 } |
| 1426 codec.pltype = payloadType; | 1416 codec.pltype = payloadType; |
| 1427 return 0; | 1417 return 0; |
| 1428 } | 1418 } |
| 1429 | 1419 |
| 1430 int32_t Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) { | 1420 int32_t Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) { |
| (...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3145 void Channel::RegisterReceiveCodecsToRTPModule() { | 3135 void Channel::RegisterReceiveCodecsToRTPModule() { |
| 3146 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 3136 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 3147 "Channel::RegisterReceiveCodecsToRTPModule()"); | 3137 "Channel::RegisterReceiveCodecsToRTPModule()"); |
| 3148 | 3138 |
| 3149 CodecInst codec; | 3139 CodecInst codec; |
| 3150 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); | 3140 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); |
| 3151 | 3141 |
| 3152 for (int idx = 0; idx < nSupportedCodecs; idx++) { | 3142 for (int idx = 0; idx < nSupportedCodecs; idx++) { |
| 3153 // Open up the RTP/RTCP receiver for all supported codecs | 3143 // Open up the RTP/RTCP receiver for all supported codecs |
| 3154 if ((audio_coding_->Codec(idx, &codec) == -1) || | 3144 if ((audio_coding_->Codec(idx, &codec) == -1) || |
| 3155 (rtp_receiver_->RegisterReceivePayload( | 3145 (rtp_receiver_->RegisterReceivePayload(codec) == -1)) { |
| 3156 codec.plname, codec.pltype, codec.plfreq, codec.channels, | |
| 3157 (codec.rate < 0) ? 0 : codec.rate) == -1)) { | |
| 3158 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 3146 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 3159 "Channel::RegisterReceiveCodecsToRTPModule() unable" | 3147 "Channel::RegisterReceiveCodecsToRTPModule() unable" |
| 3160 " to register %s (%d/%d/%" PRIuS | 3148 " to register %s (%d/%d/%" PRIuS |
| 3161 "/%d) to RTP/RTCP " | 3149 "/%d) to RTP/RTCP " |
| 3162 "receiver", | 3150 "receiver", |
| 3163 codec.plname, codec.pltype, codec.plfreq, codec.channels, | 3151 codec.plname, codec.pltype, codec.plfreq, codec.channels, |
| 3164 codec.rate); | 3152 codec.rate); |
| 3165 } else { | 3153 } else { |
| 3166 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 3154 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 3167 "Channel::RegisterReceiveCodecsToRTPModule() %s " | 3155 "Channel::RegisterReceiveCodecsToRTPModule() %s " |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3240 int64_t min_rtt = 0; | 3228 int64_t min_rtt = 0; |
| 3241 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3229 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3242 0) { | 3230 0) { |
| 3243 return 0; | 3231 return 0; |
| 3244 } | 3232 } |
| 3245 return rtt; | 3233 return rtt; |
| 3246 } | 3234 } |
| 3247 | 3235 |
| 3248 } // namespace voe | 3236 } // namespace voe |
| 3249 } // namespace webrtc | 3237 } // namespace webrtc |
| OLD | NEW |