1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/cast/rtcp/rtcp_receiver.h"
#include "base/logging.h"
#include "media/cast/rtcp/rtcp_utility.h"
namespace {
media::cast::CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event) {
switch (event) {
case 1:
return media::cast::kAckSent;
case 2:
return media::cast::kAudioPlayoutDelay;
case 3:
return media::cast::kAudioFrameDecoded;
case 4:
return media::cast::kVideoFrameDecoded;
case 5:
return media::cast::kVideoRenderDelay;
case 6:
return media::cast::kPacketReceived;
default:
// If the sender adds new log messages we will end up here until we add
// the new messages in the receiver.
VLOG(1) << "Unexpected log message received: " << static_cast<int>(event);
NOTREACHED();
return media::cast::kUnknown;
}
}
media::cast::RtcpSenderFrameStatus TranslateToFrameStatusFromWireFormat(
uint8 status) {
switch (status) {
case 0:
return media::cast::kRtcpSenderFrameStatusUnknown;
case 1:
return media::cast::kRtcpSenderFrameStatusDroppedByEncoder;
case 2:
return media::cast::kRtcpSenderFrameStatusDroppedByFlowControl;
case 3:
return media::cast::kRtcpSenderFrameStatusSentToNetwork;
default:
// If the sender adds new log messages we will end up here until we add
// the new messages in the receiver.
NOTREACHED();
VLOG(1) << "Unexpected status received: " << static_cast<int>(status);
return media::cast::kRtcpSenderFrameStatusUnknown;
}
}
} // namespace
namespace media {
namespace cast {
RtcpReceiver::RtcpReceiver(scoped_refptr<CastEnvironment> cast_environment,
RtcpSenderFeedback* sender_feedback,
RtcpReceiverFeedback* receiver_feedback,
RtcpRttFeedback* rtt_feedback,
uint32 local_ssrc)
: ssrc_(local_ssrc),
remote_ssrc_(0),
sender_feedback_(sender_feedback),
receiver_feedback_(receiver_feedback),
rtt_feedback_(rtt_feedback),
cast_environment_(cast_environment) {}
RtcpReceiver::~RtcpReceiver() {}
void RtcpReceiver::SetRemoteSSRC(uint32 ssrc) {
remote_ssrc_ = ssrc;
}
void RtcpReceiver::IncomingRtcpPacket(RtcpParser* rtcp_parser) {
RtcpFieldTypes field_type = rtcp_parser->Begin();
while (field_type != kRtcpNotValidCode) {
// Each "case" is responsible for iterate the parser to the next top
// level packet.
switch (field_type) {
case kRtcpSrCode:
HandleSenderReport(rtcp_parser);
break;
case kRtcpRrCode:
HandleReceiverReport(rtcp_parser);
break;
case kRtcpSdesCode:
HandleSDES(rtcp_parser);
break;
case kRtcpByeCode:
HandleBYE(rtcp_parser);
break;
case kRtcpXrCode:
HandleXr(rtcp_parser);
break;
case kRtcpGenericRtpFeedbackNackCode:
HandleNACK(rtcp_parser);
break;
case kRtcpGenericRtpFeedbackSrReqCode:
HandleSendReportRequest(rtcp_parser);
break;
case kRtcpPayloadSpecificPliCode:
HandlePLI(rtcp_parser);
break;
case kRtcpPayloadSpecificRpsiCode:
HandleRpsi(rtcp_parser);
break;
case kRtcpPayloadSpecificFirCode:
HandleFIR(rtcp_parser);
break;
case kRtcpPayloadSpecificAppCode:
HandlePayloadSpecificApp(rtcp_parser);
break;
case kRtcpApplicationSpecificCastReceiverLogCode:
HandleApplicationSpecificCastReceiverLog(rtcp_parser);
break;
case kRtcpApplicationSpecificCastSenderLogCode:
HandleApplicationSpecificCastSenderLog(rtcp_parser);
break;
case kRtcpPayloadSpecificRembCode:
case kRtcpPayloadSpecificRembItemCode:
case kRtcpPayloadSpecificCastCode:
case kRtcpPayloadSpecificCastNackItemCode:
case kRtcpApplicationSpecificCastReceiverLogFrameCode:
case kRtcpApplicationSpecificCastReceiverLogEventCode:
case kRtcpNotValidCode:
case kRtcpReportBlockItemCode:
case kRtcpSdesChunkCode:
case kRtcpGenericRtpFeedbackNackItemCode:
case kRtcpPayloadSpecificFirItemCode:
case kRtcpXrRrtrCode:
case kRtcpXrDlrrCode:
case kRtcpXrUnknownItemCode:
rtcp_parser->Iterate();
NOTREACHED() << "Invalid state";
break;
}
field_type = rtcp_parser->FieldType();
}
}
void RtcpReceiver::HandleSenderReport(RtcpParser* rtcp_parser) {
RtcpFieldTypes rtcp_field_type = rtcp_parser->FieldType();
const RtcpField& rtcp_field = rtcp_parser->Field();
DCHECK(rtcp_field_type == kRtcpSrCode) << "Invalid state";
// Synchronization source identifier for the originator of this SR packet.
uint32 remote_ssrc = rtcp_field.sender_report.sender_ssrc;
VLOG(1) << "Cast RTCP received SR from SSRC " << remote_ssrc;
if (remote_ssrc_ == remote_ssrc) {
RtcpSenderInfo remote_sender_info;
remote_sender_info.ntp_seconds =
rtcp_field.sender_report.ntp_most_significant;
remote_sender_info.ntp_fraction =
rtcp_field.sender_report.ntp_least_significant;
remote_sender_info.rtp_timestamp =
rtcp_field.sender_report.rtp_timestamp;
remote_sender_info.send_packet_count =
rtcp_field.sender_report.sender_packet_count;
remote_sender_info.send_octet_count =
rtcp_field.sender_report.sender_octet_count;
if (receiver_feedback_) {
receiver_feedback_->OnReceivedSenderReport(remote_sender_info);
}
}
rtcp_field_type = rtcp_parser->Iterate();
while (rtcp_field_type == kRtcpReportBlockItemCode) {
HandleReportBlock(&rtcp_field, remote_ssrc);
rtcp_field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleReceiverReport(RtcpParser* rtcp_parser) {
RtcpFieldTypes rtcp_field_type = rtcp_parser->FieldType();
const RtcpField& rtcp_field = rtcp_parser->Field();
DCHECK(rtcp_field_type == kRtcpRrCode) << "Invalid state";
uint32 remote_ssrc = rtcp_field.receiver_report.sender_ssrc;
VLOG(1) << "Cast RTCP received RR from SSRC " << remote_ssrc;
rtcp_field_type = rtcp_parser->Iterate();
while (rtcp_field_type == kRtcpReportBlockItemCode) {
HandleReportBlock(&rtcp_field, remote_ssrc);
rtcp_field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleReportBlock(const RtcpField* rtcp_field,
uint32 remote_ssrc) {
// This will be called once per report block in the Rtcp packet.
// We filter out all report blocks that are not for us.
// Each packet has max 31 RR blocks.
//
// We can calculate RTT if we send a send report and get a report block back.
// |rtcp_field.ReportBlockItem.ssrc| is the ssrc identifier of the source to
// which the information in this reception report block pertains.
const RtcpFieldReportBlockItem& rb = rtcp_field->report_block_item;
// Filter out all report blocks that are not for us.
if (rb.ssrc != ssrc_) {
// This block is not for us ignore it.
return;
}
VLOG(1) << "Cast RTCP received RB from SSRC " << remote_ssrc;
base::TimeTicks now = cast_environment_->Clock()->NowTicks();
cast_environment_->Logging()->InsertGenericEvent(now, kPacketLoss,
rb.fraction_lost);
cast_environment_->Logging()->InsertGenericEvent(now, kJitterMs,
rb.jitter);
RtcpReportBlock report_block;
report_block.remote_ssrc = remote_ssrc;
report_block.media_ssrc = rb.ssrc;
report_block.fraction_lost = rb.fraction_lost;
report_block.cumulative_lost = rb.cumulative_number_of_packets_lost;
report_block.extended_high_sequence_number =
rb.extended_highest_sequence_number;
report_block.jitter = rb.jitter;
report_block.last_sr = rb.last_sender_report;
report_block.delay_since_last_sr = rb.delay_last_sender_report;
if (rtt_feedback_) {
rtt_feedback_->OnReceivedDelaySinceLastReport(rb.ssrc,
rb.last_sender_report,
rb.delay_last_sender_report);
}
}
void RtcpReceiver::HandleSDES(RtcpParser* rtcp_parser) {
RtcpFieldTypes field_type = rtcp_parser->Iterate();
while (field_type == kRtcpSdesChunkCode) {
HandleSDESChunk(rtcp_parser);
field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleSDESChunk(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
VLOG(1) << "Cast RTCP received SDES with cname " << rtcp_field.c_name.name;
}
void RtcpReceiver::HandleXr(RtcpParser* rtcp_parser) {
RtcpFieldTypes rtcp_field_type = rtcp_parser->FieldType();
const RtcpField& rtcp_field = rtcp_parser->Field();
DCHECK(rtcp_field_type == kRtcpXrCode) << "Invalid state";
uint32 remote_ssrc = rtcp_field.extended_report.sender_ssrc;
rtcp_field_type = rtcp_parser->Iterate();
while (rtcp_field_type == kRtcpXrDlrrCode ||
rtcp_field_type == kRtcpXrRrtrCode ||
rtcp_field_type == kRtcpXrUnknownItemCode) {
if (rtcp_field_type == kRtcpXrRrtrCode) {
HandleRrtr(rtcp_parser, remote_ssrc);
} else if (rtcp_field_type == kRtcpXrDlrrCode) {
HandleDlrr(rtcp_parser);
}
rtcp_field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleRrtr(RtcpParser* rtcp_parser, uint32 remote_ssrc) {
if (remote_ssrc_ != remote_ssrc) {
// Not to us.
return;
}
const RtcpField& rtcp_field = rtcp_parser->Field();
RtcpReceiverReferenceTimeReport remote_time_report;
remote_time_report.remote_ssrc = remote_ssrc;
remote_time_report.ntp_seconds = rtcp_field.rrtr.ntp_most_significant;
remote_time_report.ntp_fraction = rtcp_field.rrtr.ntp_least_significant;
if (receiver_feedback_) {
receiver_feedback_->OnReceiverReferenceTimeReport(remote_time_report);
}
}
void RtcpReceiver::HandleDlrr(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
if (remote_ssrc_ != rtcp_field.dlrr.receivers_ssrc) {
// Not to us.
return;
}
if (rtt_feedback_) {
rtt_feedback_->OnReceivedDelaySinceLastReport(
rtcp_field.dlrr.receivers_ssrc,
rtcp_field.dlrr.last_receiver_report,
rtcp_field.dlrr.delay_last_receiver_report);
}
}
void RtcpReceiver::HandleNACK(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
if (ssrc_ != rtcp_field.nack.media_ssrc) {
RtcpFieldTypes field_type;
// Message not to us. Iterate until we have passed this message.
do {
field_type = rtcp_parser->Iterate();
} while (field_type == kRtcpGenericRtpFeedbackNackItemCode);
return;
}
std::list<uint16> nackSequenceNumbers;
RtcpFieldTypes field_type = rtcp_parser->Iterate();
while (field_type == kRtcpGenericRtpFeedbackNackItemCode) {
HandleNACKItem(&rtcp_field, &nackSequenceNumbers);
field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleNACKItem(const RtcpField* rtcp_field,
std::list<uint16>* nack_sequence_numbers) {
nack_sequence_numbers->push_back(rtcp_field->nack_item.packet_id);
uint16 bitmask = rtcp_field->nack_item.bitmask;
if (bitmask) {
for (int i = 1; i <= 16; ++i) {
if (bitmask & 1) {
nack_sequence_numbers->push_back(rtcp_field->nack_item.packet_id + i);
}
bitmask = bitmask >> 1;
}
}
}
void RtcpReceiver::HandleBYE(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
uint32 remote_ssrc = rtcp_field.bye.sender_ssrc;
if (remote_ssrc_ == remote_ssrc) {
VLOG(1) << "Cast RTCP received BYE from SSRC " << remote_ssrc;
}
rtcp_parser->Iterate();
}
void RtcpReceiver::HandlePLI(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
if (ssrc_ == rtcp_field.pli.media_ssrc) {
// Received a signal that we need to send a new key frame.
VLOG(1) << "Cast RTCP received PLI on our SSRC " << ssrc_;
}
rtcp_parser->Iterate();
}
void RtcpReceiver::HandleSendReportRequest(RtcpParser* rtcp_parser) {
if (receiver_feedback_) {
receiver_feedback_->OnReceivedSendReportRequest();
}
rtcp_parser->Iterate();
}
void RtcpReceiver::HandleRpsi(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
if (rtcp_parser->Iterate() != kRtcpPayloadSpecificRpsiCode) {
return;
}
if (rtcp_field.rpsi.number_of_valid_bits % 8 != 0) {
// Continue
return;
}
uint64 rpsi_picture_id = 0;
// Convert native_bit_string to rpsi_picture_id
uint8 bytes = rtcp_field.rpsi.number_of_valid_bits / 8;
for (uint8 n = 0; n < (bytes - 1); ++n) {
rpsi_picture_id += (rtcp_field.rpsi.native_bit_string[n] & 0x7f);
rpsi_picture_id <<= 7; // Prepare next.
}
rpsi_picture_id += (rtcp_field.rpsi.native_bit_string[bytes - 1] & 0x7f);
VLOG(1) << "Cast RTCP received RPSI with picture_id " << rpsi_picture_id;
}
void RtcpReceiver::HandlePayloadSpecificApp(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
uint32 remote_ssrc = rtcp_field.application_specific.sender_ssrc;
if (remote_ssrc_ != remote_ssrc) {
// Message not to us. Iterate until we have passed this message.
RtcpFieldTypes field_type;
do {
field_type = rtcp_parser->Iterate();
} while (field_type == kRtcpPayloadSpecificRembCode ||
field_type == kRtcpPayloadSpecificRembItemCode ||
field_type == kRtcpPayloadSpecificCastCode ||
field_type == kRtcpPayloadSpecificCastNackItemCode);
return;
}
RtcpFieldTypes packet_type = rtcp_parser->Iterate();
switch (packet_type) {
case kRtcpPayloadSpecificRembCode:
packet_type = rtcp_parser->Iterate();
if (packet_type == kRtcpPayloadSpecificRembItemCode) {
HandlePayloadSpecificRembItem(rtcp_parser);
rtcp_parser->Iterate();
}
break;
case kRtcpPayloadSpecificCastCode:
packet_type = rtcp_parser->Iterate();
if (packet_type == kRtcpPayloadSpecificCastCode) {
HandlePayloadSpecificCastItem(rtcp_parser);
}
break;
default:
return;
}
}
void RtcpReceiver::HandlePayloadSpecificRembItem(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
for (int i = 0; i < rtcp_field.remb_item.number_of_ssrcs; ++i) {
if (rtcp_field.remb_item.ssrcs[i] == ssrc_) {
// Found matching ssrc.
VLOG(1) << "Cast RTCP received REMB with received_bitrate "
<< rtcp_field.remb_item.bitrate;
return;
}
}
}
void RtcpReceiver::HandleApplicationSpecificCastReceiverLog(
RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
uint32 remote_ssrc = rtcp_field.cast_receiver_log.sender_ssrc;
if (remote_ssrc_ != remote_ssrc) {
// Message not to us. Iterate until we have passed this message.
RtcpFieldTypes field_type;
do {
field_type = rtcp_parser->Iterate();
} while (field_type == kRtcpApplicationSpecificCastReceiverLogFrameCode ||
field_type == kRtcpApplicationSpecificCastReceiverLogEventCode);
return;
}
RtcpReceiverLogMessage receiver_log;
RtcpFieldTypes field_type = rtcp_parser->Iterate();
while (field_type == kRtcpApplicationSpecificCastReceiverLogFrameCode) {
RtcpReceiverFrameLogMessage frame_log(
rtcp_field.cast_receiver_log.rtp_timestamp);
field_type = rtcp_parser->Iterate();
while (field_type == kRtcpApplicationSpecificCastReceiverLogEventCode) {
HandleApplicationSpecificCastReceiverEventLog(rtcp_parser,
&frame_log.event_log_messages_);
field_type = rtcp_parser->Iterate();
}
receiver_log.push_back(frame_log);
}
if (receiver_feedback_ && !receiver_log.empty()) {
receiver_feedback_->OnReceivedReceiverLog(receiver_log);
}
}
void RtcpReceiver::HandleApplicationSpecificCastReceiverEventLog(
RtcpParser* rtcp_parser,
RtcpReceiverEventLogMessages* event_log_messages) {
const RtcpField& rtcp_field = rtcp_parser->Field();
RtcpReceiverEventLogMessage event_log;
event_log.type = TranslateToLogEventFromWireFormat(
rtcp_field.cast_receiver_log.event);
event_log.event_timestamp = base::TimeTicks() +
base::TimeDelta::FromMilliseconds(
rtcp_field.cast_receiver_log.event_timestamp_base +
rtcp_field.cast_receiver_log.event_timestamp_delta);
event_log.delay_delta = base::TimeDelta::FromMilliseconds(
rtcp_field.cast_receiver_log.delay_delta_or_packet_id);
event_log.packet_id =
rtcp_field.cast_receiver_log.delay_delta_or_packet_id;
event_log_messages->push_back(event_log);
}
void RtcpReceiver::HandleApplicationSpecificCastSenderLog(
RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
uint32 remote_ssrc = rtcp_field.cast_sender_log.sender_ssrc;
if (remote_ssrc_ != remote_ssrc) {
RtcpFieldTypes field_type;
// Message not to us. Iterate until we have passed this message.
do {
field_type = rtcp_parser->Iterate();
} while (field_type == kRtcpApplicationSpecificCastSenderLogCode);
return;
}
RtcpSenderLogMessage sender_log;
RtcpFieldTypes field_type = rtcp_parser->Iterate();
while (field_type == kRtcpApplicationSpecificCastSenderLogCode) {
const RtcpField& rtcp_field = rtcp_parser->Field();
RtcpSenderFrameLogMessage frame_log;
frame_log.frame_status =
TranslateToFrameStatusFromWireFormat(rtcp_field.cast_sender_log.status);
frame_log.rtp_timestamp = rtcp_field.cast_sender_log.rtp_timestamp;
sender_log.push_back(frame_log);
field_type = rtcp_parser->Iterate();
}
if (receiver_feedback_) {
receiver_feedback_->OnReceivedSenderLog(sender_log);
}
}
void RtcpReceiver::HandlePayloadSpecificCastItem(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
RtcpCastMessage cast_message(remote_ssrc_);
cast_message.ack_frame_id_ = ack_frame_id_wrap_helper_.MapTo32bitsFrameId(
rtcp_field.cast_item.last_frame_id);
RtcpFieldTypes packet_type = rtcp_parser->Iterate();
while (packet_type == kRtcpPayloadSpecificCastNackItemCode) {
const RtcpField& rtcp_field = rtcp_parser->Field();
HandlePayloadSpecificCastNackItem(
&rtcp_field, &cast_message.missing_frames_and_packets_);
packet_type = rtcp_parser->Iterate();
}
if (sender_feedback_) {
sender_feedback_->OnReceivedCastFeedback(cast_message);
}
}
void RtcpReceiver::HandlePayloadSpecificCastNackItem(
const RtcpField* rtcp_field,
MissingFramesAndPacketsMap* missing_frames_and_packets) {
MissingFramesAndPacketsMap::iterator frame_it =
missing_frames_and_packets->find(rtcp_field->cast_nack_item.frame_id);
if (frame_it == missing_frames_and_packets->end()) {
// First missing packet in a frame.
PacketIdSet empty_set;
std::pair<MissingFramesAndPacketsMap::iterator, bool> ret =
missing_frames_and_packets->insert(std::pair<uint8, PacketIdSet>(
rtcp_field->cast_nack_item.frame_id, empty_set));
frame_it = ret.first;
DCHECK(frame_it != missing_frames_and_packets->end()) << "Invalid state";
}
if (rtcp_field->cast_nack_item.packet_id == kRtcpCastAllPacketsLost) {
// Special case all packets in a frame is missing.
return;
}
uint16 packet_id = rtcp_field->cast_nack_item.packet_id;
uint8 bitmask = rtcp_field->cast_nack_item.bitmask;
frame_it->second.insert(packet_id);
if (bitmask) {
for (int i = 1; i <= 8; ++i) {
if (bitmask & 1) {
frame_it->second.insert(packet_id + i);
}
bitmask = bitmask >> 1;
}
}
}
void RtcpReceiver::HandleFIR(RtcpParser* rtcp_parser) {
const RtcpField& rtcp_field = rtcp_parser->Field();
RtcpFieldTypes field_type = rtcp_parser->Iterate();
while (field_type == kRtcpPayloadSpecificFirItemCode) {
HandleFIRItem(&rtcp_field);
field_type = rtcp_parser->Iterate();
}
}
void RtcpReceiver::HandleFIRItem(const RtcpField* rtcp_field) {
// Is it our sender that is requested to generate a new keyframe.
if (ssrc_ != rtcp_field->fir_item.ssrc) return;
VLOG(1) << "Cast RTCP received FIR on our SSRC " << ssrc_;
}
} // namespace cast
} // namespace media
|