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 */ |
11 | 11 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 12 #ifndef WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 13 #define WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
14 | 14 |
15 #include <map> | 15 #include <map> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
22 #include "webrtc/typedefs.h" | 22 #include "webrtc/typedefs.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" | |
åsapersson
2015/11/12 14:26:25
nit: alphabetic order
danilchap
2015/11/12 15:30:45
Done.
| |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace rtcp { | 26 namespace rtcp { |
26 | 27 |
27 static const int kCommonFbFmtLength = 12; | 28 static const int kCommonFbFmtLength = 12; |
28 static const int kReportBlockLength = 24; | 29 static const int kReportBlockLength = 24; |
29 | 30 |
30 class Dlrr; | 31 class Dlrr; |
31 class RawPacket; | 32 class RawPacket; |
32 class Rrtr; | 33 class Rrtr; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 size_t* index, | 139 size_t* index, |
139 size_t max_length, | 140 size_t max_length, |
140 RtcpPacket::PacketReadyCallback* callback) const override; | 141 RtcpPacket::PacketReadyCallback* callback) const override; |
141 | 142 |
142 size_t BlockLength() const override; | 143 size_t BlockLength() const override; |
143 | 144 |
144 private: | 145 private: |
145 RTC_DISALLOW_COPY_AND_ASSIGN(Empty); | 146 RTC_DISALLOW_COPY_AND_ASSIGN(Empty); |
146 }; | 147 }; |
147 | 148 |
148 // From RFC 3550, RTP: A Transport Protocol for Real-Time Applications. | |
149 // | |
150 // RTCP report block (RFC 3550). | |
151 // | |
152 // 0 1 2 3 | |
153 // 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 | |
154 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
155 // | SSRC_1 (SSRC of first source) | | |
156 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
157 // | fraction lost | cumulative number of packets lost | | |
158 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
159 // | extended highest sequence number received | | |
160 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
161 // | interarrival jitter | | |
162 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
163 // | last SR (LSR) | | |
164 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
165 // | delay since last SR (DLSR) | | |
166 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
167 | |
168 class ReportBlock { | |
169 public: | |
170 ReportBlock() { | |
171 // TODO(asapersson): Consider adding a constructor to struct. | |
172 memset(&report_block_, 0, sizeof(report_block_)); | |
173 } | |
174 | |
175 ~ReportBlock() {} | |
176 | |
177 void To(uint32_t ssrc) { | |
178 report_block_.SSRC = ssrc; | |
179 } | |
180 void WithFractionLost(uint8_t fraction_lost) { | |
181 report_block_.FractionLost = fraction_lost; | |
182 } | |
183 void WithCumulativeLost(uint32_t cumulative_lost) { | |
184 report_block_.CumulativeNumOfPacketsLost = cumulative_lost; | |
185 } | |
186 void WithExtHighestSeqNum(uint32_t ext_highest_seq_num) { | |
187 report_block_.ExtendedHighestSequenceNumber = ext_highest_seq_num; | |
188 } | |
189 void WithJitter(uint32_t jitter) { | |
190 report_block_.Jitter = jitter; | |
191 } | |
192 void WithLastSr(uint32_t last_sr) { | |
193 report_block_.LastSR = last_sr; | |
194 } | |
195 void WithDelayLastSr(uint32_t delay_last_sr) { | |
196 report_block_.DelayLastSR = delay_last_sr; | |
197 } | |
198 | |
199 private: | |
200 friend class SenderReport; | |
201 friend class ReceiverReport; | |
202 RTCPUtility::RTCPPacketReportBlockItem report_block_; | |
203 }; | |
204 | |
205 // RTCP sender report (RFC 3550). | 149 // RTCP sender report (RFC 3550). |
206 // | 150 // |
207 // 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 |
208 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 152 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
209 // |V=2|P| RC | PT=SR=200 | length | | 153 // |V=2|P| RC | PT=SR=200 | length | |
210 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 154 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
211 // | SSRC of sender | | 155 // | SSRC of sender | |
212 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 156 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
213 // | NTP timestamp, most significant word | | 157 // | NTP timestamp, most significant word | |
214 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 158 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 static const int kMaxNumberOfReportBlocks = 0x1f; | 205 static const int kMaxNumberOfReportBlocks = 0x1f; |
262 | 206 |
263 size_t BlockLength() const { | 207 size_t BlockLength() const { |
264 const size_t kSrHeaderLength = 8; | 208 const size_t kSrHeaderLength = 8; |
265 const size_t kSenderInfoLength = 20; | 209 const size_t kSenderInfoLength = 20; |
266 return kSrHeaderLength + kSenderInfoLength + | 210 return kSrHeaderLength + kSenderInfoLength + |
267 report_blocks_.size() * kReportBlockLength; | 211 report_blocks_.size() * kReportBlockLength; |
268 } | 212 } |
269 | 213 |
270 RTCPUtility::RTCPPacketSR sr_; | 214 RTCPUtility::RTCPPacketSR sr_; |
271 std::vector<RTCPUtility::RTCPPacketReportBlockItem> report_blocks_; | 215 std::vector<ReportBlock> report_blocks_; |
272 | 216 |
273 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport); | 217 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport); |
274 }; | 218 }; |
275 | 219 |
276 // | 220 // |
277 // RTCP receiver report (RFC 3550). | 221 // RTCP receiver report (RFC 3550). |
278 // | 222 // |
279 // 0 1 2 3 | 223 // 0 1 2 3 |
280 // 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 | 224 // 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 |
281 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 225 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
(...skipping 25 matching lines...) Expand all Loading... | |
307 | 251 |
308 private: | 252 private: |
309 static const int kMaxNumberOfReportBlocks = 0x1F; | 253 static const int kMaxNumberOfReportBlocks = 0x1F; |
310 | 254 |
311 size_t BlockLength() const { | 255 size_t BlockLength() const { |
312 const size_t kRrHeaderLength = 8; | 256 const size_t kRrHeaderLength = 8; |
313 return kRrHeaderLength + report_blocks_.size() * kReportBlockLength; | 257 return kRrHeaderLength + report_blocks_.size() * kReportBlockLength; |
314 } | 258 } |
315 | 259 |
316 RTCPUtility::RTCPPacketRR rr_; | 260 RTCPUtility::RTCPPacketRR rr_; |
317 std::vector<RTCPUtility::RTCPPacketReportBlockItem> report_blocks_; | 261 std::vector<ReportBlock> report_blocks_; |
318 | 262 |
319 RTC_DISALLOW_COPY_AND_ASSIGN(ReceiverReport); | 263 RTC_DISALLOW_COPY_AND_ASSIGN(ReceiverReport); |
320 }; | 264 }; |
321 | 265 |
322 // Transmission Time Offsets in RTP Streams (RFC 5450). | 266 // Transmission Time Offsets in RTP Streams (RFC 5450). |
323 // | 267 // |
324 // 0 1 2 3 | 268 // 0 1 2 3 |
325 // 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 | 269 // 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 |
326 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 270 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
327 // hdr |V=2|P| RC | PT=IJ=195 | length | | 271 // hdr |V=2|P| RC | PT=IJ=195 | length | |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1157 | 1101 |
1158 private: | 1102 private: |
1159 const size_t buffer_length_; | 1103 const size_t buffer_length_; |
1160 size_t length_; | 1104 size_t length_; |
1161 rtc::scoped_ptr<uint8_t[]> buffer_; | 1105 rtc::scoped_ptr<uint8_t[]> buffer_; |
1162 }; | 1106 }; |
1163 | 1107 |
1164 } // namespace rtcp | 1108 } // namespace rtcp |
1165 } // namespace webrtc | 1109 } // namespace webrtc |
1166 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 1110 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
OLD | NEW |