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

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

Issue 1677013002: Switch to using new ACM methods for encoder management (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@acm-13
Patch Set: Solar review comments Created 4 years, 8 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 * 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 25 matching lines...) Expand all
36 #include "webrtc/voice_engine/include/voe_external_media.h" 36 #include "webrtc/voice_engine/include/voe_external_media.h"
37 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 37 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
38 #include "webrtc/voice_engine/output_mixer.h" 38 #include "webrtc/voice_engine/output_mixer.h"
39 #include "webrtc/voice_engine/statistics.h" 39 #include "webrtc/voice_engine/statistics.h"
40 #include "webrtc/voice_engine/transmit_mixer.h" 40 #include "webrtc/voice_engine/transmit_mixer.h"
41 #include "webrtc/voice_engine/utility.h" 41 #include "webrtc/voice_engine/utility.h"
42 42
43 namespace webrtc { 43 namespace webrtc {
44 namespace voe { 44 namespace voe {
45 45
46 namespace {
47
48 bool RegisterReceiveCodec(std::unique_ptr<AudioCodingModule>* acm,
49 acm2::RentACodec* rac,
50 const CodecInst& ci) {
51 const int result =
52 (*acm)->RegisterReceiveCodec(ci, [&] { return rac->RentIsacDecoder(); });
53 return result == 0;
54 }
55
56 } // namespace
57
46 const int kTelephoneEventAttenuationdB = 10; 58 const int kTelephoneEventAttenuationdB = 10;
47 59
48 class TransportFeedbackProxy : public TransportFeedbackObserver { 60 class TransportFeedbackProxy : public TransportFeedbackObserver {
49 public: 61 public:
50 TransportFeedbackProxy() : feedback_observer_(nullptr) { 62 TransportFeedbackProxy() : feedback_observer_(nullptr) {
51 pacer_thread_.DetachFromThread(); 63 pacer_thread_.DetachFromThread();
52 network_thread_.DetachFromThread(); 64 network_thread_.DetachFromThread();
53 } 65 }
54 66
55 void SetTransportFeedbackObserver( 67 void SetTransportFeedbackObserver(
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 receiveCodec.pltype = payloadType; 396 receiveCodec.pltype = payloadType;
385 receiveCodec.plfreq = frequency; 397 receiveCodec.plfreq = frequency;
386 receiveCodec.channels = channels; 398 receiveCodec.channels = channels;
387 receiveCodec.rate = rate; 399 receiveCodec.rate = rate;
388 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); 400 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
389 401
390 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels); 402 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels);
391 receiveCodec.pacsize = dummyCodec.pacsize; 403 receiveCodec.pacsize = dummyCodec.pacsize;
392 404
393 // Register the new codec to the ACM 405 // Register the new codec to the ACM
394 if (audio_coding_->RegisterReceiveCodec(receiveCodec) == -1) { 406 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, receiveCodec)) {
395 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 407 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
396 "Channel::OnInitializeDecoder() invalid codec (" 408 "Channel::OnInitializeDecoder() invalid codec ("
397 "pt=%d, name=%s) received - 1", 409 "pt=%d, name=%s) received - 1",
398 payloadType, payloadName); 410 payloadType, payloadName);
399 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR); 411 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR);
400 return -1; 412 return -1;
401 } 413 }
402 414
403 return 0; 415 return 0;
404 } 416 }
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 codec.rate); 971 codec.rate);
960 } 972 }
961 973
962 // Ensure that PCMU is used as default codec on the sending side 974 // Ensure that PCMU is used as default codec on the sending side
963 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) { 975 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) {
964 SetSendCodec(codec); 976 SetSendCodec(codec);
965 } 977 }
966 978
967 // Register default PT for outband 'telephone-event' 979 // Register default PT for outband 'telephone-event'
968 if (!STR_CASE_CMP(codec.plname, "telephone-event")) { 980 if (!STR_CASE_CMP(codec.plname, "telephone-event")) {
969 if ((_rtpRtcpModule->RegisterSendPayload(codec) == -1) || 981 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 ||
970 (audio_coding_->RegisterReceiveCodec(codec) == -1)) { 982 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
971 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 983 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
972 "Channel::Init() failed to register outband " 984 "Channel::Init() failed to register outband "
973 "'telephone-event' (%d/%d) correctly", 985 "'telephone-event' (%d/%d) correctly",
974 codec.pltype, codec.plfreq); 986 codec.pltype, codec.plfreq);
975 } 987 }
976 } 988 }
977 989
978 if (!STR_CASE_CMP(codec.plname, "CN")) { 990 if (!STR_CASE_CMP(codec.plname, "CN")) {
979 if ((audio_coding_->RegisterSendCodec(codec) == -1) || 991 if (!codec_manager_.RegisterEncoder(codec) ||
980 (audio_coding_->RegisterReceiveCodec(codec) == -1) || 992 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) ||
981 (_rtpRtcpModule->RegisterSendPayload(codec) == -1)) { 993 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) ||
994 _rtpRtcpModule->RegisterSendPayload(codec) == -1) {
982 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 995 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
983 "Channel::Init() failed to register CN (%d/%d) " 996 "Channel::Init() failed to register CN (%d/%d) "
984 "correctly - 1", 997 "correctly - 1",
985 codec.pltype, codec.plfreq); 998 codec.pltype, codec.plfreq);
986 } 999 }
987 } 1000 }
988 #ifdef WEBRTC_CODEC_RED 1001 #ifdef WEBRTC_CODEC_RED
989 // Register RED to the receiving side of the ACM. 1002 // Register RED to the receiving side of the ACM.
990 // We will not receive an OnInitializeDecoder() callback for RED. 1003 // We will not receive an OnInitializeDecoder() callback for RED.
991 if (!STR_CASE_CMP(codec.plname, "RED")) { 1004 if (!STR_CASE_CMP(codec.plname, "RED")) {
992 if (audio_coding_->RegisterReceiveCodec(codec) == -1) { 1005 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
993 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1006 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
994 "Channel::Init() failed to register RED (%d/%d) " 1007 "Channel::Init() failed to register RED (%d/%d) "
995 "correctly", 1008 "correctly",
996 codec.pltype, codec.plfreq); 1009 codec.pltype, codec.plfreq);
997 } 1010 }
998 } 1011 }
999 #endif 1012 #endif
1000 } 1013 }
1001 1014
1002 if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) { 1015 if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 _engineStatisticsPtr->SetLastError( 1201 _engineStatisticsPtr->SetLastError(
1189 VE_INVALID_OPERATION, kTraceWarning, 1202 VE_INVALID_OPERATION, kTraceWarning,
1190 "DeRegisterVoiceEngineObserver() observer already disabled"); 1203 "DeRegisterVoiceEngineObserver() observer already disabled");
1191 return 0; 1204 return 0;
1192 } 1205 }
1193 _voiceEngineObserverPtr = NULL; 1206 _voiceEngineObserverPtr = NULL;
1194 return 0; 1207 return 0;
1195 } 1208 }
1196 1209
1197 int32_t Channel::GetSendCodec(CodecInst& codec) { 1210 int32_t Channel::GetSendCodec(CodecInst& codec) {
1198 auto send_codec = audio_coding_->SendCodec(); 1211 auto send_codec = codec_manager_.GetCodecInst();
1199 if (send_codec) { 1212 if (send_codec) {
1200 codec = *send_codec; 1213 codec = *send_codec;
1201 return 0; 1214 return 0;
1202 } 1215 }
1203 return -1; 1216 return -1;
1204 } 1217 }
1205 1218
1206 int32_t Channel::GetRecCodec(CodecInst& codec) { 1219 int32_t Channel::GetRecCodec(CodecInst& codec) {
1207 return (audio_coding_->ReceiveCodec(&codec)); 1220 return (audio_coding_->ReceiveCodec(&codec));
1208 } 1221 }
1209 1222
1210 int32_t Channel::SetSendCodec(const CodecInst& codec) { 1223 int32_t Channel::SetSendCodec(const CodecInst& codec) {
1211 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1224 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1212 "Channel::SetSendCodec()"); 1225 "Channel::SetSendCodec()");
1213 1226
1214 if (audio_coding_->RegisterSendCodec(codec) != 0) { 1227 if (!codec_manager_.RegisterEncoder(codec) ||
1228 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
1215 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1229 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1216 "SetSendCodec() failed to register codec to ACM"); 1230 "SetSendCodec() failed to register codec to ACM");
1217 return -1; 1231 return -1;
1218 } 1232 }
1219 1233
1220 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1234 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1221 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); 1235 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
1222 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1236 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1223 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1237 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1224 "SetSendCodec() failed to register codec to" 1238 "SetSendCodec() failed to register codec to"
(...skipping 26 matching lines...) Expand all
1251 0) { 1265 0) {
1252 assert(false); // This should not happen. 1266 assert(false); // This should not happen.
1253 } 1267 }
1254 } 1268 }
1255 1269
1256 int32_t Channel::SetVADStatus(bool enableVAD, 1270 int32_t Channel::SetVADStatus(bool enableVAD,
1257 ACMVADMode mode, 1271 ACMVADMode mode,
1258 bool disableDTX) { 1272 bool disableDTX) {
1259 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1273 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1260 "Channel::SetVADStatus(mode=%d)", mode); 1274 "Channel::SetVADStatus(mode=%d)", mode);
1261 assert(!(disableDTX && enableVAD)); // disableDTX mode is deprecated. 1275 RTC_DCHECK(!(disableDTX && enableVAD)); // disableDTX mode is deprecated.
1262 // To disable VAD, DTX must be disabled too 1276 if (!codec_manager_.SetVAD(enableVAD, mode) ||
1263 disableDTX = ((enableVAD == false) ? true : disableDTX); 1277 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
1264 if (audio_coding_->SetVAD(!disableDTX, enableVAD, mode) != 0) {
1265 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR, 1278 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR,
1266 kTraceError, 1279 kTraceError,
1267 "SetVADStatus() failed to set VAD"); 1280 "SetVADStatus() failed to set VAD");
1268 return -1; 1281 return -1;
1269 } 1282 }
1270 return 0; 1283 return 0;
1271 } 1284 }
1272 1285
1273 int32_t Channel::GetVADStatus(bool& enabledVAD, 1286 int32_t Channel::GetVADStatus(bool& enabledVAD,
1274 ACMVADMode& mode, 1287 ACMVADMode& mode,
1275 bool& disabledDTX) { 1288 bool& disabledDTX) {
1276 if (audio_coding_->VAD(&disabledDTX, &enabledVAD, &mode) != 0) { 1289 const auto* params = codec_manager_.GetStackParams();
1277 _engineStatisticsPtr->SetLastError( 1290 enabledVAD = params->use_cng;
1278 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1291 mode = params->vad_mode;
1279 "GetVADStatus() failed to get VAD status"); 1292 disabledDTX = !params->use_cng;
1280 return -1;
1281 }
1282 disabledDTX = !disabledDTX;
1283 return 0; 1293 return 0;
1284 } 1294 }
1285 1295
1286 int32_t Channel::SetRecPayloadType(const CodecInst& codec) { 1296 int32_t Channel::SetRecPayloadType(const CodecInst& codec) {
1287 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1297 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1288 "Channel::SetRecPayloadType()"); 1298 "Channel::SetRecPayloadType()");
1289 1299
1290 if (channel_state_.Get().playing) { 1300 if (channel_state_.Get().playing) {
1291 _engineStatisticsPtr->SetLastError( 1301 _engineStatisticsPtr->SetLastError(
1292 VE_ALREADY_PLAYING, kTraceError, 1302 VE_ALREADY_PLAYING, kTraceError,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 "SetRecPayloadType() ACM deregistration failed - 1"); 1335 "SetRecPayloadType() ACM deregistration failed - 1");
1326 return -1; 1336 return -1;
1327 } 1337 }
1328 return 0; 1338 return 0;
1329 } 1339 }
1330 1340
1331 if (rtp_receiver_->RegisterReceivePayload( 1341 if (rtp_receiver_->RegisterReceivePayload(
1332 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1342 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1333 (codec.rate < 0) ? 0 : codec.rate) != 0) { 1343 (codec.rate < 0) ? 0 : codec.rate) != 0) {
1334 // First attempt to register failed => de-register and try again 1344 // First attempt to register failed => de-register and try again
1345 // TODO(kwiberg): Retrying is probably not necessary, since
1346 // AcmReceiver::AddCodec also retries.
1335 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); 1347 rtp_receiver_->DeRegisterReceivePayload(codec.pltype);
1336 if (rtp_receiver_->RegisterReceivePayload( 1348 if (rtp_receiver_->RegisterReceivePayload(
1337 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1349 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1338 (codec.rate < 0) ? 0 : codec.rate) != 0) { 1350 (codec.rate < 0) ? 0 : codec.rate) != 0) {
1339 _engineStatisticsPtr->SetLastError( 1351 _engineStatisticsPtr->SetLastError(
1340 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 1352 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
1341 "SetRecPayloadType() RTP/RTCP-module registration failed"); 1353 "SetRecPayloadType() RTP/RTCP-module registration failed");
1342 return -1; 1354 return -1;
1343 } 1355 }
1344 } 1356 }
1345 if (audio_coding_->RegisterReceiveCodec(codec) != 0) { 1357 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
1346 audio_coding_->UnregisterReceiveCodec(codec.pltype); 1358 audio_coding_->UnregisterReceiveCodec(codec.pltype);
1347 if (audio_coding_->RegisterReceiveCodec(codec) != 0) { 1359 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
1348 _engineStatisticsPtr->SetLastError( 1360 _engineStatisticsPtr->SetLastError(
1349 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1361 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1350 "SetRecPayloadType() ACM registration failed - 1"); 1362 "SetRecPayloadType() ACM registration failed - 1");
1351 return -1; 1363 return -1;
1352 } 1364 }
1353 } 1365 }
1354 return 0; 1366 return 0;
1355 } 1367 }
1356 1368
1357 int32_t Channel::GetRecPayloadType(CodecInst& codec) { 1369 int32_t Channel::GetRecPayloadType(CodecInst& codec) {
(...skipping 26 matching lines...) Expand all
1384 _engineStatisticsPtr->SetLastError( 1396 _engineStatisticsPtr->SetLastError(
1385 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1397 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1386 "SetSendCNPayloadType() failed to retrieve default CN codec " 1398 "SetSendCNPayloadType() failed to retrieve default CN codec "
1387 "settings"); 1399 "settings");
1388 return -1; 1400 return -1;
1389 } 1401 }
1390 1402
1391 // Modify the payload type (must be set to dynamic range) 1403 // Modify the payload type (must be set to dynamic range)
1392 codec.pltype = type; 1404 codec.pltype = type;
1393 1405
1394 if (audio_coding_->RegisterSendCodec(codec) != 0) { 1406 if (!codec_manager_.RegisterEncoder(codec) ||
1407 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
1395 _engineStatisticsPtr->SetLastError( 1408 _engineStatisticsPtr->SetLastError(
1396 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1409 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1397 "SetSendCNPayloadType() failed to register CN to ACM"); 1410 "SetSendCNPayloadType() failed to register CN to ACM");
1398 return -1; 1411 return -1;
1399 } 1412 }
1400 1413
1401 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1414 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1402 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); 1415 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
1403 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { 1416 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
1404 _engineStatisticsPtr->SetLastError( 1417 _engineStatisticsPtr->SetLastError(
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 } 2860 }
2848 2861
2849 if (SetRedPayloadType(redPayloadtype) < 0) { 2862 if (SetRedPayloadType(redPayloadtype) < 0) {
2850 _engineStatisticsPtr->SetLastError( 2863 _engineStatisticsPtr->SetLastError(
2851 VE_CODEC_ERROR, kTraceError, 2864 VE_CODEC_ERROR, kTraceError,
2852 "SetSecondarySendCodec() Failed to register RED ACM"); 2865 "SetSecondarySendCodec() Failed to register RED ACM");
2853 return -1; 2866 return -1;
2854 } 2867 }
2855 } 2868 }
2856 2869
2857 if (audio_coding_->SetREDStatus(enable) != 0) { 2870 if (!codec_manager_.SetCopyRed(enable) ||
the sun 2016/04/06 11:58:25 Nit: should this be RED, not Red?
kwiberg-webrtc 2016/04/06 12:15:29 Style guide says: "Prefer to capitalize acronyms a
the sun 2016/04/06 13:05:59 Thanks for looking that up for me! :) Ok, then it
kwiberg-webrtc 2016/04/06 14:10:40 It just says you should prefer it, not that you mu
2871 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
2858 _engineStatisticsPtr->SetLastError( 2872 _engineStatisticsPtr->SetLastError(
2859 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 2873 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
2860 "SetREDStatus() failed to set RED state in the ACM"); 2874 "SetREDStatus() failed to set RED state in the ACM");
2861 return -1; 2875 return -1;
2862 } 2876 }
2863 return 0; 2877 return 0;
2864 } 2878 }
2865 2879
2866 int Channel::GetREDStatus(bool& enabled, int& redPayloadtype) { 2880 int Channel::GetREDStatus(bool& enabled, int& redPayloadtype) {
2867 enabled = audio_coding_->REDStatus(); 2881 enabled = codec_manager_.GetStackParams()->use_red;
2868 if (enabled) { 2882 if (enabled) {
2869 int8_t payloadType = 0; 2883 int8_t payloadType = 0;
2870 if (_rtpRtcpModule->SendREDPayloadType(&payloadType) != 0) { 2884 if (_rtpRtcpModule->SendREDPayloadType(&payloadType) != 0) {
2871 _engineStatisticsPtr->SetLastError( 2885 _engineStatisticsPtr->SetLastError(
2872 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 2886 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
2873 "GetREDStatus() failed to retrieve RED PT from RTP/RTCP " 2887 "GetREDStatus() failed to retrieve RED PT from RTP/RTCP "
2874 "module"); 2888 "module");
2875 return -1; 2889 return -1;
2876 } 2890 }
2877 redPayloadtype = payloadType; 2891 redPayloadtype = payloadType;
2878 return 0; 2892 return 0;
2879 } 2893 }
2880 return 0; 2894 return 0;
2881 } 2895 }
2882 2896
2883 int Channel::SetCodecFECStatus(bool enable) { 2897 int Channel::SetCodecFECStatus(bool enable) {
2884 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2898 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2885 "Channel::SetCodecFECStatus()"); 2899 "Channel::SetCodecFECStatus()");
2886 2900
2887 if (audio_coding_->SetCodecFEC(enable) != 0) { 2901 if (!codec_manager_.SetCodecFEC(enable) ||
2902 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
2888 _engineStatisticsPtr->SetLastError( 2903 _engineStatisticsPtr->SetLastError(
2889 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 2904 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
2890 "SetCodecFECStatus() failed to set FEC state"); 2905 "SetCodecFECStatus() failed to set FEC state");
2891 return -1; 2906 return -1;
2892 } 2907 }
2893 return 0; 2908 return 0;
2894 } 2909 }
2895 2910
2896 bool Channel::GetCodecFECStatus() { 2911 bool Channel::GetCodecFECStatus() {
2897 bool enabled = audio_coding_->CodecFEC(); 2912 return codec_manager_.GetStackParams()->use_codec_fec;
2898 return enabled;
2899 } 2913 }
2900 2914
2901 void Channel::SetNACKStatus(bool enable, int maxNumberOfPackets) { 2915 void Channel::SetNACKStatus(bool enable, int maxNumberOfPackets) {
2902 // None of these functions can fail. 2916 // None of these functions can fail.
2903 // If pacing is enabled we always store packets. 2917 // If pacing is enabled we always store packets.
2904 if (!pacing_enabled_) 2918 if (!pacing_enabled_)
2905 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); 2919 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets);
2906 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); 2920 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets);
2907 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); 2921 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff);
2908 if (enable) 2922 if (enable)
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
3429 } 3443 }
3430 3444
3431 if (!found_red) { 3445 if (!found_red) {
3432 _engineStatisticsPtr->SetLastError( 3446 _engineStatisticsPtr->SetLastError(
3433 VE_CODEC_ERROR, kTraceError, 3447 VE_CODEC_ERROR, kTraceError,
3434 "SetRedPayloadType() RED is not supported"); 3448 "SetRedPayloadType() RED is not supported");
3435 return -1; 3449 return -1;
3436 } 3450 }
3437 3451
3438 codec.pltype = red_payload_type; 3452 codec.pltype = red_payload_type;
3439 if (audio_coding_->RegisterSendCodec(codec) < 0) { 3453 if (!codec_manager_.RegisterEncoder(codec) ||
3454 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
3440 _engineStatisticsPtr->SetLastError( 3455 _engineStatisticsPtr->SetLastError(
3441 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 3456 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
3442 "SetRedPayloadType() RED registration in ACM module failed"); 3457 "SetRedPayloadType() RED registration in ACM module failed");
3443 return -1; 3458 return -1;
3444 } 3459 }
3445 3460
3446 if (_rtpRtcpModule->SetSendREDPayloadType(red_payload_type) != 0) { 3461 if (_rtpRtcpModule->SetSendREDPayloadType(red_payload_type) != 0) {
3447 _engineStatisticsPtr->SetLastError( 3462 _engineStatisticsPtr->SetLastError(
3448 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 3463 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
3449 "SetRedPayloadType() RED registration in RTP/RTCP module failed"); 3464 "SetRedPayloadType() RED registration in RTP/RTCP module failed");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 int64_t min_rtt = 0; 3543 int64_t min_rtt = 0;
3529 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3544 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3530 0) { 3545 0) {
3531 return 0; 3546 return 0;
3532 } 3547 }
3533 return rtt; 3548 return rtt;
3534 } 3549 }
3535 3550
3536 } // namespace voe 3551 } // namespace voe
3537 } // namespace webrtc 3552 } // namespace webrtc
OLDNEW
« webrtc/modules/audio_coding/acm2/codec_manager.h ('K') | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698