Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CAST_RTCP_RTCP_UTILITY_H_ | 5 #ifndef MEDIA_CAST_RTCP_RTCP_UTILITY_H_ |
| 6 #define MEDIA_CAST_RTCP_RTCP_UTILITY_H_ | 6 #define MEDIA_CAST_RTCP_RTCP_UTILITY_H_ |
| 7 | 7 |
| 8 #include "media/cast/cast_config.h" | 8 #include "media/cast/cast_config.h" |
| 9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
| 10 #include "media/cast/rtcp/rtcp_defines.h" | 10 #include "media/cast/rtcp/rtcp_defines.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 namespace cast { | 13 namespace cast { |
| 14 | 14 |
| 15 static const int kRtcpRpsiDataSize = 30; | 15 static const int kRtcpRpsiDataSize = 30; |
| 16 | 16 |
| 17 // RFC 3550 page 44, including end null. | 17 // RFC 3550 page 44, including end null. |
| 18 static const size_t kRtcpCnameSize = 256; | 18 static const size_t kRtcpCnameSize = 256; |
| 19 static const int kRtcpMaxNumberOfRembFeedbackSsrcs = 255; | 19 static const int kRtcpMaxNumberOfRembFeedbackSsrcs = 255; |
| 20 | 20 |
| 21 static const uint32 kRemb = ('R' << 24) + ('E' << 16) + ('M' << 8) + 'B'; | 21 static const uint32 kRemb = ('R' << 24) + ('E' << 16) + ('M' << 8) + 'B'; |
| 22 static const uint32 kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T'; | 22 static const uint32 kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T'; |
| 23 | 23 |
| 24 static const uint8 kSenderLogSubtype = 1; | |
| 25 static const uint8 kReceiverLogSubtype = 2; | |
| 26 | |
| 27 static const size_t kRtcpMaxReceiverLogMessages = 256; | |
| 28 static const size_t kRtcpMaxNackFields = 253; | |
| 29 static const size_t kRtcpMaxCastLossFields = 100; | |
| 30 | |
| 24 struct RtcpFieldReceiverReport { | 31 struct RtcpFieldReceiverReport { |
| 25 // RFC 3550. | 32 // RFC 3550. |
| 26 uint32 sender_ssrc; | 33 uint32 sender_ssrc; |
| 27 uint8 number_of_report_blocks; | 34 uint8 number_of_report_blocks; |
| 28 }; | 35 }; |
| 29 | 36 |
| 30 struct RtcpFieldSenderReport { | 37 struct RtcpFieldSenderReport { |
| 31 // RFC 3550. | 38 // RFC 3550. |
| 32 uint32 sender_ssrc; | 39 uint32 sender_ssrc; |
| 33 uint8 number_of_report_blocks; | 40 uint8 number_of_report_blocks; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 uint8 last_frame_id; | 139 uint8 last_frame_id; |
| 133 uint8 number_of_lost_fields; | 140 uint8 number_of_lost_fields; |
| 134 }; | 141 }; |
| 135 | 142 |
| 136 struct RtcpFieldPayloadSpecificCastNackItem { | 143 struct RtcpFieldPayloadSpecificCastNackItem { |
| 137 uint8 frame_id; | 144 uint8 frame_id; |
| 138 uint16 packet_id; | 145 uint16 packet_id; |
| 139 uint8 bitmask; | 146 uint8 bitmask; |
| 140 }; | 147 }; |
| 141 | 148 |
| 149 struct RtcpFieldApplicationSpecificCastReceiverLogItem { | |
| 150 uint32 sender_ssrc; | |
| 151 uint32 rtp_timestamp; | |
| 152 uint32 event_timestamp_base; | |
| 153 uint8 event; | |
| 154 uint16 delay_delta_or_packet_id; | |
| 155 uint16 event_timestamp_delta; | |
| 156 }; | |
| 157 | |
| 158 struct RtcpFieldApplicationSpecificCastSenderLogItem { | |
| 159 uint32 sender_ssrc; | |
| 160 uint8 status; | |
| 161 uint32 rtp_timestamp; | |
| 162 }; | |
| 163 | |
| 142 union RtcpField { | 164 union RtcpField { |
| 143 RtcpFieldReceiverReport receiver_report; | 165 RtcpFieldReceiverReport receiver_report; |
| 144 RtcpFieldSenderReport sender_report; | 166 RtcpFieldSenderReport sender_report; |
| 145 RtcpFieldReportBlockItem report_block_item; | 167 RtcpFieldReportBlockItem report_block_item; |
| 146 RtcpFieldSdesCName c_name; | 168 RtcpFieldSdesCName c_name; |
| 147 RtcpFieldBye bye; | 169 RtcpFieldBye bye; |
| 148 | 170 |
| 149 RtcpFieldXr extended_report; | 171 RtcpFieldXr extended_report; |
| 150 RtcpFieldXrRrtr rrtr; | 172 RtcpFieldXrRrtr rrtr; |
| 151 RtcpFieldXrDlrr dlrr; | 173 RtcpFieldXrDlrr dlrr; |
| 152 | 174 |
| 153 RtcpFieldGenericRtpFeedbackNack nack; | 175 RtcpFieldGenericRtpFeedbackNack nack; |
| 154 RtcpFieldGenericRtpFeedbackNackItem nack_item; | 176 RtcpFieldGenericRtpFeedbackNackItem nack_item; |
| 155 | 177 |
| 156 RtcpFieldPayloadSpecificPli pli; | 178 RtcpFieldPayloadSpecificPli pli; |
| 157 RtcpFieldPayloadSpecificRpsi rpsi; | 179 RtcpFieldPayloadSpecificRpsi rpsi; |
| 158 RtcpFieldPayloadSpecificFir fir; | 180 RtcpFieldPayloadSpecificFir fir; |
| 159 RtcpFieldPayloadSpecificFirItem fir_item; | 181 RtcpFieldPayloadSpecificFirItem fir_item; |
| 160 RtcpFieldPayloadSpecificApplication application_specific; | 182 RtcpFieldPayloadSpecificApplication application_specific; |
| 161 RtcpFieldPayloadSpecificRembItem remb_item; | 183 RtcpFieldPayloadSpecificRembItem remb_item; |
| 162 RtcpFieldPayloadSpecificCastItem cast_item; | 184 RtcpFieldPayloadSpecificCastItem cast_item; |
| 163 RtcpFieldPayloadSpecificCastNackItem cast_nack_item; | 185 RtcpFieldPayloadSpecificCastNackItem cast_nack_item; |
| 186 | |
| 187 RtcpFieldApplicationSpecificCastReceiverLogItem cast_receiver_log; | |
| 188 RtcpFieldApplicationSpecificCastSenderLogItem cast_sender_log; | |
| 164 }; | 189 }; |
| 165 | 190 |
| 166 enum RtcpFieldTypes { | 191 enum RtcpFieldTypes { |
| 167 kRtcpNotValidCode, | 192 kRtcpNotValidCode, |
| 168 | 193 |
| 169 // RFC 3550. | 194 // RFC 3550. |
| 170 kRtcpRrCode, | 195 kRtcpRrCode, |
| 171 kRtcpSrCode, | 196 kRtcpSrCode, |
| 172 kRtcpReportBlockItemCode, | 197 kRtcpReportBlockItemCode, |
| 173 | 198 |
| 174 kRtcpSdesCode, | 199 kRtcpSdesCode, |
| 175 kRtcpSdesChunkCode, | 200 kRtcpSdesChunkCode, |
| 176 kRtcpByeCode, | 201 kRtcpByeCode, |
| 177 | 202 |
| 178 // RFC 3611. | 203 // RFC 3611. |
| 179 kRtcpXrCode, | 204 kRtcpXrCode, |
| 180 kRtcpXrRrtrCode, | 205 kRtcpXrRrtrCode, |
| 181 kRtcpXrDlrrCode, | 206 kRtcpXrDlrrCode, |
| 182 kRtcpXrUnknownItemCode, | 207 kRtcpXrUnknownItemCode, |
| 183 | 208 |
| 184 // RFC 4585. | 209 // RFC 4585. |
| 185 kRtcpGenericRtpFeedbackNackCode, | 210 kRtcpGenericRtpFeedbackNackCode, |
| 186 kRtcpGenericRtpFeedbackNackItemCode, | 211 kRtcpGenericRtpFeedbackNackItemCode, |
| 187 | 212 |
| 188 kRtcpPayloadSpecificPliCode, | 213 kRtcpPayloadSpecificPliCode, |
| 189 kRtcpPayloadSpecificRpsiCode, | 214 kRtcpPayloadSpecificRpsiCode, |
| 190 kRtcpPayloadSpecificAppCode, | 215 kRtcpPayloadSpecificAppCode, |
| 191 | 216 |
| 217 // Application specific . | |
|
mikhal
2013/11/22 21:33:18
move .
pwestin
2013/11/22 22:50:33
Done.
| |
| 192 kRtcpPayloadSpecificRembCode, | 218 kRtcpPayloadSpecificRembCode, |
| 193 kRtcpPayloadSpecificRembItemCode, | 219 kRtcpPayloadSpecificRembItemCode, |
| 194 kRtcpPayloadSpecificCastCode, | 220 kRtcpPayloadSpecificCastCode, |
| 195 kRtcpPayloadSpecificCastNackItemCode, | 221 kRtcpPayloadSpecificCastNackItemCode, |
| 222 kRtcpApplicationSpecificCastReceiverLogCode, | |
| 223 kRtcpApplicationSpecificCastReceiverLogFrameCode, | |
| 224 kRtcpApplicationSpecificCastReceiverLogEventCode, | |
| 225 kRtcpApplicationSpecificCastSenderLogCode, | |
| 196 | 226 |
| 197 // RFC 5104. | 227 // RFC 5104. |
| 198 kRtcpPayloadSpecificFirCode, | 228 kRtcpPayloadSpecificFirCode, |
| 199 kRtcpPayloadSpecificFirItemCode, | 229 kRtcpPayloadSpecificFirItemCode, |
| 200 | 230 |
| 201 // RFC 6051. | 231 // RFC 6051. |
| 202 kRtcpGenericRtpFeedbackSrReqCode, | 232 kRtcpGenericRtpFeedbackSrReqCode, |
| 203 }; | 233 }; |
| 204 | 234 |
| 205 struct RtcpCommonHeader { | 235 struct RtcpCommonHeader { |
| 206 uint8 V; // Version. | 236 uint8 V; // Version. |
| 207 bool P; // Padding. | 237 bool P; // Padding. |
| 208 uint8 IC; // Item count / subtype. | 238 uint8 IC; // Item count / subtype. |
| 209 uint8 PT; // Packet Type. | 239 uint8 PT; // Packet Type. |
| 210 uint16 length_in_octets; | 240 uint16 length_in_octets; |
| 211 }; | 241 }; |
| 212 | 242 |
| 213 enum RtcpPacketTypes { | 243 enum RtcpPacketTypes { |
| 214 kPacketTypeLow = 194, // SMPTE time-code mapping. | 244 kPacketTypeLow = 194, // SMPTE time-code mapping. |
| 215 kPacketTypeInterArrivalJitterReport = 195, | 245 kPacketTypeInterArrivalJitterReport = 195, |
| 216 kPacketTypeSenderReport = 200, | 246 kPacketTypeSenderReport = 200, |
| 217 kPacketTypeReceiverReport = 201, | 247 kPacketTypeReceiverReport = 201, |
| 218 kPacketTypeSdes= 202, | 248 kPacketTypeSdes = 202, |
| 219 kPacketTypeBye = 203, | 249 kPacketTypeBye = 203, |
| 220 kPacketTypeApplicationDefined = 204, | 250 kPacketTypeApplicationDefined = 204, |
| 221 kPacketTypeGenericRtpFeedback = 205, | 251 kPacketTypeGenericRtpFeedback = 205, |
| 222 kPacketTypePayloadSpecific = 206, | 252 kPacketTypePayloadSpecific = 206, |
| 223 kPacketTypeXr = 207, | 253 kPacketTypeXr = 207, |
| 224 kPacketTypeHigh = 210, // Port Mapping. | 254 kPacketTypeHigh = 210, // Port Mapping. |
| 225 }; | 255 }; |
| 226 | 256 |
| 227 class RtcpParser { | 257 class RtcpParser { |
| 228 public: | 258 public: |
| 229 RtcpParser(const uint8* rtcp_data, size_t rtcp_length); | 259 RtcpParser(const uint8* rtcp_data, size_t rtcp_length); |
| 230 ~RtcpParser(); | 260 ~RtcpParser(); |
| 231 | 261 |
| 232 RtcpFieldTypes FieldType() const; | 262 RtcpFieldTypes FieldType() const; |
| 233 const RtcpField& Field() const; | 263 const RtcpField& Field() const; |
| 234 | 264 |
| 235 bool IsValid() const; | 265 bool IsValid() const; |
| 236 | 266 |
| 237 RtcpFieldTypes Begin(); | 267 RtcpFieldTypes Begin(); |
| 238 RtcpFieldTypes Iterate(); | 268 RtcpFieldTypes Iterate(); |
| 239 | 269 |
| 240 private: | 270 private: |
| 241 enum ParseState { | 271 enum ParseState { |
| 242 kStateTopLevel, // Top level packet | 272 kStateTopLevel, // Top level packet |
| 243 kStateReportBlock, // Sender/Receiver report report blocks. | 273 kStateReportBlock, // Sender/Receiver report report blocks. |
| 244 kStateSdes, | 274 kStateSdes, |
| 245 kStateBye, | 275 kStateBye, |
| 276 kStateApplicationSpecificCastReceiverFrameLog, | |
| 277 kStateApplicationSpecificCastReceiverEventLog, | |
| 278 kStateApplicationSpecificCastSenderLog, | |
| 246 kStateExtendedReportBlock, | 279 kStateExtendedReportBlock, |
| 247 kStateExtendedReportDelaySinceLastReceiverReport, | 280 kStateExtendedReportDelaySinceLastReceiverReport, |
| 248 kStateGenericRtpFeedbackNack, | 281 kStateGenericRtpFeedbackNack, |
| 249 kStatePayloadSpecificRpsi, | 282 kStatePayloadSpecificRpsi, |
| 250 kStatePayloadSpecificFir, | 283 kStatePayloadSpecificFir, |
| 251 kStatePayloadSpecificApplication, | 284 kStatePayloadSpecificApplication, |
| 252 kStatePayloadSpecificRemb, // Application specific Remb. | 285 kStatePayloadSpecificRemb, // Application specific Remb. |
| 253 kStatePayloadSpecificCast, // Application specific Cast. | 286 kStatePayloadSpecificCast, // Application specific Cast. |
| 254 kStatePayloadSpecificCastNack, // Application specific Nack for Cast. | 287 kStatePayloadSpecificCastNack, // Application specific Nack for Cast. |
| 255 }; | 288 }; |
| 256 | 289 |
| 257 bool RtcpParseCommonHeader(const uint8* begin, | 290 bool RtcpParseCommonHeader(const uint8* begin, |
| 258 const uint8* end, | 291 const uint8* end, |
| 259 RtcpCommonHeader* parsed_header) const; | 292 RtcpCommonHeader* parsed_header) const; |
| 260 | 293 |
| 261 void IterateTopLevel(); | 294 void IterateTopLevel(); |
| 262 void IterateReportBlockItem(); | 295 void IterateReportBlockItem(); |
| 263 void IterateSdesItem(); | 296 void IterateSdesItem(); |
| 264 void IterateByeItem(); | 297 void IterateByeItem(); |
| 298 void IterateCastReceiverLogFrame(); | |
| 299 void IterateCastReceiverLogEvent(); | |
| 300 void IterateCastSenderLog(); | |
| 265 void IterateExtendedReportItem(); | 301 void IterateExtendedReportItem(); |
| 266 void IterateExtendedReportDelaySinceLastReceiverReportItem(); | 302 void IterateExtendedReportDelaySinceLastReceiverReportItem(); |
| 267 void IterateNackItem(); | 303 void IterateNackItem(); |
| 268 void IterateRpsiItem(); | 304 void IterateRpsiItem(); |
| 269 void IterateFirItem(); | 305 void IterateFirItem(); |
| 270 void IteratePayloadSpecificAppItem(); | 306 void IteratePayloadSpecificAppItem(); |
| 271 void IteratePayloadSpecificRembItem(); | 307 void IteratePayloadSpecificRembItem(); |
| 272 void IteratePayloadSpecificCastItem(); | 308 void IteratePayloadSpecificCastItem(); |
| 273 void IteratePayloadSpecificCastNackItem(); | 309 void IteratePayloadSpecificCastNackItem(); |
| 274 | 310 |
| 275 void Validate(); | 311 void Validate(); |
| 276 void EndCurrentBlock(); | 312 void EndCurrentBlock(); |
| 277 | 313 |
| 278 bool ParseRR(); | 314 bool ParseRR(); |
| 279 bool ParseSR(); | 315 bool ParseSR(); |
| 280 bool ParseReportBlockItem(); | 316 bool ParseReportBlockItem(); |
| 281 | 317 |
| 282 bool ParseSdes(); | 318 bool ParseSdes(); |
| 283 bool ParseSdesItem(); | 319 bool ParseSdesItem(); |
| 284 bool ParseSdesTypes(); | 320 bool ParseSdesTypes(); |
| 285 bool ParseBye(); | 321 bool ParseBye(); |
| 286 bool ParseByeItem(); | 322 bool ParseByeItem(); |
| 323 bool ParseApplicationDefined(uint8 subtype); | |
| 324 bool ParseCastReceiverLogFrameItem(); | |
| 325 bool ParseCastReceiverLogEventItem(); | |
| 326 bool ParseCastSenderLogItem(); | |
| 287 | 327 |
| 288 bool ParseExtendedReport(); | 328 bool ParseExtendedReport(); |
| 289 bool ParseExtendedReportItem(); | 329 bool ParseExtendedReportItem(); |
| 290 bool ParseExtendedReportReceiverReferenceTimeReport(); | 330 bool ParseExtendedReportReceiverReferenceTimeReport(); |
| 291 bool ParseExtendedReportDelaySinceLastReceiverReport(); | 331 bool ParseExtendedReportDelaySinceLastReceiverReport(); |
| 292 | 332 |
| 293 bool ParseFeedBackCommon(const RtcpCommonHeader& header); | 333 bool ParseFeedBackCommon(const RtcpCommonHeader& header); |
| 294 bool ParseNackItem(); | 334 bool ParseNackItem(); |
| 295 bool ParseRpsiItem(); | 335 bool ParseRpsiItem(); |
| 296 bool ParseFirItem(); | 336 bool ParseFirItem(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 312 RtcpFieldTypes field_type_; | 352 RtcpFieldTypes field_type_; |
| 313 RtcpField field_; | 353 RtcpField field_; |
| 314 | 354 |
| 315 DISALLOW_COPY_AND_ASSIGN(RtcpParser); | 355 DISALLOW_COPY_AND_ASSIGN(RtcpParser); |
| 316 }; | 356 }; |
| 317 | 357 |
| 318 } // namespace cast | 358 } // namespace cast |
| 319 } // namespace media | 359 } // namespace media |
| 320 | 360 |
| 321 #endif // MEDIA_CAST_RTCP_RTCP_UTILITY_H_ | 361 #endif // MEDIA_CAST_RTCP_RTCP_UTILITY_H_ |
| OLD | NEW |