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

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

Issue 1544983002: [rtp_rtcp] rtcp::SenderReport moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added SenderReport::ClearReportBlocks to make SenderReport reusable Created 4 years, 11 months 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 size_t* index, 138 size_t* index,
139 size_t max_length, 139 size_t max_length,
140 RtcpPacket::PacketReadyCallback* callback) const override; 140 RtcpPacket::PacketReadyCallback* callback) const override;
141 141
142 size_t BlockLength() const override; 142 size_t BlockLength() const override;
143 143
144 private: 144 private:
145 RTC_DISALLOW_COPY_AND_ASSIGN(Empty); 145 RTC_DISALLOW_COPY_AND_ASSIGN(Empty);
146 }; 146 };
147 147
148 // RTCP sender report (RFC 3550).
149 //
150 // 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
151 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 // |V=2|P| RC | PT=SR=200 | length |
153 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 // | SSRC of sender |
155 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
156 // | NTP timestamp, most significant word |
157 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158 // | NTP timestamp, least significant word |
159 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
160 // | RTP timestamp |
161 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
162 // | sender's packet count |
163 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
164 // | sender's octet count |
165 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
166 // | report block(s) |
167 // | .... |
168
169 class SenderReport : public RtcpPacket {
170 public:
171 SenderReport() : RtcpPacket() {
172 memset(&sr_, 0, sizeof(sr_));
173 }
174
175 virtual ~SenderReport() {}
176
177 void From(uint32_t ssrc) {
178 sr_.SenderSSRC = ssrc;
179 }
180 void WithNtpSec(uint32_t sec) {
181 sr_.NTPMostSignificant = sec;
182 }
183 void WithNtpFrac(uint32_t frac) {
184 sr_.NTPLeastSignificant = frac;
185 }
186 void WithRtpTimestamp(uint32_t rtp_timestamp) {
187 sr_.RTPTimestamp = rtp_timestamp;
188 }
189 void WithPacketCount(uint32_t packet_count) {
190 sr_.SenderPacketCount = packet_count;
191 }
192 void WithOctetCount(uint32_t octet_count) {
193 sr_.SenderOctetCount = octet_count;
194 }
195 bool WithReportBlock(const ReportBlock& block);
196
197 protected:
198 bool Create(uint8_t* packet,
199 size_t* index,
200 size_t max_length,
201 RtcpPacket::PacketReadyCallback* callback) const override;
202
203 private:
204 static const int kMaxNumberOfReportBlocks = 0x1f;
205
206 size_t BlockLength() const {
207 const size_t kSrHeaderLength = 8;
208 const size_t kSenderInfoLength = 20;
209 return kSrHeaderLength + kSenderInfoLength +
210 report_blocks_.size() * kReportBlockLength;
211 }
212
213 RTCPUtility::RTCPPacketSR sr_;
214 std::vector<ReportBlock> report_blocks_;
215
216 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport);
217 };
218
219 // Source Description (SDES) (RFC 3550). 148 // Source Description (SDES) (RFC 3550).
220 // 149 //
221 // 0 1 2 3 150 // 0 1 2 3
222 // 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 151 // 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
223 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 152 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
224 // header |V=2|P| SC | PT=SDES=202 | length | 153 // header |V=2|P| SC | PT=SDES=202 | length |
225 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 154 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
226 // chunk | SSRC/CSRC_1 | 155 // chunk | SSRC/CSRC_1 |
227 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 156 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
228 // | SDES items | 157 // | SDES items |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 596
668 private: 597 private:
669 const size_t buffer_length_; 598 const size_t buffer_length_;
670 size_t length_; 599 size_t length_;
671 rtc::scoped_ptr<uint8_t[]> buffer_; 600 rtc::scoped_ptr<uint8_t[]> buffer_;
672 }; 601 };
673 602
674 } // namespace rtcp 603 } // namespace rtcp
675 } // namespace webrtc 604 } // namespace webrtc
676 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 605 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698