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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 // RTCP is enabled by default. | 980 // RTCP is enabled by default. |
981 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); | 981 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); |
982 // --- Register all permanent callbacks | 982 // --- Register all permanent callbacks |
983 if (audio_coding_->RegisterTransportCallback(this) == -1) { | 983 if (audio_coding_->RegisterTransportCallback(this) == -1) { |
984 _engineStatisticsPtr->SetLastError( | 984 _engineStatisticsPtr->SetLastError( |
985 VE_CANNOT_INIT_CHANNEL, kTraceError, | 985 VE_CANNOT_INIT_CHANNEL, kTraceError, |
986 "Channel::Init() callbacks not registered"); | 986 "Channel::Init() callbacks not registered"); |
987 return -1; | 987 return -1; |
988 } | 988 } |
989 | 989 |
990 // --- Register all supported codecs to the receiving side of the | 990 // Register a default set of send codecs. |
991 // RTP/RTCP module | 991 const int nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); |
| 992 for (int idx = 0; idx < nSupportedCodecs; idx++) { |
| 993 CodecInst codec; |
| 994 RTC_CHECK_EQ(0, audio_coding_->Codec(idx, &codec)); |
992 | 995 |
993 CodecInst codec; | 996 // Ensure that PCMU is used as default send codec. |
994 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); | 997 if (STR_CASE_CMP(codec.plname, "PCMU") == 0 && codec.channels == 1) { |
| 998 SetSendCodec(codec); |
| 999 } |
995 | 1000 |
| 1001 // Register default PT for 'telephone-event' |
| 1002 if (STR_CASE_CMP(codec.plname, "telephone-event") == 0) { |
| 1003 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1) { |
| 1004 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1005 "Channel::Init() failed to register outband " |
| 1006 "'telephone-event' (%d/%d) correctly", |
| 1007 codec.pltype, codec.plfreq); |
| 1008 } |
| 1009 } |
| 1010 |
| 1011 if (STR_CASE_CMP(codec.plname, "CN") == 0) { |
| 1012 if (!codec_manager_.RegisterEncoder(codec) || |
| 1013 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || |
| 1014 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { |
| 1015 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1016 "Channel::Init() failed to register CN (%d/%d) " |
| 1017 "correctly - 1", |
| 1018 codec.pltype, codec.plfreq); |
| 1019 } |
| 1020 } |
| 1021 } |
| 1022 |
| 1023 return 0; |
| 1024 } |
| 1025 |
| 1026 void Channel::RegisterLegacyReceiveCodecs() { |
| 1027 const int nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); |
996 for (int idx = 0; idx < nSupportedCodecs; idx++) { | 1028 for (int idx = 0; idx < nSupportedCodecs; idx++) { |
| 1029 CodecInst codec; |
| 1030 RTC_CHECK_EQ(0, audio_coding_->Codec(idx, &codec)); |
| 1031 |
997 // Open up the RTP/RTCP receiver for all supported codecs | 1032 // Open up the RTP/RTCP receiver for all supported codecs |
998 if ((audio_coding_->Codec(idx, &codec) == -1) || | 1033 if (rtp_receiver_->RegisterReceivePayload(codec) == -1) { |
999 (rtp_receiver_->RegisterReceivePayload(codec) == -1)) { | |
1000 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1034 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
1001 "Channel::Init() unable to register %s " | 1035 "Channel::Init() unable to register %s " |
1002 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", | 1036 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", |
1003 codec.plname, codec.pltype, codec.plfreq, codec.channels, | 1037 codec.plname, codec.pltype, codec.plfreq, codec.channels, |
1004 codec.rate); | 1038 codec.rate); |
1005 } else { | 1039 } else { |
1006 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1040 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1007 "Channel::Init() %s (%d/%d/%" PRIuS | 1041 "Channel::Init() %s (%d/%d/%" PRIuS |
1008 "/%d) has been " | 1042 "/%d) has been " |
1009 "added to the RTP/RTCP receiver", | 1043 "added to the RTP/RTCP receiver", |
1010 codec.plname, codec.pltype, codec.plfreq, codec.channels, | 1044 codec.plname, codec.pltype, codec.plfreq, codec.channels, |
1011 codec.rate); | 1045 codec.rate); |
1012 } | 1046 } |
1013 | 1047 |
1014 // Ensure that PCMU is used as default codec on the sending side | 1048 // Register default PT for 'telephone-event' |
1015 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) { | 1049 if (STR_CASE_CMP(codec.plname, "telephone-event") == 0) { |
1016 SetSendCodec(codec); | 1050 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, |
1017 } | |
1018 | |
1019 // Register default PT for outband 'telephone-event' | |
1020 if (!STR_CASE_CMP(codec.plname, "telephone-event")) { | |
1021 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 || | |
1022 !audio_coding_->RegisterReceiveCodec(codec.pltype, | |
1023 CodecInstToSdp(codec))) { | 1051 CodecInstToSdp(codec))) { |
1024 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1052 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
1025 "Channel::Init() failed to register outband " | 1053 "Channel::Init() failed to register inband " |
1026 "'telephone-event' (%d/%d) correctly", | 1054 "'telephone-event' (%d/%d) correctly", |
1027 codec.pltype, codec.plfreq); | 1055 codec.pltype, codec.plfreq); |
1028 } | 1056 } |
1029 } | 1057 } |
1030 | 1058 |
1031 if (!STR_CASE_CMP(codec.plname, "CN")) { | 1059 if (STR_CASE_CMP(codec.plname, "CN") == 0) { |
1032 if (!codec_manager_.RegisterEncoder(codec) || | 1060 if (!audio_coding_->RegisterReceiveCodec(codec.pltype, |
1033 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || | 1061 CodecInstToSdp(codec))) { |
1034 !audio_coding_->RegisterReceiveCodec(codec.pltype, | |
1035 CodecInstToSdp(codec)) || | |
1036 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { | |
1037 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1062 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
1038 "Channel::Init() failed to register CN (%d/%d) " | 1063 "Channel::Init() failed to register CN (%d/%d) " |
1039 "correctly - 1", | 1064 "correctly - 1", |
1040 codec.pltype, codec.plfreq); | 1065 codec.pltype, codec.plfreq); |
1041 } | 1066 } |
1042 } | 1067 } |
1043 } | 1068 } |
1044 | |
1045 return 0; | |
1046 } | 1069 } |
1047 | 1070 |
1048 void Channel::Terminate() { | 1071 void Channel::Terminate() { |
1049 RTC_DCHECK(construction_thread_.CalledOnValidThread()); | 1072 RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
1050 // Must be called on the same thread as Init(). | 1073 // Must be called on the same thread as Init(). |
1051 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 1074 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
1052 "Channel::Terminate"); | 1075 "Channel::Terminate"); |
1053 | 1076 |
1054 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); | 1077 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); |
1055 | 1078 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 int32_t Channel::GetVADStatus(bool& enabledVAD, | 1376 int32_t Channel::GetVADStatus(bool& enabledVAD, |
1354 ACMVADMode& mode, | 1377 ACMVADMode& mode, |
1355 bool& disabledDTX) { | 1378 bool& disabledDTX) { |
1356 const auto* params = codec_manager_.GetStackParams(); | 1379 const auto* params = codec_manager_.GetStackParams(); |
1357 enabledVAD = params->use_cng; | 1380 enabledVAD = params->use_cng; |
1358 mode = params->vad_mode; | 1381 mode = params->vad_mode; |
1359 disabledDTX = !params->use_cng; | 1382 disabledDTX = !params->use_cng; |
1360 return 0; | 1383 return 0; |
1361 } | 1384 } |
1362 | 1385 |
| 1386 void Channel::SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs) { |
| 1387 rtp_payload_registry_->SetAudioReceivePayloads(codecs); |
| 1388 audio_coding_->SetReceiveCodecs(codecs); |
| 1389 } |
| 1390 |
1363 int32_t Channel::SetRecPayloadType(const CodecInst& codec) { | 1391 int32_t Channel::SetRecPayloadType(const CodecInst& codec) { |
1364 return SetRecPayloadType(codec.pltype, CodecInstToSdp(codec)); | 1392 return SetRecPayloadType(codec.pltype, CodecInstToSdp(codec)); |
1365 } | 1393 } |
1366 | 1394 |
1367 int32_t Channel::SetRecPayloadType(int payload_type, | 1395 int32_t Channel::SetRecPayloadType(int payload_type, |
1368 const SdpAudioFormat& format) { | 1396 const SdpAudioFormat& format) { |
1369 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1397 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1370 "Channel::SetRecPayloadType()"); | 1398 "Channel::SetRecPayloadType()"); |
1371 | 1399 |
1372 if (channel_state_.Get().playing) { | 1400 if (channel_state_.Get().playing) { |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3029 int64_t min_rtt = 0; | 3057 int64_t min_rtt = 0; |
3030 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3058 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3031 0) { | 3059 0) { |
3032 return 0; | 3060 return 0; |
3033 } | 3061 } |
3034 return rtt; | 3062 return rtt; |
3035 } | 3063 } |
3036 | 3064 |
3037 } // namespace voe | 3065 } // namespace voe |
3038 } // namespace webrtc | 3066 } // namespace webrtc |
OLD | NEW |