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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 void CreateBye(const RTCPPacketBYE& bye, | 221 void CreateBye(const RTCPPacketBYE& bye, |
222 const std::vector<uint32_t>& csrcs, | 222 const std::vector<uint32_t>& csrcs, |
223 uint8_t* buffer, | 223 uint8_t* buffer, |
224 size_t* pos) { | 224 size_t* pos) { |
225 AssignUWord32(buffer, pos, bye.SenderSSRC); | 225 AssignUWord32(buffer, pos, bye.SenderSSRC); |
226 for (uint32_t csrc : csrcs) | 226 for (uint32_t csrc : csrcs) |
227 AssignUWord32(buffer, pos, csrc); | 227 AssignUWord32(buffer, pos, csrc); |
228 } | 228 } |
229 | 229 |
230 // Application-Defined packet (APP) (RFC 3550). | |
231 // | |
232 // 0 1 2 3 | |
233 // 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 | |
234 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
235 // |V=2|P| subtype | PT=APP=204 | length | | |
236 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
237 // | SSRC/CSRC | | |
238 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
239 // | name (ASCII) | | |
240 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
241 // | application-dependent data ... | |
242 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
243 | |
244 void CreateApp(const RTCPPacketAPP& app, | |
245 uint32_t ssrc, | |
246 uint8_t* buffer, | |
247 size_t* pos) { | |
248 AssignUWord32(buffer, pos, ssrc); | |
249 AssignUWord32(buffer, pos, app.Name); | |
250 memcpy(buffer + *pos, app.Data, app.Size); | |
251 *pos += app.Size; | |
252 } | |
253 | |
254 // RFC 4585: Feedback format. | 230 // RFC 4585: Feedback format. |
255 // | 231 // |
256 // Common packet format: | 232 // Common packet format: |
257 // | 233 // |
258 // 0 1 2 3 | 234 // 0 1 2 3 |
259 // 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 | 235 // 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 |
260 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 236 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
261 // |V=2|P| FMT | PT | length | | 237 // |V=2|P| FMT | PT | length | |
262 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 238 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
263 // | SSRC of packet sender | | 239 // | SSRC of packet sender | |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 817 |
842 bool Bye::WithCsrc(uint32_t csrc) { | 818 bool Bye::WithCsrc(uint32_t csrc) { |
843 if (csrcs_.size() >= kMaxNumberOfCsrcs) { | 819 if (csrcs_.size() >= kMaxNumberOfCsrcs) { |
844 LOG(LS_WARNING) << "Max CSRC size reached."; | 820 LOG(LS_WARNING) << "Max CSRC size reached."; |
845 return false; | 821 return false; |
846 } | 822 } |
847 csrcs_.push_back(csrc); | 823 csrcs_.push_back(csrc); |
848 return true; | 824 return true; |
849 } | 825 } |
850 | 826 |
851 bool App::Create(uint8_t* packet, | |
852 size_t* index, | |
853 size_t max_length, | |
854 RtcpPacket::PacketReadyCallback* callback) const { | |
855 while (*index + BlockLength() > max_length) { | |
856 if (!OnBufferFull(packet, index, callback)) | |
857 return false; | |
858 } | |
859 CreateHeader(app_.SubType, PT_APP, HeaderLength(), packet, index); | |
860 CreateApp(app_, ssrc_, packet, index); | |
861 return true; | |
862 } | |
863 | |
864 bool Pli::Create(uint8_t* packet, | 827 bool Pli::Create(uint8_t* packet, |
865 size_t* index, | 828 size_t* index, |
866 size_t max_length, | 829 size_t max_length, |
867 RtcpPacket::PacketReadyCallback* callback) const { | 830 RtcpPacket::PacketReadyCallback* callback) const { |
868 while (*index + BlockLength() > max_length) { | 831 while (*index + BlockLength() > max_length) { |
869 if (!OnBufferFull(packet, index, callback)) | 832 if (!OnBufferFull(packet, index, callback)) |
870 return false; | 833 return false; |
871 } | 834 } |
872 const uint8_t kFmt = 1; | 835 const uint8_t kFmt = 1; |
873 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index); | 836 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 return length_; | 1132 return length_; |
1170 } | 1133 } |
1171 | 1134 |
1172 void RawPacket::SetLength(size_t length) { | 1135 void RawPacket::SetLength(size_t length) { |
1173 assert(length <= buffer_length_); | 1136 assert(length <= buffer_length_); |
1174 length_ = length; | 1137 length_ = length; |
1175 } | 1138 } |
1176 | 1139 |
1177 } // namespace rtcp | 1140 } // namespace rtcp |
1178 } // namespace webrtc | 1141 } // namespace webrtc |
OLD | NEW |