| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" |
| 12 | 12 |
| 13 #include <assert.h> // assert | 13 #include <assert.h> // assert |
| 14 #include <string.h> // memcpy | 14 #include <string.h> // memcpy |
| 15 | 15 |
| 16 #include <algorithm> // min | 16 #include <algorithm> // min |
| 17 #include <limits> // max | 17 #include <limits> // max |
| 18 #include <utility> | 18 #include <utility> |
| 19 | 19 |
| 20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
| 22 #include "webrtc/base/trace_event.h" | 22 #include "webrtc/base/trace_event.h" |
| 23 #include "webrtc/common_types.h" | 23 #include "webrtc/common_types.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
| 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
| 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |
| 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
| 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
| 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |
| 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
| 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
| 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
| 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |
| 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" |
| 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |
| 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 37 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 38 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 736 } |
| 736 | 737 |
| 737 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildReceiverReferenceTime( | 738 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildReceiverReferenceTime( |
| 738 const RtcpContext& ctx) { | 739 const RtcpContext& ctx) { |
| 739 if (last_xr_rr_.size() >= RTCP_NUMBER_OF_SR) | 740 if (last_xr_rr_.size() >= RTCP_NUMBER_OF_SR) |
| 740 last_xr_rr_.erase(last_xr_rr_.begin()); | 741 last_xr_rr_.erase(last_xr_rr_.begin()); |
| 741 last_xr_rr_.insert(std::pair<uint32_t, int64_t>( | 742 last_xr_rr_.insert(std::pair<uint32_t, int64_t>( |
| 742 RTCPUtility::MidNtp(ctx.ntp_sec_, ctx.ntp_frac_), | 743 RTCPUtility::MidNtp(ctx.ntp_sec_, ctx.ntp_frac_), |
| 743 Clock::NtpToMs(ctx.ntp_sec_, ctx.ntp_frac_))); | 744 Clock::NtpToMs(ctx.ntp_sec_, ctx.ntp_frac_))); |
| 744 | 745 |
| 745 rtcp::Xr* xr = new rtcp::Xr(); | 746 rtcp::ExtendedReports* xr = new rtcp::ExtendedReports(); |
| 746 xr->From(ssrc_); | 747 xr->From(ssrc_); |
| 747 | 748 |
| 748 rtcp::Rrtr rrtr; | 749 rtcp::Rrtr rrtr; |
| 749 rrtr.WithNtp(NtpTime(ctx.ntp_sec_, ctx.ntp_frac_)); | 750 rrtr.WithNtp(NtpTime(ctx.ntp_sec_, ctx.ntp_frac_)); |
| 750 | 751 |
| 751 xr->WithRrtr(&rrtr); | 752 xr->WithRrtr(&rrtr); |
| 752 | 753 |
| 753 // TODO(sprang): Merge XR report sending to contain all of RRTR, DLRR, VOIP? | 754 // TODO(sprang): Merge XR report sending to contain all of RRTR, DLRR, VOIP? |
| 754 | 755 |
| 755 return rtc::scoped_ptr<rtcp::Xr>(xr); | 756 return rtc::scoped_ptr<rtcp::RtcpPacket>(xr); |
| 756 } | 757 } |
| 757 | 758 |
| 758 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildDlrr( | 759 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildDlrr( |
| 759 const RtcpContext& ctx) { | 760 const RtcpContext& ctx) { |
| 760 rtcp::Xr* xr = new rtcp::Xr(); | 761 rtcp::ExtendedReports* xr = new rtcp::ExtendedReports(); |
| 761 xr->From(ssrc_); | 762 xr->From(ssrc_); |
| 762 | 763 |
| 763 rtcp::Dlrr dlrr; | 764 rtcp::Dlrr dlrr; |
| 764 const RtcpReceiveTimeInfo& info = ctx.feedback_state_.last_xr_rr; | 765 const RtcpReceiveTimeInfo& info = ctx.feedback_state_.last_xr_rr; |
| 765 dlrr.WithDlrrItem(info.sourceSSRC, info.lastRR, info.delaySinceLastRR); | 766 dlrr.WithDlrrItem(info.sourceSSRC, info.lastRR, info.delaySinceLastRR); |
| 766 | 767 |
| 767 xr->WithDlrr(&dlrr); | 768 xr->WithDlrr(&dlrr); |
| 768 | 769 |
| 769 return rtc::scoped_ptr<rtcp::Xr>(xr); | 770 return rtc::scoped_ptr<rtcp::RtcpPacket>(xr); |
| 770 } | 771 } |
| 771 | 772 |
| 772 // TODO(sprang): Add a unit test for this, or remove if the code isn't used. | 773 // TODO(sprang): Add a unit test for this, or remove if the code isn't used. |
| 773 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildVoIPMetric( | 774 rtc::scoped_ptr<rtcp::RtcpPacket> RTCPSender::BuildVoIPMetric( |
| 774 const RtcpContext& context) { | 775 const RtcpContext& context) { |
| 775 rtcp::Xr* xr = new rtcp::Xr(); | 776 rtcp::ExtendedReports* xr = new rtcp::ExtendedReports(); |
| 776 xr->From(ssrc_); | 777 xr->From(ssrc_); |
| 777 | 778 |
| 778 rtcp::VoipMetric voip; | 779 rtcp::VoipMetric voip; |
| 779 voip.To(remote_ssrc_); | 780 voip.To(remote_ssrc_); |
| 780 voip.WithVoipMetric(xr_voip_metric_); | 781 voip.WithVoipMetric(xr_voip_metric_); |
| 781 | 782 |
| 782 xr->WithVoipMetric(&voip); | 783 xr->WithVoipMetric(&voip); |
| 783 | 784 |
| 784 return rtc::scoped_ptr<rtcp::Xr>(xr); | 785 return rtc::scoped_ptr<rtcp::RtcpPacket>(xr); |
| 785 } | 786 } |
| 786 | 787 |
| 787 int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, | 788 int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, |
| 788 RTCPPacketType packetType, | 789 RTCPPacketType packetType, |
| 789 int32_t nack_size, | 790 int32_t nack_size, |
| 790 const uint16_t* nack_list, | 791 const uint16_t* nack_list, |
| 791 bool repeat, | 792 bool repeat, |
| 792 uint64_t pictureID) { | 793 uint64_t pictureID) { |
| 793 return SendCompoundRTCP( | 794 return SendCompoundRTCP( |
| 794 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1), | 795 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1), |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 Transport* const transport_; | 1056 Transport* const transport_; |
| 1056 bool send_failure_; | 1057 bool send_failure_; |
| 1057 } sender(transport_); | 1058 } sender(transport_); |
| 1058 | 1059 |
| 1059 uint8_t buffer[IP_PACKET_SIZE]; | 1060 uint8_t buffer[IP_PACKET_SIZE]; |
| 1060 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && | 1061 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && |
| 1061 !sender.send_failure_; | 1062 !sender.send_failure_; |
| 1062 } | 1063 } |
| 1063 | 1064 |
| 1064 } // namespace webrtc | 1065 } // namespace webrtc |
| OLD | NEW |