| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "rtc_base/criticalsection.h" | 32 #include "rtc_base/criticalsection.h" |
| 33 #include "rtc_base/format_macros.h" | 33 #include "rtc_base/format_macros.h" |
| 34 #include "rtc_base/location.h" | 34 #include "rtc_base/location.h" |
| 35 #include "rtc_base/logging.h" | 35 #include "rtc_base/logging.h" |
| 36 #include "rtc_base/rate_limiter.h" | 36 #include "rtc_base/rate_limiter.h" |
| 37 #include "rtc_base/task_queue.h" | 37 #include "rtc_base/task_queue.h" |
| 38 #include "rtc_base/thread_checker.h" | 38 #include "rtc_base/thread_checker.h" |
| 39 #include "rtc_base/timeutils.h" | 39 #include "rtc_base/timeutils.h" |
| 40 #include "system_wrappers/include/field_trial.h" | 40 #include "system_wrappers/include/field_trial.h" |
| 41 #include "system_wrappers/include/trace.h" | 41 #include "system_wrappers/include/trace.h" |
| 42 #include "voice_engine/include/voe_rtp_rtcp.h" | |
| 43 #include "voice_engine/output_mixer.h" | 42 #include "voice_engine/output_mixer.h" |
| 44 #include "voice_engine/statistics.h" | 43 #include "voice_engine/statistics.h" |
| 45 #include "voice_engine/utility.h" | 44 #include "voice_engine/utility.h" |
| 46 | 45 |
| 47 namespace webrtc { | 46 namespace webrtc { |
| 48 namespace voe { | 47 namespace voe { |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 constexpr double kAudioSampleDurationSeconds = 0.01; | 51 constexpr double kAudioSampleDurationSeconds = 0.01; |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 "Channel::SetLocalSSRC()"); | 1568 "Channel::SetLocalSSRC()"); |
| 1570 if (channel_state_.Get().sending) { | 1569 if (channel_state_.Get().sending) { |
| 1571 _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, | 1570 _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, |
| 1572 "SetLocalSSRC() already sending"); | 1571 "SetLocalSSRC() already sending"); |
| 1573 return -1; | 1572 return -1; |
| 1574 } | 1573 } |
| 1575 _rtpRtcpModule->SetSSRC(ssrc); | 1574 _rtpRtcpModule->SetSSRC(ssrc); |
| 1576 return 0; | 1575 return 0; |
| 1577 } | 1576 } |
| 1578 | 1577 |
| 1579 int Channel::GetLocalSSRC(unsigned int& ssrc) { | |
| 1580 ssrc = _rtpRtcpModule->SSRC(); | |
| 1581 return 0; | |
| 1582 } | |
| 1583 | |
| 1584 int Channel::GetRemoteSSRC(unsigned int& ssrc) { | 1578 int Channel::GetRemoteSSRC(unsigned int& ssrc) { |
| 1585 ssrc = rtp_receiver_->SSRC(); | 1579 ssrc = rtp_receiver_->SSRC(); |
| 1586 return 0; | 1580 return 0; |
| 1587 } | 1581 } |
| 1588 | 1582 |
| 1589 int Channel::SetSendAudioLevelIndicationStatus(bool enable, unsigned char id) { | 1583 int Channel::SetSendAudioLevelIndicationStatus(bool enable, unsigned char id) { |
| 1590 _includeAudioLevelIndication = enable; | 1584 _includeAudioLevelIndication = enable; |
| 1591 return SetSendRtpHeaderExtension(enable, kRtpExtensionAudioLevel, id); | 1585 return SetSendRtpHeaderExtension(enable, kRtpExtensionAudioLevel, id); |
| 1592 } | 1586 } |
| 1593 | 1587 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 packet_router_->RemoveReceiveRtpModule(_rtpRtcpModule.get()); | 1658 packet_router_->RemoveReceiveRtpModule(_rtpRtcpModule.get()); |
| 1665 packet_router_ = nullptr; | 1659 packet_router_ = nullptr; |
| 1666 } | 1660 } |
| 1667 | 1661 |
| 1668 void Channel::SetRTCPStatus(bool enable) { | 1662 void Channel::SetRTCPStatus(bool enable) { |
| 1669 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1663 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1670 "Channel::SetRTCPStatus()"); | 1664 "Channel::SetRTCPStatus()"); |
| 1671 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); | 1665 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); |
| 1672 } | 1666 } |
| 1673 | 1667 |
| 1674 int Channel::GetRTCPStatus(bool& enabled) { | |
| 1675 RtcpMode method = _rtpRtcpModule->RTCP(); | |
| 1676 enabled = (method != RtcpMode::kOff); | |
| 1677 return 0; | |
| 1678 } | |
| 1679 | |
| 1680 int Channel::SetRTCP_CNAME(const char cName[256]) { | 1668 int Channel::SetRTCP_CNAME(const char cName[256]) { |
| 1681 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1669 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1682 "Channel::SetRTCP_CNAME()"); | 1670 "Channel::SetRTCP_CNAME()"); |
| 1683 if (_rtpRtcpModule->SetCNAME(cName) != 0) { | 1671 if (_rtpRtcpModule->SetCNAME(cName) != 0) { |
| 1684 _engineStatisticsPtr->SetLastError( | 1672 _engineStatisticsPtr->SetLastError( |
| 1685 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 1673 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
| 1686 "SetRTCP_CNAME() failed to set RTCP CNAME"); | 1674 "SetRTCP_CNAME() failed to set RTCP CNAME"); |
| 1687 return -1; | 1675 return -1; |
| 1688 } | 1676 } |
| 1689 return 0; | 1677 return 0; |
| 1690 } | 1678 } |
| 1691 | 1679 |
| 1692 int Channel::GetRemoteRTCP_CNAME(char cName[256]) { | |
| 1693 if (cName == NULL) { | |
| 1694 _engineStatisticsPtr->SetLastError( | |
| 1695 VE_INVALID_ARGUMENT, kTraceError, | |
| 1696 "GetRemoteRTCP_CNAME() invalid CNAME input buffer"); | |
| 1697 return -1; | |
| 1698 } | |
| 1699 char cname[RTCP_CNAME_SIZE]; | |
| 1700 const uint32_t remoteSSRC = rtp_receiver_->SSRC(); | |
| 1701 if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) { | |
| 1702 _engineStatisticsPtr->SetLastError( | |
| 1703 VE_CANNOT_RETRIEVE_CNAME, kTraceError, | |
| 1704 "GetRemoteRTCP_CNAME() failed to retrieve remote RTCP CNAME"); | |
| 1705 return -1; | |
| 1706 } | |
| 1707 strcpy(cName, cname); | |
| 1708 return 0; | |
| 1709 } | |
| 1710 | |
| 1711 int Channel::SendApplicationDefinedRTCPPacket( | |
| 1712 unsigned char subType, | |
| 1713 unsigned int name, | |
| 1714 const char* data, | |
| 1715 unsigned short dataLengthInBytes) { | |
| 1716 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 1717 "Channel::SendApplicationDefinedRTCPPacket()"); | |
| 1718 if (!channel_state_.Get().sending) { | |
| 1719 _engineStatisticsPtr->SetLastError( | |
| 1720 VE_NOT_SENDING, kTraceError, | |
| 1721 "SendApplicationDefinedRTCPPacket() not sending"); | |
| 1722 return -1; | |
| 1723 } | |
| 1724 if (NULL == data) { | |
| 1725 _engineStatisticsPtr->SetLastError( | |
| 1726 VE_INVALID_ARGUMENT, kTraceError, | |
| 1727 "SendApplicationDefinedRTCPPacket() invalid data value"); | |
| 1728 return -1; | |
| 1729 } | |
| 1730 if (dataLengthInBytes % 4 != 0) { | |
| 1731 _engineStatisticsPtr->SetLastError( | |
| 1732 VE_INVALID_ARGUMENT, kTraceError, | |
| 1733 "SendApplicationDefinedRTCPPacket() invalid length value"); | |
| 1734 return -1; | |
| 1735 } | |
| 1736 RtcpMode status = _rtpRtcpModule->RTCP(); | |
| 1737 if (status == RtcpMode::kOff) { | |
| 1738 _engineStatisticsPtr->SetLastError( | |
| 1739 VE_RTCP_ERROR, kTraceError, | |
| 1740 "SendApplicationDefinedRTCPPacket() RTCP is disabled"); | |
| 1741 return -1; | |
| 1742 } | |
| 1743 | |
| 1744 // Create and schedule the RTCP APP packet for transmission | |
| 1745 if (_rtpRtcpModule->SetRTCPApplicationSpecificData( | |
| 1746 subType, name, (const unsigned char*)data, dataLengthInBytes) != 0) { | |
| 1747 _engineStatisticsPtr->SetLastError( | |
| 1748 VE_SEND_ERROR, kTraceError, | |
| 1749 "SendApplicationDefinedRTCPPacket() failed to send RTCP packet"); | |
| 1750 return -1; | |
| 1751 } | |
| 1752 return 0; | |
| 1753 } | |
| 1754 | |
| 1755 int Channel::GetRemoteRTCPReportBlocks( | 1680 int Channel::GetRemoteRTCPReportBlocks( |
| 1756 std::vector<ReportBlock>* report_blocks) { | 1681 std::vector<ReportBlock>* report_blocks) { |
| 1757 if (report_blocks == NULL) { | 1682 if (report_blocks == NULL) { |
| 1758 _engineStatisticsPtr->SetLastError( | 1683 _engineStatisticsPtr->SetLastError( |
| 1759 VE_INVALID_ARGUMENT, kTraceError, | 1684 VE_INVALID_ARGUMENT, kTraceError, |
| 1760 "GetRemoteRTCPReportBlock()s invalid report_blocks."); | 1685 "GetRemoteRTCPReportBlock()s invalid report_blocks."); |
| 1761 return -1; | 1686 return -1; |
| 1762 } | 1687 } |
| 1763 | 1688 |
| 1764 // Get the report blocks from the latest received RTCP Sender or Receiver | 1689 // Get the report blocks from the latest received RTCP Sender or Receiver |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 int64_t min_rtt = 0; | 2106 int64_t min_rtt = 0; |
| 2182 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 2107 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 2183 0) { | 2108 0) { |
| 2184 return 0; | 2109 return 0; |
| 2185 } | 2110 } |
| 2186 return rtt; | 2111 return rtt; |
| 2187 } | 2112 } |
| 2188 | 2113 |
| 2189 } // namespace voe | 2114 } // namespace voe |
| 2190 } // namespace webrtc | 2115 } // namespace webrtc |
| OLD | NEW |