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

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

Issue 1373903003: Unify newapi::RtcpMode and RTCPMethod. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: ehm, compile the code Created 5 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
« no previous file with comments | « webrtc/video_receive_stream.h ('k') | no next file » | 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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 914
915 // --- RTP/RTCP module initialization 915 // --- RTP/RTCP module initialization
916 916
917 // Ensure that RTCP is enabled by default for the created channel. 917 // Ensure that RTCP is enabled by default for the created channel.
918 // Note that, the module will keep generating RTCP until it is explicitly 918 // Note that, the module will keep generating RTCP until it is explicitly
919 // disabled by the user. 919 // disabled by the user.
920 // After StopListen (when no sockets exists), RTCP packets will no longer 920 // After StopListen (when no sockets exists), RTCP packets will no longer
921 // be transmitted since the Transport object will then be invalid. 921 // be transmitted since the Transport object will then be invalid.
922 telephone_event_handler_->SetTelephoneEventForwardToDecoder(true); 922 telephone_event_handler_->SetTelephoneEventForwardToDecoder(true);
923 // RTCP is enabled by default. 923 // RTCP is enabled by default.
924 _rtpRtcpModule->SetRTCPStatus(kRtcpCompound); 924 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
925 // --- Register all permanent callbacks 925 // --- Register all permanent callbacks
926 const bool fail = 926 const bool fail =
927 (audio_coding_->RegisterTransportCallback(this) == -1) || 927 (audio_coding_->RegisterTransportCallback(this) == -1) ||
928 (audio_coding_->RegisterVADCallback(this) == -1); 928 (audio_coding_->RegisterVADCallback(this) == -1);
929 929
930 if (fail) 930 if (fail)
931 { 931 {
932 _engineStatisticsPtr->SetLastError( 932 _engineStatisticsPtr->SetLastError(
933 VE_CANNOT_INIT_CHANNEL, kTraceError, 933 VE_CANNOT_INIT_CHANNEL, kTraceError,
934 "Channel::Init() callbacks not registered"); 934 "Channel::Init() callbacks not registered");
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 if (enable && !rtp_header_parser_->RegisterRtpHeaderExtension( 2776 if (enable && !rtp_header_parser_->RegisterRtpHeaderExtension(
2777 kRtpExtensionAbsoluteSendTime, id)) { 2777 kRtpExtensionAbsoluteSendTime, id)) {
2778 return -1; 2778 return -1;
2779 } 2779 }
2780 return 0; 2780 return 0;
2781 } 2781 }
2782 2782
2783 void Channel::SetRTCPStatus(bool enable) { 2783 void Channel::SetRTCPStatus(bool enable) {
2784 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2784 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2785 "Channel::SetRTCPStatus()"); 2785 "Channel::SetRTCPStatus()");
2786 _rtpRtcpModule->SetRTCPStatus(enable ? kRtcpCompound : kRtcpOff); 2786 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff);
2787 } 2787 }
2788 2788
2789 int 2789 int
2790 Channel::GetRTCPStatus(bool& enabled) 2790 Channel::GetRTCPStatus(bool& enabled)
2791 { 2791 {
2792 RTCPMethod method = _rtpRtcpModule->RTCP(); 2792 RtcpMode method = _rtpRtcpModule->RTCP();
2793 enabled = (method != kRtcpOff); 2793 enabled = (method != RtcpMode::kOff);
2794 return 0; 2794 return 0;
2795 } 2795 }
2796 2796
2797 int 2797 int
2798 Channel::SetRTCP_CNAME(const char cName[256]) 2798 Channel::SetRTCP_CNAME(const char cName[256])
2799 { 2799 {
2800 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2800 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2801 "Channel::SetRTCP_CNAME()"); 2801 "Channel::SetRTCP_CNAME()");
2802 if (_rtpRtcpModule->SetCNAME(cName) != 0) 2802 if (_rtpRtcpModule->SetCNAME(cName) != 0)
2803 { 2803 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 "SendApplicationDefinedRTCPPacket() invalid data value"); 2929 "SendApplicationDefinedRTCPPacket() invalid data value");
2930 return -1; 2930 return -1;
2931 } 2931 }
2932 if (dataLengthInBytes % 4 != 0) 2932 if (dataLengthInBytes % 4 != 0)
2933 { 2933 {
2934 _engineStatisticsPtr->SetLastError( 2934 _engineStatisticsPtr->SetLastError(
2935 VE_INVALID_ARGUMENT, kTraceError, 2935 VE_INVALID_ARGUMENT, kTraceError,
2936 "SendApplicationDefinedRTCPPacket() invalid length value"); 2936 "SendApplicationDefinedRTCPPacket() invalid length value");
2937 return -1; 2937 return -1;
2938 } 2938 }
2939 RTCPMethod status = _rtpRtcpModule->RTCP(); 2939 RtcpMode status = _rtpRtcpModule->RTCP();
2940 if (status == kRtcpOff) 2940 if (status == RtcpMode::kOff) {
2941 {
2942 _engineStatisticsPtr->SetLastError( 2941 _engineStatisticsPtr->SetLastError(
2943 VE_RTCP_ERROR, kTraceError, 2942 VE_RTCP_ERROR, kTraceError,
2944 "SendApplicationDefinedRTCPPacket() RTCP is disabled"); 2943 "SendApplicationDefinedRTCPPacket() RTCP is disabled");
2945 return -1; 2944 return -1;
2946 } 2945 }
2947 2946
2948 // Create and schedule the RTCP APP packet for transmission 2947 // Create and schedule the RTCP APP packet for transmission
2949 if (_rtpRtcpModule->SetRTCPApplicationSpecificData( 2948 if (_rtpRtcpModule->SetRTCPApplicationSpecificData(
2950 subType, 2949 subType,
2951 name, 2950 name,
2952 (const unsigned char*) data, 2951 (const unsigned char*) data,
2953 dataLengthInBytes) != 0) 2952 dataLengthInBytes) != 0)
2954 { 2953 {
2955 _engineStatisticsPtr->SetLastError( 2954 _engineStatisticsPtr->SetLastError(
2956 VE_SEND_ERROR, kTraceError, 2955 VE_SEND_ERROR, kTraceError,
2957 "SendApplicationDefinedRTCPPacket() failed to send RTCP packet"); 2956 "SendApplicationDefinedRTCPPacket() failed to send RTCP packet");
2958 return -1; 2957 return -1;
2959 } 2958 }
2960 return 0; 2959 return 0;
2961 } 2960 }
2962 2961
2963 int 2962 int
2964 Channel::GetRTPStatistics( 2963 Channel::GetRTPStatistics(
2965 unsigned int& averageJitterMs, 2964 unsigned int& averageJitterMs,
2966 unsigned int& maxJitterMs, 2965 unsigned int& maxJitterMs,
2967 unsigned int& discardedPackets) 2966 unsigned int& discardedPackets)
2968 { 2967 {
2969 // The jitter statistics is updated for each received RTP packet and is 2968 // The jitter statistics is updated for each received RTP packet and is
2970 // based on received packets. 2969 // based on received packets.
2971 if (_rtpRtcpModule->RTCP() == kRtcpOff) { 2970 if (_rtpRtcpModule->RTCP() == RtcpMode::kOff) {
2972 // If RTCP is off, there is no timed thread in the RTCP module regularly 2971 // If RTCP is off, there is no timed thread in the RTCP module regularly
2973 // generating new stats, trigger the update manually here instead. 2972 // generating new stats, trigger the update manually here instead.
2974 StreamStatistician* statistician = 2973 StreamStatistician* statistician =
2975 rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC()); 2974 rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC());
2976 if (statistician) { 2975 if (statistician) {
2977 // Don't use returned statistics, use data from proxy instead so that 2976 // Don't use returned statistics, use data from proxy instead so that
2978 // max jitter can be fetched atomically. 2977 // max jitter can be fetched atomically.
2979 RtcpStatistics s; 2978 RtcpStatistics s;
2980 statistician->GetStatistics(&s, true); 2979 statistician->GetStatistics(&s, true);
2981 } 2980 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 int 3031 int
3033 Channel::GetRTPStatistics(CallStatistics& stats) 3032 Channel::GetRTPStatistics(CallStatistics& stats)
3034 { 3033 {
3035 // --- RtcpStatistics 3034 // --- RtcpStatistics
3036 3035
3037 // The jitter statistics is updated for each received RTP packet and is 3036 // The jitter statistics is updated for each received RTP packet and is
3038 // based on received packets. 3037 // based on received packets.
3039 RtcpStatistics statistics; 3038 RtcpStatistics statistics;
3040 StreamStatistician* statistician = 3039 StreamStatistician* statistician =
3041 rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC()); 3040 rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC());
3042 if (!statistician || !statistician->GetStatistics( 3041 if (!statistician ||
3043 &statistics, _rtpRtcpModule->RTCP() == kRtcpOff)) { 3042 !statistician->GetStatistics(
3043 &statistics, _rtpRtcpModule->RTCP() == RtcpMode::kOff)) {
3044 _engineStatisticsPtr->SetLastError( 3044 _engineStatisticsPtr->SetLastError(
3045 VE_CANNOT_RETRIEVE_RTP_STAT, kTraceWarning, 3045 VE_CANNOT_RETRIEVE_RTP_STAT, kTraceWarning,
3046 "GetRTPStatistics() failed to read RTP statistics from the " 3046 "GetRTPStatistics() failed to read RTP statistics from the "
3047 "RTP/RTCP module"); 3047 "RTP/RTCP module");
3048 } 3048 }
3049 3049
3050 stats.fractionLost = statistics.fraction_lost; 3050 stats.fractionLost = statistics.fraction_lost;
3051 stats.cumulativeLost = statistics.cumulative_lost; 3051 stats.cumulativeLost = statistics.cumulative_lost;
3052 stats.extendedMax = statistics.extended_max_sequence_number; 3052 stats.extendedMax = statistics.extended_max_sequence_number;
3053 stats.jitterSamples = statistics.jitter; 3053 stats.jitterSamples = statistics.jitter;
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 // DSP routines can operate at 48,000 Hz, but the RTP clock 3904 // DSP routines can operate at 48,000 Hz, but the RTP clock
3905 // rate for the Opus payload format is standardized to 48,000 Hz, 3905 // rate for the Opus payload format is standardized to 48,000 Hz,
3906 // because that is the maximum supported decoding sampling rate. 3906 // because that is the maximum supported decoding sampling rate.
3907 playout_frequency = 48000; 3907 playout_frequency = 48000;
3908 } 3908 }
3909 } 3909 }
3910 return playout_frequency; 3910 return playout_frequency;
3911 } 3911 }
3912 3912
3913 int64_t Channel::GetRTT(bool allow_associate_channel) const { 3913 int64_t Channel::GetRTT(bool allow_associate_channel) const {
3914 RTCPMethod method = _rtpRtcpModule->RTCP(); 3914 RtcpMode method = _rtpRtcpModule->RTCP();
3915 if (method == kRtcpOff) { 3915 if (method == RtcpMode::kOff) {
3916 return 0; 3916 return 0;
3917 } 3917 }
3918 std::vector<RTCPReportBlock> report_blocks; 3918 std::vector<RTCPReportBlock> report_blocks;
3919 _rtpRtcpModule->RemoteRTCPStat(&report_blocks); 3919 _rtpRtcpModule->RemoteRTCPStat(&report_blocks);
3920 3920
3921 int64_t rtt = 0; 3921 int64_t rtt = 0;
3922 if (report_blocks.empty()) { 3922 if (report_blocks.empty()) {
3923 if (allow_associate_channel) { 3923 if (allow_associate_channel) {
3924 CriticalSectionScoped lock(assoc_send_channel_lock_.get()); 3924 CriticalSectionScoped lock(assoc_send_channel_lock_.get());
3925 Channel* channel = associate_send_channel_.channel(); 3925 Channel* channel = associate_send_channel_.channel();
(...skipping 28 matching lines...) Expand all
3954 int64_t min_rtt = 0; 3954 int64_t min_rtt = 0;
3955 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) 3955 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt)
3956 != 0) { 3956 != 0) {
3957 return 0; 3957 return 0;
3958 } 3958 }
3959 return rtt; 3959 return rtt;
3960 } 3960 }
3961 3961
3962 } // namespace voe 3962 } // namespace voe
3963 } // namespace webrtc 3963 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698