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

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

Issue 2388153004: Stop using old AudioCodingModule::RegisterReceiveCodec overloads (Closed)
Patch Set: rebase 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
11 #include "webrtc/voice_engine/channel.h" 11 #include "webrtc/voice_engine/channel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/format_macros.h" 18 #include "webrtc/base/format_macros.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/rate_limiter.h" 20 #include "webrtc/base/rate_limiter.h"
21 #include "webrtc/base/thread_checker.h" 21 #include "webrtc/base/thread_checker.h"
22 #include "webrtc/base/timeutils.h" 22 #include "webrtc/base/timeutils.h"
23 #include "webrtc/config.h" 23 #include "webrtc/config.h"
24 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 24 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
25 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
25 #include "webrtc/modules/audio_device/include/audio_device.h" 26 #include "webrtc/modules/audio_device/include/audio_device.h"
26 #include "webrtc/modules/audio_processing/include/audio_processing.h" 27 #include "webrtc/modules/audio_processing/include/audio_processing.h"
27 #include "webrtc/modules/include/module_common_types.h" 28 #include "webrtc/modules/include/module_common_types.h"
28 #include "webrtc/modules/pacing/packet_router.h" 29 #include "webrtc/modules/pacing/packet_router.h"
29 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 30 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
30 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
31 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 32 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
33 #include "webrtc/modules/utility/include/audio_frame_operations.h" 34 #include "webrtc/modules/utility/include/audio_frame_operations.h"
34 #include "webrtc/modules/utility/include/process_thread.h" 35 #include "webrtc/modules/utility/include/process_thread.h"
35 #include "webrtc/system_wrappers/include/trace.h" 36 #include "webrtc/system_wrappers/include/trace.h"
36 #include "webrtc/voice_engine/include/voe_external_media.h" 37 #include "webrtc/voice_engine/include/voe_external_media.h"
37 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 38 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
38 #include "webrtc/voice_engine/output_mixer.h" 39 #include "webrtc/voice_engine/output_mixer.h"
39 #include "webrtc/voice_engine/statistics.h" 40 #include "webrtc/voice_engine/statistics.h"
40 #include "webrtc/voice_engine/transmit_mixer.h" 41 #include "webrtc/voice_engine/transmit_mixer.h"
41 #include "webrtc/voice_engine/utility.h" 42 #include "webrtc/voice_engine/utility.h"
42 43
43 namespace webrtc { 44 namespace webrtc {
44 namespace voe { 45 namespace voe {
45 46
46 namespace { 47 namespace {
47 48
48 constexpr int64_t kMaxRetransmissionWindowMs = 1000; 49 constexpr int64_t kMaxRetransmissionWindowMs = 1000;
49 constexpr int64_t kMinRetransmissionWindowMs = 30; 50 constexpr int64_t kMinRetransmissionWindowMs = 30;
50 51
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 52 } // namespace
60 53
61 const int kTelephoneEventAttenuationdB = 10; 54 const int kTelephoneEventAttenuationdB = 10;
62 55
63 class RtcEventLogProxy final : public webrtc::RtcEventLog { 56 class RtcEventLogProxy final : public webrtc::RtcEventLog {
64 public: 57 public:
65 RtcEventLogProxy() : event_log_(nullptr) {} 58 RtcEventLogProxy() : event_log_(nullptr) {}
66 59
67 bool StartLogging(const std::string& file_name, 60 bool StartLogging(const std::string& file_name,
68 int64_t max_size_bytes) override { 61 int64_t max_size_bytes) override {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 receiveCodec.pltype = payloadType; 484 receiveCodec.pltype = payloadType;
492 receiveCodec.plfreq = frequency; 485 receiveCodec.plfreq = frequency;
493 receiveCodec.channels = channels; 486 receiveCodec.channels = channels;
494 receiveCodec.rate = rate; 487 receiveCodec.rate = rate;
495 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); 488 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
496 489
497 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels); 490 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels);
498 receiveCodec.pacsize = dummyCodec.pacsize; 491 receiveCodec.pacsize = dummyCodec.pacsize;
499 492
500 // Register the new codec to the ACM 493 // Register the new codec to the ACM
501 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, receiveCodec)) { 494 if (!audio_coding_->RegisterReceiveCodec(receiveCodec.pltype,
495 CodecInstToSdp(receiveCodec))) {
502 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 496 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
503 "Channel::OnInitializeDecoder() invalid codec (" 497 "Channel::OnInitializeDecoder() invalid codec ("
504 "pt=%d, name=%s) received - 1", 498 "pt=%d, name=%s) received - 1",
505 payloadType, payloadName); 499 payloadType, payloadName);
506 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR); 500 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR);
507 return -1; 501 return -1;
508 } 502 }
509 503
510 return 0; 504 return 0;
511 } 505 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1053 }
1060 1054
1061 // Ensure that PCMU is used as default codec on the sending side 1055 // Ensure that PCMU is used as default codec on the sending side
1062 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) { 1056 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) {
1063 SetSendCodec(codec); 1057 SetSendCodec(codec);
1064 } 1058 }
1065 1059
1066 // Register default PT for outband 'telephone-event' 1060 // Register default PT for outband 'telephone-event'
1067 if (!STR_CASE_CMP(codec.plname, "telephone-event")) { 1061 if (!STR_CASE_CMP(codec.plname, "telephone-event")) {
1068 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 || 1062 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 ||
1069 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1063 !audio_coding_->RegisterReceiveCodec(codec.pltype,
1064 CodecInstToSdp(codec))) {
1070 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1065 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1071 "Channel::Init() failed to register outband " 1066 "Channel::Init() failed to register outband "
1072 "'telephone-event' (%d/%d) correctly", 1067 "'telephone-event' (%d/%d) correctly",
1073 codec.pltype, codec.plfreq); 1068 codec.pltype, codec.plfreq);
1074 } 1069 }
1075 } 1070 }
1076 1071
1077 if (!STR_CASE_CMP(codec.plname, "CN")) { 1072 if (!STR_CASE_CMP(codec.plname, "CN")) {
1078 if (!codec_manager_.RegisterEncoder(codec) || 1073 if (!codec_manager_.RegisterEncoder(codec) ||
1079 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || 1074 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) ||
1080 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) || 1075 !audio_coding_->RegisterReceiveCodec(codec.pltype,
1076 CodecInstToSdp(codec)) ||
1081 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { 1077 _rtpRtcpModule->RegisterSendPayload(codec) == -1) {
1082 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1078 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1083 "Channel::Init() failed to register CN (%d/%d) " 1079 "Channel::Init() failed to register CN (%d/%d) "
1084 "correctly - 1", 1080 "correctly - 1",
1085 codec.pltype, codec.plfreq); 1081 codec.pltype, codec.plfreq);
1086 } 1082 }
1087 } 1083 }
1088 } 1084 }
1089 1085
1090 return 0; 1086 return 0;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 rtp_receiver_->DeRegisterReceivePayload(codec.pltype); 1414 rtp_receiver_->DeRegisterReceivePayload(codec.pltype);
1419 if (rtp_receiver_->RegisterReceivePayload( 1415 if (rtp_receiver_->RegisterReceivePayload(
1420 codec.plname, codec.pltype, codec.plfreq, codec.channels, 1416 codec.plname, codec.pltype, codec.plfreq, codec.channels,
1421 (codec.rate < 0) ? 0 : codec.rate) != 0) { 1417 (codec.rate < 0) ? 0 : codec.rate) != 0) {
1422 _engineStatisticsPtr->SetLastError( 1418 _engineStatisticsPtr->SetLastError(
1423 VE_RTP_RTCP_MODULE_ERROR, kTraceError, 1419 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
1424 "SetRecPayloadType() RTP/RTCP-module registration failed"); 1420 "SetRecPayloadType() RTP/RTCP-module registration failed");
1425 return -1; 1421 return -1;
1426 } 1422 }
1427 } 1423 }
1428 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1424 if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
1425 CodecInstToSdp(codec))) {
1429 audio_coding_->UnregisterReceiveCodec(codec.pltype); 1426 audio_coding_->UnregisterReceiveCodec(codec.pltype);
1430 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) { 1427 if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
1428 CodecInstToSdp(codec))) {
1431 _engineStatisticsPtr->SetLastError( 1429 _engineStatisticsPtr->SetLastError(
1432 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1430 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1433 "SetRecPayloadType() ACM registration failed - 1"); 1431 "SetRecPayloadType() ACM registration failed - 1");
1434 return -1; 1432 return -1;
1435 } 1433 }
1436 } 1434 }
1437 return 0; 1435 return 0;
1438 } 1436 }
1439 1437
1440 int32_t Channel::GetRecPayloadType(CodecInst& codec) { 1438 int32_t Channel::GetRecPayloadType(CodecInst& codec) {
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 int64_t min_rtt = 0; 3265 int64_t min_rtt = 0;
3268 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3266 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3269 0) { 3267 0) {
3270 return 0; 3268 return 0;
3271 } 3269 }
3272 return rtt; 3270 return rtt;
3273 } 3271 }
3274 3272
3275 } // namespace voe 3273 } // namespace voe
3276 } // namespace webrtc 3274 } // namespace webrtc
OLDNEW
« webrtc/modules/audio_coding/audio_coding.gypi ('K') | « webrtc/voice_engine/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698