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

Side by Side Diff: media/cast/net/rtcp/rtcp_utility.h

Issue 427733002: Cast: Remove unused RTCP messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | media/cast/net/rtcp/rtcp_utility.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/logging/logging_defines.h" 10 #include "media/cast/logging/logging_defines.h"
11 #include "media/cast/net/rtcp/rtcp_defines.h" 11 #include "media/cast/net/rtcp/rtcp_defines.h"
12 12
13 namespace media { 13 namespace media {
14 namespace cast { 14 namespace cast {
15 15
16 static const int kRtcpRpsiDataSize = 30;
17
18 // RFC 3550 page 44, including end null. 16 // RFC 3550 page 44, including end null.
19 static const size_t kRtcpCnameSize = 256; 17 static const size_t kRtcpCnameSize = 256;
20 static const int kRtcpMaxNumberOfRembFeedbackSsrcs = 255;
21 18
22 static const uint32 kRemb = ('R' << 24) + ('E' << 16) + ('M' << 8) + 'B';
23 static const uint32 kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T'; 19 static const uint32 kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T';
24 20
25 static const uint8 kReceiverLogSubtype = 2; 21 static const uint8 kReceiverLogSubtype = 2;
26 22
27 static const size_t kRtcpMaxReceiverLogMessages = 256; 23 static const size_t kRtcpMaxReceiverLogMessages = 256;
28 static const size_t kRtcpMaxNackFields = 253;
29 static const size_t kRtcpMaxCastLossFields = 100; 24 static const size_t kRtcpMaxCastLossFields = 100;
30 25
31 struct RtcpFieldReceiverReport { 26 struct RtcpFieldReceiverReport {
32 // RFC 3550. 27 // RFC 3550.
33 uint32 sender_ssrc; 28 uint32 sender_ssrc;
34 uint8 number_of_report_blocks; 29 uint8 number_of_report_blocks;
35 }; 30 };
36 31
37 struct RtcpFieldSenderReport { 32 struct RtcpFieldSenderReport {
38 // RFC 3550. 33 // RFC 3550.
(...skipping 10 matching lines...) Expand all
49 // RFC 3550. 44 // RFC 3550.
50 uint32 ssrc; 45 uint32 ssrc;
51 uint8 fraction_lost; 46 uint8 fraction_lost;
52 uint32 cumulative_number_of_packets_lost; 47 uint32 cumulative_number_of_packets_lost;
53 uint32 extended_highest_sequence_number; 48 uint32 extended_highest_sequence_number;
54 uint32 jitter; 49 uint32 jitter;
55 uint32 last_sender_report; 50 uint32 last_sender_report;
56 uint32 delay_last_sender_report; 51 uint32 delay_last_sender_report;
57 }; 52 };
58 53
59 struct RtcpFieldSdesCName {
60 // RFC 3550
61 uint32 sender_ssrc;
62 char name[kRtcpCnameSize];
63 };
64
65 struct RtcpFieldBye {
66 // RFC 3550.
67 uint32 sender_ssrc;
68 };
69
70 struct RtcpFieldGenericRtpFeedbackNack {
71 // RFC 4585.
72 uint32 sender_ssrc;
73 uint32 media_ssrc;
74 };
75
76 struct RtcpFieldGenericRtpFeedbackNackItem {
77 // RFC 4585.
78 uint16 packet_id;
79 uint16 bitmask;
80 };
81
82 struct RtcpFieldPayloadSpecificFir {
83 // RFC 5104.
84 uint32 sender_ssrc;
85 uint32 media_ssrc; // zero!
86 };
87
88 struct RtcpFieldPayloadSpecificFirItem {
89 // RFC 5104.
90 uint32 ssrc;
91 uint8 command_sequence_number;
92 };
93
94 struct RtcpFieldPayloadSpecificPli {
95 // RFC 4585.
96 uint32 sender_ssrc;
97 uint32 media_ssrc;
98 };
99
100 struct RtcpFieldPayloadSpecificRpsi {
101 // RFC 4585.
102 uint32 sender_ssrc;
103 uint32 media_ssrc;
104 uint8 payload_type;
105 uint16 number_of_valid_bits;
106 uint8 native_bit_string[kRtcpRpsiDataSize];
107 };
108
109 struct RtcpFieldXr { 54 struct RtcpFieldXr {
110 // RFC 3611. 55 // RFC 3611.
111 uint32 sender_ssrc; 56 uint32 sender_ssrc;
112 }; 57 };
113 58
114 struct RtcpFieldXrRrtr { 59 struct RtcpFieldXrRrtr {
115 // RFC 3611. 60 // RFC 3611.
116 uint32 ntp_most_significant; 61 uint32 ntp_most_significant;
117 uint32 ntp_least_significant; 62 uint32 ntp_least_significant;
118 }; 63 };
119 64
120 struct RtcpFieldXrDlrr { 65 struct RtcpFieldXrDlrr {
121 // RFC 3611. 66 // RFC 3611.
122 uint32 receivers_ssrc; 67 uint32 receivers_ssrc;
123 uint32 last_receiver_report; 68 uint32 last_receiver_report;
124 uint32 delay_last_receiver_report; 69 uint32 delay_last_receiver_report;
125 }; 70 };
126 71
127 struct RtcpFieldPayloadSpecificApplication { 72 struct RtcpFieldPayloadSpecificApplication {
128 uint32 sender_ssrc; 73 uint32 sender_ssrc;
129 uint32 media_ssrc; 74 uint32 media_ssrc;
130 }; 75 };
131 76
132 struct RtcpFieldPayloadSpecificRembItem {
133 uint32 bitrate;
134 uint8 number_of_ssrcs;
135 uint32 ssrcs[kRtcpMaxNumberOfRembFeedbackSsrcs];
136 };
137
138 struct RtcpFieldPayloadSpecificCastItem { 77 struct RtcpFieldPayloadSpecificCastItem {
139 uint8 last_frame_id; 78 uint8 last_frame_id;
140 uint8 number_of_lost_fields; 79 uint8 number_of_lost_fields;
141 uint16 target_delay_ms; 80 uint16 target_delay_ms;
142 }; 81 };
143 82
144 struct RtcpFieldPayloadSpecificCastNackItem { 83 struct RtcpFieldPayloadSpecificCastNackItem {
145 uint8 frame_id; 84 uint8 frame_id;
146 uint16 packet_id; 85 uint16 packet_id;
147 uint8 bitmask; 86 uint8 bitmask;
148 }; 87 };
149 88
150 struct RtcpFieldApplicationSpecificCastReceiverLogItem { 89 struct RtcpFieldApplicationSpecificCastReceiverLogItem {
151 uint32 sender_ssrc; 90 uint32 sender_ssrc;
152 uint32 rtp_timestamp; 91 uint32 rtp_timestamp;
153 uint32 event_timestamp_base; 92 uint32 event_timestamp_base;
154 uint8 event; 93 uint8 event;
155 union { 94 union {
156 uint16 packet_id; 95 uint16 packet_id;
157 int16 delay_delta; 96 int16 delay_delta;
158 } delay_delta_or_packet_id; 97 } delay_delta_or_packet_id;
159 uint16 event_timestamp_delta; 98 uint16 event_timestamp_delta;
160 }; 99 };
161 100
162 union RtcpField { 101 union RtcpField {
163 RtcpFieldReceiverReport receiver_report; 102 RtcpFieldReceiverReport receiver_report;
164 RtcpFieldSenderReport sender_report; 103 RtcpFieldSenderReport sender_report;
165 RtcpFieldReportBlockItem report_block_item; 104 RtcpFieldReportBlockItem report_block_item;
166 RtcpFieldSdesCName c_name;
167 RtcpFieldBye bye;
168 105
169 RtcpFieldXr extended_report; 106 RtcpFieldXr extended_report;
170 RtcpFieldXrRrtr rrtr; 107 RtcpFieldXrRrtr rrtr;
171 RtcpFieldXrDlrr dlrr; 108 RtcpFieldXrDlrr dlrr;
172 109
173 RtcpFieldGenericRtpFeedbackNack nack;
174 RtcpFieldGenericRtpFeedbackNackItem nack_item;
175
176 RtcpFieldPayloadSpecificPli pli;
177 RtcpFieldPayloadSpecificRpsi rpsi;
178 RtcpFieldPayloadSpecificFir fir;
179 RtcpFieldPayloadSpecificFirItem fir_item;
180 RtcpFieldPayloadSpecificApplication application_specific; 110 RtcpFieldPayloadSpecificApplication application_specific;
181 RtcpFieldPayloadSpecificRembItem remb_item;
182 RtcpFieldPayloadSpecificCastItem cast_item; 111 RtcpFieldPayloadSpecificCastItem cast_item;
183 RtcpFieldPayloadSpecificCastNackItem cast_nack_item; 112 RtcpFieldPayloadSpecificCastNackItem cast_nack_item;
184 113
185 RtcpFieldApplicationSpecificCastReceiverLogItem cast_receiver_log; 114 RtcpFieldApplicationSpecificCastReceiverLogItem cast_receiver_log;
186 }; 115 };
187 116
188 enum RtcpFieldTypes { 117 enum RtcpFieldTypes {
189 kRtcpNotValidCode, 118 kRtcpNotValidCode,
190 119
191 // RFC 3550. 120 // RFC 3550.
192 kRtcpRrCode, 121 kRtcpRrCode,
193 kRtcpSrCode, 122 kRtcpSrCode,
194 kRtcpReportBlockItemCode, 123 kRtcpReportBlockItemCode,
195 kRtcpSdesCode,
196 kRtcpSdesChunkCode,
197 kRtcpByeCode,
198 124
199 // RFC 3611. 125 // RFC 3611.
200 kRtcpXrCode, 126 kRtcpXrCode,
201 kRtcpXrRrtrCode, 127 kRtcpXrRrtrCode,
202 kRtcpXrDlrrCode, 128 kRtcpXrDlrrCode,
203 kRtcpXrUnknownItemCode, 129 kRtcpXrUnknownItemCode,
204 130
205 // RFC 4585. 131 // RFC 4585.
206 kRtcpGenericRtpFeedbackNackCode,
207 kRtcpGenericRtpFeedbackNackItemCode,
208 kRtcpPayloadSpecificPliCode,
209 kRtcpPayloadSpecificRpsiCode,
210 kRtcpPayloadSpecificAppCode, 132 kRtcpPayloadSpecificAppCode,
211 133
212 // Application specific. 134 // Application specific.
213 kRtcpPayloadSpecificRembCode,
214 kRtcpPayloadSpecificRembItemCode,
215 kRtcpPayloadSpecificCastCode, 135 kRtcpPayloadSpecificCastCode,
216 kRtcpPayloadSpecificCastNackItemCode, 136 kRtcpPayloadSpecificCastNackItemCode,
217 kRtcpApplicationSpecificCastReceiverLogCode, 137 kRtcpApplicationSpecificCastReceiverLogCode,
218 kRtcpApplicationSpecificCastReceiverLogFrameCode, 138 kRtcpApplicationSpecificCastReceiverLogFrameCode,
219 kRtcpApplicationSpecificCastReceiverLogEventCode, 139 kRtcpApplicationSpecificCastReceiverLogEventCode,
220
221 // RFC 5104.
222 kRtcpPayloadSpecificFirCode,
223 kRtcpPayloadSpecificFirItemCode,
224
225 // RFC 6051.
226 kRtcpGenericRtpFeedbackSrReqCode,
227 }; 140 };
228 141
229 struct RtcpCommonHeader { 142 struct RtcpCommonHeader {
230 uint8 V; // Version. 143 uint8 V; // Version.
231 bool P; // Padding. 144 bool P; // Padding.
232 uint8 IC; // Item count / subtype. 145 uint8 IC; // Item count / subtype.
233 uint8 PT; // Packet Type. 146 uint8 PT; // Packet Type.
234 uint16 length_in_octets; 147 uint16 length_in_octets;
235 }; 148 };
236 149
237 class RtcpParser { 150 class RtcpParser {
238 public: 151 public:
239 RtcpParser(const uint8* rtcp_data, size_t rtcp_length); 152 RtcpParser(const uint8* rtcp_data, size_t rtcp_length);
240 ~RtcpParser(); 153 ~RtcpParser();
241 154
242 RtcpFieldTypes FieldType() const; 155 RtcpFieldTypes FieldType() const;
243 const RtcpField& Field() const; 156 const RtcpField& Field() const;
244 157
245 bool IsValid() const; 158 bool IsValid() const;
246 159
247 RtcpFieldTypes Begin(); 160 RtcpFieldTypes Begin();
248 RtcpFieldTypes Iterate(); 161 RtcpFieldTypes Iterate();
249 162
250 private: 163 private:
251 enum ParseState { 164 enum ParseState {
252 kStateTopLevel, // Top level packet 165 kStateTopLevel, // Top level packet
253 kStateReportBlock, // Sender/Receiver report report blocks. 166 kStateReportBlock, // Sender/Receiver report report blocks.
254 kStateSdes,
255 kStateBye,
256 kStateApplicationSpecificCastReceiverFrameLog, 167 kStateApplicationSpecificCastReceiverFrameLog,
257 kStateApplicationSpecificCastReceiverEventLog, 168 kStateApplicationSpecificCastReceiverEventLog,
258 kStateExtendedReportBlock, 169 kStateExtendedReportBlock,
259 kStateExtendedReportDelaySinceLastReceiverReport, 170 kStateExtendedReportDelaySinceLastReceiverReport,
260 kStateGenericRtpFeedbackNack,
261 kStatePayloadSpecificRpsi,
262 kStatePayloadSpecificFir,
263 kStatePayloadSpecificApplication, 171 kStatePayloadSpecificApplication,
264 kStatePayloadSpecificRemb, // Application specific Remb.
265 kStatePayloadSpecificCast, // Application specific Cast. 172 kStatePayloadSpecificCast, // Application specific Cast.
266 kStatePayloadSpecificCastNack, // Application specific Nack for Cast. 173 kStatePayloadSpecificCastNack, // Application specific Nack for Cast.
267 }; 174 };
268 175
269 bool RtcpParseCommonHeader(const uint8* begin, 176 bool RtcpParseCommonHeader(const uint8* begin,
270 const uint8* end, 177 const uint8* end,
271 RtcpCommonHeader* parsed_header) const; 178 RtcpCommonHeader* parsed_header) const;
272 179
273 void IterateTopLevel(); 180 void IterateTopLevel();
274 void IterateReportBlockItem(); 181 void IterateReportBlockItem();
275 void IterateSdesItem();
276 void IterateByeItem();
277 void IterateCastReceiverLogFrame(); 182 void IterateCastReceiverLogFrame();
278 void IterateCastReceiverLogEvent(); 183 void IterateCastReceiverLogEvent();
279 void IterateExtendedReportItem(); 184 void IterateExtendedReportItem();
280 void IterateExtendedReportDelaySinceLastReceiverReportItem(); 185 void IterateExtendedReportDelaySinceLastReceiverReportItem();
281 void IterateNackItem();
282 void IterateRpsiItem();
283 void IterateFirItem();
284 void IteratePayloadSpecificAppItem(); 186 void IteratePayloadSpecificAppItem();
285 void IteratePayloadSpecificRembItem();
286 void IteratePayloadSpecificCastItem(); 187 void IteratePayloadSpecificCastItem();
287 void IteratePayloadSpecificCastNackItem(); 188 void IteratePayloadSpecificCastNackItem();
288 189
289 void Validate(); 190 void Validate();
290 void EndCurrentBlock(); 191 void EndCurrentBlock();
291 192
292 bool ParseRR(); 193 bool ParseRR();
293 bool ParseSR(); 194 bool ParseSR();
294 bool ParseReportBlockItem(); 195 bool ParseReportBlockItem();
295 196
296 bool ParseSdes();
297 bool ParseSdesItem();
298 bool ParseSdesTypes();
299 bool ParseBye();
300 bool ParseByeItem();
301 bool ParseApplicationDefined(uint8 subtype); 197 bool ParseApplicationDefined(uint8 subtype);
302 bool ParseCastReceiverLogFrameItem(); 198 bool ParseCastReceiverLogFrameItem();
303 bool ParseCastReceiverLogEventItem(); 199 bool ParseCastReceiverLogEventItem();
304 200
305 bool ParseExtendedReport(); 201 bool ParseExtendedReport();
306 bool ParseExtendedReportItem(); 202 bool ParseExtendedReportItem();
307 bool ParseExtendedReportReceiverReferenceTimeReport(); 203 bool ParseExtendedReportReceiverReferenceTimeReport();
308 bool ParseExtendedReportDelaySinceLastReceiverReport(); 204 bool ParseExtendedReportDelaySinceLastReceiverReport();
309 205
310 bool ParseFeedBackCommon(const RtcpCommonHeader& header); 206 bool ParseFeedBackCommon(const RtcpCommonHeader& header);
311 bool ParseNackItem();
312 bool ParseRpsiItem();
313 bool ParseFirItem();
314 bool ParsePayloadSpecificAppItem(); 207 bool ParsePayloadSpecificAppItem();
315 bool ParsePayloadSpecificRembItem();
316 bool ParsePayloadSpecificCastItem(); 208 bool ParsePayloadSpecificCastItem();
317 bool ParsePayloadSpecificCastNackItem(); 209 bool ParsePayloadSpecificCastNackItem();
318 210
319 private: 211 private:
320 const uint8* const rtcp_data_begin_; 212 const uint8* const rtcp_data_begin_;
321 const uint8* const rtcp_data_end_; 213 const uint8* const rtcp_data_end_;
322 214
323 bool valid_packet_; 215 bool valid_packet_;
324 const uint8* rtcp_data_; 216 const uint8* rtcp_data_;
325 const uint8* rtcp_block_end_; 217 const uint8* rtcp_block_end_;
(...skipping 11 matching lines...) Expand all
337 // wire. Therefore, this function can only return values from 0 to 15. 229 // wire. Therefore, this function can only return values from 0 to 15.
338 uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event); 230 uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event);
339 231
340 // The inverse of |ConvertEventTypeToWireFormat()|. 232 // The inverse of |ConvertEventTypeToWireFormat()|.
341 CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event); 233 CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event);
342 234
343 } // namespace cast 235 } // namespace cast
344 } // namespace media 236 } // namespace media
345 237
346 #endif // MEDIA_CAST_RTCP_RTCP_UTILITY_H_ 238 #endif // MEDIA_CAST_RTCP_RTCP_UTILITY_H_
OLDNEW
« no previous file with comments | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | media/cast/net/rtcp/rtcp_utility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698