Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet.cc

Issue 1430013003: rtcp::Bye packet moved to own file and got a Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 AssignUWord32(buffer, pos, (*it).ssrc); 226 AssignUWord32(buffer, pos, (*it).ssrc);
227 AssignUWord8(buffer, pos, kSdesItemType); 227 AssignUWord8(buffer, pos, kSdesItemType);
228 AssignUWord8(buffer, pos, (*it).name.length()); 228 AssignUWord8(buffer, pos, (*it).name.length());
229 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length()); 229 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length());
230 *pos += (*it).name.length(); 230 *pos += (*it).name.length();
231 memset(buffer + *pos, 0, (*it).null_octets); 231 memset(buffer + *pos, 0, (*it).null_octets);
232 *pos += (*it).null_octets; 232 *pos += (*it).null_octets;
233 } 233 }
234 } 234 }
235 235
236 // Bye packet (BYE) (RFC 3550).
237 //
238 // 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
239 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 // |V=2|P| SC | PT=BYE=203 | length |
241 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 // | SSRC/CSRC |
243 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244 // : ... :
245 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
246 // (opt) | length | reason for leaving ...
247 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248
249 void CreateBye(const RTCPPacketBYE& bye,
250 const std::vector<uint32_t>& csrcs,
251 uint8_t* buffer,
252 size_t* pos) {
253 AssignUWord32(buffer, pos, bye.SenderSSRC);
254 for (uint32_t csrc : csrcs)
255 AssignUWord32(buffer, pos, csrc);
256 }
257
258 // Application-Defined packet (APP) (RFC 3550). 236 // Application-Defined packet (APP) (RFC 3550).
259 // 237 //
260 // 0 1 2 3 238 // 0 1 2 3
261 // 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 239 // 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
262 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 240 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263 // |V=2|P| subtype | PT=APP=204 | length | 241 // |V=2|P| subtype | PT=APP=204 | length |
264 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 242 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 // | SSRC/CSRC | 243 // | SSRC/CSRC |
266 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 244 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
267 // | name (ASCII) | 245 // | name (ASCII) |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 // Header (4 bytes). 847 // Header (4 bytes).
870 // Chunk: 848 // Chunk:
871 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding. 849 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding.
872 size_t length = kHeaderLength; 850 size_t length = kHeaderLength;
873 for (const Chunk& chunk : chunks_) 851 for (const Chunk& chunk : chunks_)
874 length += 6 + chunk.name.length() + chunk.null_octets; 852 length += 6 + chunk.name.length() + chunk.null_octets;
875 assert(length % 4 == 0); 853 assert(length % 4 == 0);
876 return length; 854 return length;
877 } 855 }
878 856
879 bool Bye::Create(uint8_t* packet,
880 size_t* index,
881 size_t max_length,
882 RtcpPacket::PacketReadyCallback* callback) const {
883 while (*index + BlockLength() > max_length) {
884 if (!OnBufferFull(packet, index, callback))
885 return false;
886 }
887 size_t length = HeaderLength();
888 CreateHeader(length, PT_BYE, length, packet, index);
889 CreateBye(bye_, csrcs_, packet, index);
890 return true;
891 }
892
893 bool Bye::WithCsrc(uint32_t csrc) {
894 if (csrcs_.size() >= kMaxNumberOfCsrcs) {
895 LOG(LS_WARNING) << "Max CSRC size reached.";
896 return false;
897 }
898 csrcs_.push_back(csrc);
899 return true;
900 }
901
902 bool App::Create(uint8_t* packet, 857 bool App::Create(uint8_t* packet,
903 size_t* index, 858 size_t* index,
904 size_t max_length, 859 size_t max_length,
905 RtcpPacket::PacketReadyCallback* callback) const { 860 RtcpPacket::PacketReadyCallback* callback) const {
906 while (*index + BlockLength() > max_length) { 861 while (*index + BlockLength() > max_length) {
907 if (!OnBufferFull(packet, index, callback)) 862 if (!OnBufferFull(packet, index, callback))
908 return false; 863 return false;
909 } 864 }
910 CreateHeader(app_.SubType, PT_APP, HeaderLength(), packet, index); 865 CreateHeader(app_.SubType, PT_APP, HeaderLength(), packet, index);
911 CreateApp(app_, ssrc_, packet, index); 866 CreateApp(app_, ssrc_, packet, index);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return length_; 1175 return length_;
1221 } 1176 }
1222 1177
1223 void RawPacket::SetLength(size_t length) { 1178 void RawPacket::SetLength(size_t length) {
1224 assert(length <= buffer_length_); 1179 assert(length <= buffer_length_);
1225 length_ = length; 1180 length_ = length;
1226 } 1181 }
1227 1182
1228 } // namespace rtcp 1183 } // namespace rtcp
1229 } // namespace webrtc 1184 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698