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 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 void CreateReportBlocks(const std::vector<ReportBlock>& blocks, | 157 void CreateReportBlocks(const std::vector<ReportBlock>& blocks, |
158 uint8_t* buffer, | 158 uint8_t* buffer, |
159 size_t* pos) { | 159 size_t* pos) { |
160 for (const ReportBlock& block : blocks) { | 160 for (const ReportBlock& block : blocks) { |
161 block.Create(buffer + *pos); | 161 block.Create(buffer + *pos); |
162 *pos += ReportBlock::kLength; | 162 *pos += ReportBlock::kLength; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 // Transmission Time Offsets in RTP Streams (RFC 5450). | |
167 // | |
168 // 0 1 2 3 | |
169 // 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 | |
170 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
171 // hdr |V=2|P| RC | PT=IJ=195 | length | | |
172 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
173 // | inter-arrival jitter | | |
174 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
175 // . . | |
176 // . . | |
177 // . . | |
178 // | inter-arrival jitter | | |
179 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
180 | |
181 void CreateIj(const std::vector<uint32_t>& ij_items, | |
182 uint8_t* buffer, | |
183 size_t* pos) { | |
184 for (uint32_t item : ij_items) | |
185 AssignUWord32(buffer, pos, item); | |
186 } | |
187 | |
188 // Source Description (SDES) (RFC 3550). | 166 // Source Description (SDES) (RFC 3550). |
189 // | 167 // |
190 // 0 1 2 3 | 168 // 0 1 2 3 |
191 // 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 | 169 // 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 |
192 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 170 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
193 // header |V=2|P| SC | PT=SDES=202 | length | | 171 // header |V=2|P| SC | PT=SDES=202 | length | |
194 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 172 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
195 // chunk | SSRC/CSRC_1 | | 173 // chunk | SSRC/CSRC_1 | |
196 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 174 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
197 // | SDES items | | 175 // | SDES items | |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 bool ReceiverReport::WithReportBlock(const ReportBlock& block) { | 775 bool ReceiverReport::WithReportBlock(const ReportBlock& block) { |
798 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | 776 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { |
799 LOG(LS_WARNING) << "Max report blocks reached."; | 777 LOG(LS_WARNING) << "Max report blocks reached."; |
800 return false; | 778 return false; |
801 } | 779 } |
802 report_blocks_.push_back(block); | 780 report_blocks_.push_back(block); |
803 rr_.NumberOfReportBlocks = report_blocks_.size(); | 781 rr_.NumberOfReportBlocks = report_blocks_.size(); |
804 return true; | 782 return true; |
805 } | 783 } |
806 | 784 |
807 bool Ij::Create(uint8_t* packet, | |
808 size_t* index, | |
809 size_t max_length, | |
810 RtcpPacket::PacketReadyCallback* callback) const { | |
811 while (*index + BlockLength() > max_length) { | |
812 if (!OnBufferFull(packet, index, callback)) | |
813 return false; | |
814 } | |
815 size_t length = ij_items_.size(); | |
816 CreateHeader(length, PT_IJ, length, packet, index); | |
817 CreateIj(ij_items_, packet, index); | |
818 return true; | |
819 } | |
820 | |
821 bool Ij::WithJitterItem(uint32_t jitter) { | |
822 if (ij_items_.size() >= kMaxNumberOfIjItems) { | |
823 LOG(LS_WARNING) << "Max inter-arrival jitter items reached."; | |
824 return false; | |
825 } | |
826 ij_items_.push_back(jitter); | |
827 return true; | |
828 } | |
829 | |
830 bool Sdes::Create(uint8_t* packet, | 785 bool Sdes::Create(uint8_t* packet, |
831 size_t* index, | 786 size_t* index, |
832 size_t max_length, | 787 size_t max_length, |
833 RtcpPacket::PacketReadyCallback* callback) const { | 788 RtcpPacket::PacketReadyCallback* callback) const { |
834 assert(!chunks_.empty()); | 789 assert(!chunks_.empty()); |
835 while (*index + BlockLength() > max_length) { | 790 while (*index + BlockLength() > max_length) { |
836 if (!OnBufferFull(packet, index, callback)) | 791 if (!OnBufferFull(packet, index, callback)) |
837 return false; | 792 return false; |
838 } | 793 } |
839 CreateHeader(chunks_.size(), PT_SDES, HeaderLength(), packet, index); | 794 CreateHeader(chunks_.size(), PT_SDES, HeaderLength(), packet, index); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 return length_; | 1169 return length_; |
1215 } | 1170 } |
1216 | 1171 |
1217 void RawPacket::SetLength(size_t length) { | 1172 void RawPacket::SetLength(size_t length) { |
1218 assert(length <= buffer_length_); | 1173 assert(length <= buffer_length_); |
1219 length_ = length; | 1174 length_ = length; |
1220 } | 1175 } |
1221 | 1176 |
1222 } // namespace rtcp | 1177 } // namespace rtcp |
1223 } // namespace webrtc | 1178 } // namespace webrtc |
OLD | NEW |