OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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_packet.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
16 | 16 |
17 using webrtc::RTCPUtility::kBtDlrr; | 17 using webrtc::RTCPUtility::kBtDlrr; |
18 using webrtc::RTCPUtility::kBtReceiverReferenceTime; | 18 using webrtc::RTCPUtility::kBtReceiverReferenceTime; |
19 using webrtc::RTCPUtility::kBtVoipMetric; | 19 using webrtc::RTCPUtility::kBtVoipMetric; |
20 | 20 |
21 using webrtc::RTCPUtility::PT_APP; | 21 using webrtc::RTCPUtility::PT_APP; |
22 using webrtc::RTCPUtility::PT_IJ; | 22 using webrtc::RTCPUtility::PT_IJ; |
23 using webrtc::RTCPUtility::PT_PSFB; | 23 using webrtc::RTCPUtility::PT_PSFB; |
24 using webrtc::RTCPUtility::PT_RR; | |
25 using webrtc::RTCPUtility::PT_RTPFB; | 24 using webrtc::RTCPUtility::PT_RTPFB; |
26 using webrtc::RTCPUtility::PT_SDES; | 25 using webrtc::RTCPUtility::PT_SDES; |
27 using webrtc::RTCPUtility::PT_SR; | 26 using webrtc::RTCPUtility::PT_SR; |
28 using webrtc::RTCPUtility::PT_XR; | 27 using webrtc::RTCPUtility::PT_XR; |
29 | 28 |
30 using webrtc::RTCPUtility::RTCPPacketAPP; | 29 using webrtc::RTCPUtility::RTCPPacketAPP; |
31 using webrtc::RTCPUtility::RTCPPacketPSFBAPP; | 30 using webrtc::RTCPUtility::RTCPPacketPSFBAPP; |
32 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; | 31 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; |
33 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; | 32 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; |
34 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem; | 33 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem; |
35 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; | 34 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; |
36 using webrtc::RTCPUtility::RTCPPacketPSFBSLI; | 35 using webrtc::RTCPUtility::RTCPPacketPSFBSLI; |
37 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem; | 36 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem; |
38 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; | 37 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; |
39 using webrtc::RTCPUtility::RTCPPacketRR; | |
40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; | 38 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; |
41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; | 39 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; |
42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; | 40 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; |
43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; | 41 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; |
44 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; | 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; |
45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; | 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; |
46 using webrtc::RTCPUtility::RTCPPacketSR; | 44 using webrtc::RTCPUtility::RTCPPacketSR; |
47 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; | 45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; |
48 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem; | 46 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem; |
49 using webrtc::RTCPUtility::RTCPPacketXR; | 47 using webrtc::RTCPUtility::RTCPPacketXR; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 uint8_t* buffer, | 110 uint8_t* buffer, |
113 size_t* pos) { | 111 size_t* pos) { |
114 AssignUWord32(buffer, pos, sr.SenderSSRC); | 112 AssignUWord32(buffer, pos, sr.SenderSSRC); |
115 AssignUWord32(buffer, pos, sr.NTPMostSignificant); | 113 AssignUWord32(buffer, pos, sr.NTPMostSignificant); |
116 AssignUWord32(buffer, pos, sr.NTPLeastSignificant); | 114 AssignUWord32(buffer, pos, sr.NTPLeastSignificant); |
117 AssignUWord32(buffer, pos, sr.RTPTimestamp); | 115 AssignUWord32(buffer, pos, sr.RTPTimestamp); |
118 AssignUWord32(buffer, pos, sr.SenderPacketCount); | 116 AssignUWord32(buffer, pos, sr.SenderPacketCount); |
119 AssignUWord32(buffer, pos, sr.SenderOctetCount); | 117 AssignUWord32(buffer, pos, sr.SenderOctetCount); |
120 } | 118 } |
121 | 119 |
122 // Receiver report (RR), header (RFC 3550). | |
123 // | |
124 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
125 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
126 // |V=2|P| RC | PT=RR=201 | length | | |
127 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
128 // | SSRC of packet sender | | |
129 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
130 | |
131 void CreateReceiverReport(const RTCPPacketRR& rr, | |
132 uint8_t* buffer, | |
133 size_t* pos) { | |
134 AssignUWord32(buffer, pos, rr.SenderSSRC); | |
135 } | |
136 | |
137 // Report block (RFC 3550). | 120 // Report block (RFC 3550). |
138 // | 121 // |
139 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 122 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
140 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 123 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
141 // | SSRC_1 (SSRC of first source) | | 124 // | SSRC_1 (SSRC of first source) | |
142 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 125 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
143 // | fraction lost | cumulative number of packets lost | | 126 // | fraction lost | cumulative number of packets lost | |
144 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 127 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
145 // | extended highest sequence number received | | 128 // | extended highest sequence number received | |
146 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 129 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 bool SenderReport::WithReportBlock(const ReportBlock& block) { | 657 bool SenderReport::WithReportBlock(const ReportBlock& block) { |
675 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | 658 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { |
676 LOG(LS_WARNING) << "Max report blocks reached."; | 659 LOG(LS_WARNING) << "Max report blocks reached."; |
677 return false; | 660 return false; |
678 } | 661 } |
679 report_blocks_.push_back(block); | 662 report_blocks_.push_back(block); |
680 sr_.NumberOfReportBlocks = report_blocks_.size(); | 663 sr_.NumberOfReportBlocks = report_blocks_.size(); |
681 return true; | 664 return true; |
682 } | 665 } |
683 | 666 |
684 bool ReceiverReport::Create(uint8_t* packet, | |
685 size_t* index, | |
686 size_t max_length, | |
687 RtcpPacket::PacketReadyCallback* callback) const { | |
688 while (*index + BlockLength() > max_length) { | |
689 if (!OnBufferFull(packet, index, callback)) | |
690 return false; | |
691 } | |
692 CreateHeader(rr_.NumberOfReportBlocks, PT_RR, HeaderLength(), packet, index); | |
693 CreateReceiverReport(rr_, packet, index); | |
694 CreateReportBlocks(report_blocks_, packet, index); | |
695 return true; | |
696 } | |
697 | |
698 bool ReceiverReport::WithReportBlock(const ReportBlock& block) { | |
699 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | |
700 LOG(LS_WARNING) << "Max report blocks reached."; | |
701 return false; | |
702 } | |
703 report_blocks_.push_back(block); | |
704 rr_.NumberOfReportBlocks = report_blocks_.size(); | |
705 return true; | |
706 } | |
707 | |
708 bool Sdes::Create(uint8_t* packet, | 667 bool Sdes::Create(uint8_t* packet, |
709 size_t* index, | 668 size_t* index, |
710 size_t max_length, | 669 size_t max_length, |
711 RtcpPacket::PacketReadyCallback* callback) const { | 670 RtcpPacket::PacketReadyCallback* callback) const { |
712 assert(!chunks_.empty()); | 671 assert(!chunks_.empty()); |
713 while (*index + BlockLength() > max_length) { | 672 while (*index + BlockLength() > max_length) { |
714 if (!OnBufferFull(packet, index, callback)) | 673 if (!OnBufferFull(packet, index, callback)) |
715 return false; | 674 return false; |
716 } | 675 } |
717 CreateHeader(chunks_.size(), PT_SDES, HeaderLength(), packet, index); | 676 CreateHeader(chunks_.size(), PT_SDES, HeaderLength(), packet, index); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 return length_; | 1001 return length_; |
1043 } | 1002 } |
1044 | 1003 |
1045 void RawPacket::SetLength(size_t length) { | 1004 void RawPacket::SetLength(size_t length) { |
1046 assert(length <= buffer_length_); | 1005 assert(length <= buffer_length_); |
1047 length_ = length; | 1006 length_ = length; |
1048 } | 1007 } |
1049 | 1008 |
1050 } // namespace rtcp | 1009 } // namespace rtcp |
1051 } // namespace webrtc | 1010 } // namespace webrtc |
OLD | NEW |