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

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

Issue 2388153004: Stop using old AudioCodingModule::RegisterReceiveCodec overloads (Closed)
Patch Set: Created 4 years, 2 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 30 matching lines...) Expand all
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 { 46 namespace {
47 47
48 constexpr int64_t kMaxRetransmissionWindowMs = 1000; 48 constexpr int64_t kMaxRetransmissionWindowMs = 1000;
49 constexpr int64_t kMinRetransmissionWindowMs = 30; 49 constexpr int64_t kMinRetransmissionWindowMs = 30;
50 50
51 bool RegisterReceiveCodec(std::unique_ptr<AudioCodingModule>* acm,
52 acm2::RentACodec* rac,
53 const CodecInst& ci) {
54 const int result = (*acm)->RegisterReceiveCodec(
55 ci, [&] { return rac->RentIsacDecoder(ci.plfreq); });
56 return result == 0;
57 }
58
59 } // namespace 51 } // namespace
60 52
61 const int kTelephoneEventAttenuationdB = 10; 53 const int kTelephoneEventAttenuationdB = 10;
62 54
63 class RtcEventLogProxy final : public webrtc::RtcEventLog { 55 class RtcEventLogProxy final : public webrtc::RtcEventLog {
64 public: 56 public:
65 RtcEventLogProxy() : event_log_(nullptr) {} 57 RtcEventLogProxy() : event_log_(nullptr) {}
66 58
67 bool StartLogging(const std::string& file_name, 59 bool StartLogging(const std::string& file_name,
68 int64_t max_size_bytes) override { 60 int64_t max_size_bytes) override {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 receiveCodec.pltype = payloadType; 466 receiveCodec.pltype = payloadType;
475 receiveCodec.plfreq = frequency; 467 receiveCodec.plfreq = frequency;
476 receiveCodec.channels = channels; 468 receiveCodec.channels = channels;
477 receiveCodec.rate = rate; 469 receiveCodec.rate = rate;
478 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); 470 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
479 471
480 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels); 472 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels);
481 receiveCodec.pacsize = dummyCodec.pacsize; 473 receiveCodec.pacsize = dummyCodec.pacsize;
482 474
483 // Register the new codec to the ACM 475 // Register the new codec to the ACM
484 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, receiveCodec)) { 476 if (!audio_coding_->RegisterReceiveCodec(receiveCodec.pltype,
ossu 2016/10/05 13:39:59 Don't make a CodecInst just to convert it to an Sd
kwiberg-webrtc 2016/10/06 12:14:52 The problem is that since the caller has given us
477 CodecInstToSdp(receiveCodec))) {
485 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 478 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
486 "Channel::OnInitializeDecoder() invalid codec (" 479 "Channel::OnInitializeDecoder() invalid codec ("
487 "pt=%d, name=%s) received - 1", 480 "pt=%d, name=%s) received - 1",
488 payloadType, payloadName); 481 payloadType, payloadName);
489 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR); 482 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR);
490 return -1; 483 return -1;
491 } 484 }
492 485
493 return 0; 486 return 0;
494 } 487 }
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 _engineStatisticsPtr->SetLastError( 983 _engineStatisticsPtr->SetLastError(
991 VE_CANNOT_INIT_CHANNEL, kTraceError, 984 VE_CANNOT_INIT_CHANNEL, kTraceError,
992 "Channel::Init() callbacks not registered"); 985 "Channel::Init() callbacks not registered");
993 return -1; 986 return -1;
994 } 987 }
995 988
996 // --- Register all supported codecs to the receiving side of the 989 // --- Register all supported codecs to the receiving side of the
997 // RTP/RTCP module 990 // RTP/RTCP module
998 991
999 CodecInst codec; 992 CodecInst codec;
1000 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); 993 const uint8_t nSupportedCodecs = AudioCodingModule::NumberOfCodecs();
ossu 2016/10/05 13:39:58 How should this be done now that there are two dif
kwiberg-webrtc 2016/10/06 12:14:52 My thinking is that tests and stuff that want to i
ossu 2016/10/21 12:24:05 Acknowledged.
1001 994
1002 for (int idx = 0; idx < nSupportedCodecs; idx++) { 995 for (int idx = 0; idx < nSupportedCodecs; idx++) {
1003 // Open up the RTP/RTCP receiver for all supported codecs 996 // Open up the RTP/RTCP receiver for all supported codecs
1004 if ((audio_coding_->Codec(idx, &codec) == -1) || 997 if ((audio_coding_->Codec(idx, &codec) == -1) ||
1005 (rtp_receiver_->RegisterReceivePayload( 998 (rtp_receiver_->RegisterReceivePayload(
1006 codec.plname, codec.pltype, codec.plfreq, codec.channels, 999 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1007 (codec.rate < 0) ? 0 : codec.rate) == -1)) { 1000 (codec.rate < 0) ? 0 : codec.rate) == -1)) {
1008 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1001 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1009 "Channel::Init() unable to register %s " 1002 "Channel::Init() unable to register %s "
1010 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", 1003 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver",
1011 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1004 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1012 codec.rate); 1005 codec.rate);
1013 } else { 1006 } else {
1014 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1007 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1015 "Channel::Init() %s (%d/%d/%" PRIuS 1008 "Channel::Init() %s (%d/%d/%" PRIuS
1016 "/%d) has been " 1009 "/%d) has been "
1017 "added to the RTP/RTCP receiver", 1010 "added to the RTP/RTCP receiver",
1018 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1011 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1019 codec.rate); 1012 codec.rate);
1020 } 1013 }
1021 1014
1022 // Ensure that PCMU is used as default codec on the sending side 1015 // Ensure that PCMU is used as default codec on the sending side
1023 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) { 1016 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) {
1024 SetSendCodec(codec); 1017 SetSendCodec(codec);
1025 } 1018 }
1026 1019
1027 // Register default PT for outband 'telephone-event' 1020 // Register default PT for outband 'telephone-event'
1028 if (!STR_CASE_CMP(codec.plname, "telephone-event")) { 1021 if (!STR_CASE_CMP(codec.plname, "telephone-event")) {
1029 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 || 1022 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 ||
1030 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1023 !audio_coding_->RegisterReceiveCodec(codec.pltype,
1024 CodecInstToSdp(codec))) {
1031 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1025 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1032 "Channel::Init() failed to register outband " 1026 "Channel::Init() failed to register outband "
1033 "'telephone-event' (%d/%d) correctly", 1027 "'telephone-event' (%d/%d) correctly",
1034 codec.pltype, codec.plfreq); 1028 codec.pltype, codec.plfreq);
1035 } 1029 }
1036 } 1030 }
1037 1031
1038 if (!STR_CASE_CMP(codec.plname, "CN")) { 1032 if (!STR_CASE_CMP(codec.plname, "CN")) {
1039 if (!codec_manager_.RegisterEncoder(codec) || 1033 if (!codec_manager_.RegisterEncoder(codec) ||
1040 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || 1034 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) ||
1041 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) || 1035 !audio_coding_->RegisterReceiveCodec(codec.pltype,
1036 CodecInstToSdp(codec)) ||
1042 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { 1037 _rtpRtcpModule->RegisterSendPayload(codec) == -1) {
1043 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1038 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1044 "Channel::Init() failed to register CN (%d/%d) " 1039 "Channel::Init() failed to register CN (%d/%d) "
1045 "correctly - 1", 1040 "correctly - 1",
1046 codec.pltype, codec.plfreq); 1041 codec.pltype, codec.plfreq);
1047 } 1042 }
1048 } 1043 }
1049 } 1044 }
1050 1045
1051 return 0; 1046 return 0;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); 1375 rtp_receiver_->DeRegisterReceivePayload(codec.pltype);
1381 if (rtp_receiver_->RegisterReceivePayload( 1376 if (rtp_receiver_->RegisterReceivePayload(
1382 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1377 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1383 (codec.rate < 0) ? 0 : codec.rate) != 0) { 1378 (codec.rate < 0) ? 0 : codec.rate) != 0) {
1384 _engineStatisticsPtr->SetLastError( 1379 _engineStatisticsPtr->SetLastError(
1385 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 1380 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
1386 "SetRecPayloadType() RTP/RTCP-module registration failed"); 1381 "SetRecPayloadType() RTP/RTCP-module registration failed");
1387 return -1; 1382 return -1;
1388 } 1383 }
1389 } 1384 }
1390 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1385 if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
1386 CodecInstToSdp(codec))) {
1391 audio_coding_->UnregisterReceiveCodec(codec.pltype); 1387 audio_coding_->UnregisterReceiveCodec(codec.pltype);
1392 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1388 if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
1389 CodecInstToSdp(codec))) {
1393 _engineStatisticsPtr->SetLastError( 1390 _engineStatisticsPtr->SetLastError(
1394 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1391 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1395 "SetRecPayloadType() ACM registration failed - 1"); 1392 "SetRecPayloadType() ACM registration failed - 1");
1396 return -1; 1393 return -1;
1397 } 1394 }
1398 } 1395 }
1399 return 0; 1396 return 0;
1400 } 1397 }
1401 1398
1402 int32_t Channel::GetRecPayloadType(CodecInst& codec) { 1399 int32_t Channel::GetRecPayloadType(CodecInst& codec) {
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 int64_t min_rtt = 0; 3202 int64_t min_rtt = 0;
3206 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3203 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3207 0) { 3204 0) {
3208 return 0; 3205 return 0;
3209 } 3206 }
3210 return rtt; 3207 return rtt;
3211 } 3208 }
3212 3209
3213 } // namespace voe 3210 } // namespace voe
3214 } // namespace webrtc 3211 } // namespace webrtc
OLDNEW
« webrtc/modules/audio_coding/test/delay_test.cc ('K') | « webrtc/modules/utility/source/coder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698