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

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

Issue 2055493003: Voice Engine: Remove RED support (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@remove-red0
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/voe_rtp_rtcp_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 if (!codec_manager_.RegisterEncoder(codec) || 1021 if (!codec_manager_.RegisterEncoder(codec) ||
1022 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || 1022 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) ||
1023 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) || 1023 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) ||
1024 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { 1024 _rtpRtcpModule->RegisterSendPayload(codec) == -1) {
1025 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 1025 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1026 "Channel::Init() failed to register CN (%d/%d) " 1026 "Channel::Init() failed to register CN (%d/%d) "
1027 "correctly - 1", 1027 "correctly - 1",
1028 codec.pltype, codec.plfreq); 1028 codec.pltype, codec.plfreq);
1029 } 1029 }
1030 } 1030 }
1031 #ifdef WEBRTC_CODEC_RED
1032 // Register RED to the receiving side of the ACM.
1033 // We will not receive an OnInitializeDecoder() callback for RED.
1034 if (!STR_CASE_CMP(codec.plname, "RED")) {
1035 if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
1036 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
1037 "Channel::Init() failed to register RED (%d/%d) "
1038 "correctly",
1039 codec.pltype, codec.plfreq);
1040 }
1041 }
1042 #endif
1043 } 1031 }
1044 1032
1045 if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) { 1033 if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) {
1046 LOG(LS_ERROR) << "noise_suppression()->set_level(kDefaultNsMode) failed."; 1034 LOG(LS_ERROR) << "noise_suppression()->set_level(kDefaultNsMode) failed.";
1047 return -1; 1035 return -1;
1048 } 1036 }
1049 if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) { 1037 if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) {
1050 LOG(LS_ERROR) << "gain_control()->set_mode(kDefaultRxAgcMode) failed."; 1038 LOG(LS_ERROR) << "gain_control()->set_mode(kDefaultRxAgcMode) failed.";
1051 return -1; 1039 return -1;
1052 } 1040 }
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 stats.packetsReceived = packetsReceived; 2855 stats.packetsReceived = packetsReceived;
2868 2856
2869 // --- Timestamps 2857 // --- Timestamps
2870 { 2858 {
2871 rtc::CritScope lock(&ts_stats_lock_); 2859 rtc::CritScope lock(&ts_stats_lock_);
2872 stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_; 2860 stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_;
2873 } 2861 }
2874 return 0; 2862 return 0;
2875 } 2863 }
2876 2864
2877 int Channel::SetREDStatus(bool enable, int redPayloadtype) {
2878 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2879 "Channel::SetREDStatus()");
2880
2881 if (enable) {
2882 if (redPayloadtype < 0 || redPayloadtype > 127) {
2883 _engineStatisticsPtr->SetLastError(
2884 VE_PLTYPE_ERROR, kTraceError,
2885 "SetREDStatus() invalid RED payload type");
2886 return -1;
2887 }
2888
2889 if (SetRedPayloadType(redPayloadtype) < 0) {
2890 _engineStatisticsPtr->SetLastError(
2891 VE_CODEC_ERROR, kTraceError,
2892 "SetSecondarySendCodec() Failed to register RED ACM");
2893 return -1;
2894 }
2895 }
2896
2897 if (!codec_manager_.SetCopyRed(enable) ||
2898 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
2899 _engineStatisticsPtr->SetLastError(
2900 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
2901 "SetREDStatus() failed to set RED state in the ACM");
2902 return -1;
2903 }
2904 return 0;
2905 }
2906
2907 int Channel::GetREDStatus(bool& enabled, int& redPayloadtype) {
2908 enabled = codec_manager_.GetStackParams()->use_red;
2909 if (enabled) {
2910 int8_t payloadType = 0;
2911 if (_rtpRtcpModule->SendREDPayloadType(&payloadType) != 0) {
2912 _engineStatisticsPtr->SetLastError(
2913 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
2914 "GetREDStatus() failed to retrieve RED PT from RTP/RTCP "
2915 "module");
2916 return -1;
2917 }
2918 redPayloadtype = payloadType;
2919 return 0;
2920 }
2921 return 0;
2922 }
2923
2924 int Channel::SetCodecFECStatus(bool enable) { 2865 int Channel::SetCodecFECStatus(bool enable) {
2925 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2866 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2926 "Channel::SetCodecFECStatus()"); 2867 "Channel::SetCodecFECStatus()");
2927 2868
2928 if (!codec_manager_.SetCodecFEC(enable) || 2869 if (!codec_manager_.SetCodecFEC(enable) ||
2929 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) { 2870 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
2930 _engineStatisticsPtr->SetLastError( 2871 _engineStatisticsPtr->SetLastError(
2931 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 2872 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
2932 "SetCodecFECStatus() failed to set FEC state"); 2873 "SetCodecFECStatus() failed to set FEC state");
2933 return -1; 2874 return -1;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 "Channel::RegisterReceiveCodecsToRTPModule() %s " 3395 "Channel::RegisterReceiveCodecsToRTPModule() %s "
3455 "(%d/%d/%" PRIuS 3396 "(%d/%d/%" PRIuS
3456 "/%d) has been added to the RTP/RTCP " 3397 "/%d) has been added to the RTP/RTCP "
3457 "receiver", 3398 "receiver",
3458 codec.plname, codec.pltype, codec.plfreq, codec.channels, 3399 codec.plname, codec.pltype, codec.plfreq, codec.channels,
3459 codec.rate); 3400 codec.rate);
3460 } 3401 }
3461 } 3402 }
3462 } 3403 }
3463 3404
3464 // Assuming this method is called with valid payload type.
3465 int Channel::SetRedPayloadType(int red_payload_type) {
3466 CodecInst codec;
3467 bool found_red = false;
3468
3469 // Get default RED settings from the ACM database
3470 const int num_codecs = AudioCodingModule::NumberOfCodecs();
3471 for (int idx = 0; idx < num_codecs; idx++) {
3472 audio_coding_->Codec(idx, &codec);
3473 if (!STR_CASE_CMP(codec.plname, "RED")) {
3474 found_red = true;
3475 break;
3476 }
3477 }
3478
3479 if (!found_red) {
3480 _engineStatisticsPtr->SetLastError(
3481 VE_CODEC_ERROR, kTraceError,
3482 "SetRedPayloadType() RED is not supported");
3483 return -1;
3484 }
3485
3486 codec.pltype = red_payload_type;
3487 if (!codec_manager_.RegisterEncoder(codec) ||
3488 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
3489 _engineStatisticsPtr->SetLastError(
3490 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
3491 "SetRedPayloadType() RED registration in ACM module failed");
3492 return -1;
3493 }
3494
3495 if (_rtpRtcpModule->SetSendREDPayloadType(red_payload_type) != 0) {
3496 _engineStatisticsPtr->SetLastError(
3497 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
3498 "SetRedPayloadType() RED registration in RTP/RTCP module failed");
3499 return -1;
3500 }
3501 return 0;
3502 }
3503
3504 int Channel::SetSendRtpHeaderExtension(bool enable, 3405 int Channel::SetSendRtpHeaderExtension(bool enable,
3505 RTPExtensionType type, 3406 RTPExtensionType type,
3506 unsigned char id) { 3407 unsigned char id) {
3507 int error = 0; 3408 int error = 0;
3508 _rtpRtcpModule->DeregisterSendRtpHeaderExtension(type); 3409 _rtpRtcpModule->DeregisterSendRtpHeaderExtension(type);
3509 if (enable) { 3410 if (enable) {
3510 error = _rtpRtcpModule->RegisterSendRtpHeaderExtension(type, id); 3411 error = _rtpRtcpModule->RegisterSendRtpHeaderExtension(type, id);
3511 } 3412 }
3512 return error; 3413 return error;
3513 } 3414 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 int64_t min_rtt = 0; 3478 int64_t min_rtt = 0;
3578 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3479 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3579 0) { 3480 0) {
3580 return 0; 3481 return 0;
3581 } 3482 }
3582 return rtt; 3483 return rtt;
3583 } 3484 }
3584 3485
3585 } // namespace voe 3486 } // namespace voe
3586 } // namespace webrtc 3487 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/voe_rtp_rtcp_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698