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

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: Merged with 'master' 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 AssignUWord32(buffer, pos, (*it).ssrc); 198 AssignUWord32(buffer, pos, (*it).ssrc);
199 AssignUWord8(buffer, pos, kSdesItemType); 199 AssignUWord8(buffer, pos, kSdesItemType);
200 AssignUWord8(buffer, pos, (*it).name.length()); 200 AssignUWord8(buffer, pos, (*it).name.length());
201 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length()); 201 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length());
202 *pos += (*it).name.length(); 202 *pos += (*it).name.length();
203 memset(buffer + *pos, 0, (*it).null_octets); 203 memset(buffer + *pos, 0, (*it).null_octets);
204 *pos += (*it).null_octets; 204 *pos += (*it).null_octets;
205 } 205 }
206 } 206 }
207 207
208 // Bye packet (BYE) (RFC 3550).
209 //
210 // 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
211 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 // |V=2|P| SC | PT=BYE=203 | length |
213 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 // | SSRC/CSRC |
215 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 // : ... :
217 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
218 // (opt) | length | reason for leaving ...
219 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
220
221 void CreateBye(const RTCPPacketBYE& bye,
222 const std::vector<uint32_t>& csrcs,
223 uint8_t* buffer,
224 size_t* pos) {
225 AssignUWord32(buffer, pos, bye.SenderSSRC);
226 for (uint32_t csrc : csrcs)
227 AssignUWord32(buffer, pos, csrc);
228 }
229
230 // Application-Defined packet (APP) (RFC 3550). 208 // Application-Defined packet (APP) (RFC 3550).
231 // 209 //
232 // 0 1 2 3 210 // 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 211 // 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 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 212 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 // |V=2|P| subtype | PT=APP=204 | length | 213 // |V=2|P| subtype | PT=APP=204 | length |
236 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 214 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
237 // | SSRC/CSRC | 215 // | SSRC/CSRC |
238 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 216 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
239 // | name (ASCII) | 217 // | name (ASCII) |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 // Header (4 bytes). 796 // Header (4 bytes).
819 // Chunk: 797 // Chunk:
820 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding. 798 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding.
821 size_t length = kHeaderLength; 799 size_t length = kHeaderLength;
822 for (const Chunk& chunk : chunks_) 800 for (const Chunk& chunk : chunks_)
823 length += 6 + chunk.name.length() + chunk.null_octets; 801 length += 6 + chunk.name.length() + chunk.null_octets;
824 assert(length % 4 == 0); 802 assert(length % 4 == 0);
825 return length; 803 return length;
826 } 804 }
827 805
828 bool Bye::Create(uint8_t* packet,
829 size_t* index,
830 size_t max_length,
831 RtcpPacket::PacketReadyCallback* callback) const {
832 while (*index + BlockLength() > max_length) {
833 if (!OnBufferFull(packet, index, callback))
834 return false;
835 }
836 size_t length = HeaderLength();
837 CreateHeader(length, PT_BYE, length, packet, index);
838 CreateBye(bye_, csrcs_, packet, index);
839 return true;
840 }
841
842 bool Bye::WithCsrc(uint32_t csrc) {
843 if (csrcs_.size() >= kMaxNumberOfCsrcs) {
844 LOG(LS_WARNING) << "Max CSRC size reached.";
845 return false;
846 }
847 csrcs_.push_back(csrc);
848 return true;
849 }
850
851 bool App::Create(uint8_t* packet, 806 bool App::Create(uint8_t* packet,
852 size_t* index, 807 size_t* index,
853 size_t max_length, 808 size_t max_length,
854 RtcpPacket::PacketReadyCallback* callback) const { 809 RtcpPacket::PacketReadyCallback* callback) const {
855 while (*index + BlockLength() > max_length) { 810 while (*index + BlockLength() > max_length) {
856 if (!OnBufferFull(packet, index, callback)) 811 if (!OnBufferFull(packet, index, callback))
857 return false; 812 return false;
858 } 813 }
859 CreateHeader(app_.SubType, PT_APP, HeaderLength(), packet, index); 814 CreateHeader(app_.SubType, PT_APP, HeaderLength(), packet, index);
860 CreateApp(app_, ssrc_, packet, index); 815 CreateApp(app_, ssrc_, packet, index);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 return length_; 1124 return length_;
1170 } 1125 }
1171 1126
1172 void RawPacket::SetLength(size_t length) { 1127 void RawPacket::SetLength(size_t length) {
1173 assert(length <= buffer_length_); 1128 assert(length <= buffer_length_);
1174 length_ = length; 1129 length_ = length;
1175 } 1130 }
1176 1131
1177 } // namespace rtcp 1132 } // namespace rtcp
1178 } // namespace webrtc 1133 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698