Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / rtcp / rtcp_receiver_unittest.cc
blob3afb340228c447bd1a43cbd42dde6958c4a44dcf
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
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "base/test/simple_test_tick_clock.h"
7 #include "media/cast/cast_environment.h"
8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h"
9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h"
10 #include "media/cast/rtcp/rtcp_receiver.h"
11 #include "media/cast/rtcp/rtcp_utility.h"
12 #include "media/cast/rtcp/test_rtcp_packet_builder.h"
13 #include "media/cast/test/fake_single_thread_task_runner.h"
14 #include "media/cast/transport/cast_transport_defines.h"
15 #include "testing/gmock/include/gmock/gmock.h"
17 namespace media {
18 namespace cast {
20 using testing::_;
22 static const uint32 kSenderSsrc = 0x10203;
23 static const uint32 kSourceSsrc = 0x40506;
24 static const uint32 kUnknownSsrc = 0xDEAD;
25 static const std::string kCName("test@10.1.1.1");
27 namespace {
28 class SenderFeedbackCastVerification : public RtcpSenderFeedback {
29 public:
30 SenderFeedbackCastVerification() : called_(false) {}
32 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback)
33 OVERRIDE {
34 EXPECT_EQ(cast_feedback.media_ssrc_, kSenderSsrc);
35 EXPECT_EQ(cast_feedback.ack_frame_id_, kAckFrameId);
37 MissingFramesAndPacketsMap::const_iterator frame_it =
38 cast_feedback.missing_frames_and_packets_.begin();
40 EXPECT_TRUE(frame_it != cast_feedback.missing_frames_and_packets_.end());
41 EXPECT_EQ(kLostFrameId, frame_it->first);
42 EXPECT_TRUE(frame_it->second.empty());
43 ++frame_it;
44 EXPECT_TRUE(frame_it != cast_feedback.missing_frames_and_packets_.end());
45 EXPECT_EQ(kFrameIdWithLostPackets, frame_it->first);
46 EXPECT_EQ(3UL, frame_it->second.size());
47 PacketIdSet::const_iterator packet_it = frame_it->second.begin();
48 EXPECT_EQ(kLostPacketId1, *packet_it);
49 ++packet_it;
50 EXPECT_EQ(kLostPacketId2, *packet_it);
51 ++packet_it;
52 EXPECT_EQ(kLostPacketId3, *packet_it);
53 ++frame_it;
54 EXPECT_EQ(frame_it, cast_feedback.missing_frames_and_packets_.end());
55 called_ = true;
58 bool called() const { return called_; }
60 private:
61 bool called_;
63 DISALLOW_COPY_AND_ASSIGN(SenderFeedbackCastVerification);
66 class RtcpReceiverCastLogVerification : public RtcpReceiverFeedback {
67 public:
68 RtcpReceiverCastLogVerification()
69 : called_on_received_sender_log_(false),
70 called_on_received_receiver_log_(false) {}
72 virtual void OnReceivedSenderReport(
73 const transport::RtcpSenderInfo& remote_sender_info) OVERRIDE{};
75 virtual void OnReceiverReferenceTimeReport(
76 const RtcpReceiverReferenceTimeReport& remote_time_report) OVERRIDE{};
78 virtual void OnReceivedSendReportRequest() OVERRIDE{};
80 virtual void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log)
81 OVERRIDE {
82 EXPECT_EQ(expected_receiver_log_.size(), receiver_log.size());
83 RtcpReceiverLogMessage::const_iterator expected_it =
84 expected_receiver_log_.begin();
85 RtcpReceiverLogMessage::const_iterator incoming_it = receiver_log.begin();
86 for (; incoming_it != receiver_log.end(); ++incoming_it) {
87 EXPECT_EQ(expected_it->rtp_timestamp_, incoming_it->rtp_timestamp_);
88 EXPECT_EQ(expected_it->event_log_messages_.size(),
89 incoming_it->event_log_messages_.size());
91 RtcpReceiverEventLogMessages::const_iterator event_incoming_it =
92 incoming_it->event_log_messages_.begin();
93 RtcpReceiverEventLogMessages::const_iterator event_expected_it =
94 expected_it->event_log_messages_.begin();
95 for (; event_incoming_it != incoming_it->event_log_messages_.end();
96 ++event_incoming_it, ++event_expected_it) {
97 EXPECT_EQ(event_expected_it->type, event_incoming_it->type);
98 EXPECT_EQ(event_expected_it->event_timestamp,
99 event_incoming_it->event_timestamp);
100 if (event_expected_it->type == kVideoPacketReceived) {
101 EXPECT_EQ(event_expected_it->packet_id, event_incoming_it->packet_id);
102 } else {
103 EXPECT_EQ(event_expected_it->delay_delta,
104 event_incoming_it->delay_delta);
107 expected_receiver_log_.pop_front();
108 expected_it = expected_receiver_log_.begin();
110 called_on_received_receiver_log_ = true;
113 virtual void OnReceivedSenderLog(
114 const transport::RtcpSenderLogMessage& sender_log) OVERRIDE {
115 EXPECT_EQ(expected_sender_log_.size(), sender_log.size());
117 transport::RtcpSenderLogMessage::const_iterator expected_it =
118 expected_sender_log_.begin();
119 transport::RtcpSenderLogMessage::const_iterator incoming_it =
120 sender_log.begin();
121 for (; expected_it != expected_sender_log_.end();
122 ++expected_it, ++incoming_it) {
123 EXPECT_EQ(expected_it->frame_status, incoming_it->frame_status);
124 EXPECT_EQ(0xffffff & expected_it->rtp_timestamp,
125 incoming_it->rtp_timestamp);
127 called_on_received_sender_log_ = true;
130 bool OnReceivedSenderLogCalled() { return called_on_received_sender_log_; }
132 bool OnReceivedReceiverLogCalled() {
133 return called_on_received_receiver_log_ && expected_receiver_log_.empty();
136 void SetExpectedReceiverLog(const RtcpReceiverLogMessage& receiver_log) {
137 expected_receiver_log_ = receiver_log;
140 void SetExpectedSenderLog(const transport::RtcpSenderLogMessage& sender_log) {
141 expected_sender_log_ = sender_log;
144 private:
145 RtcpReceiverLogMessage expected_receiver_log_;
146 transport::RtcpSenderLogMessage expected_sender_log_;
147 bool called_on_received_sender_log_;
148 bool called_on_received_receiver_log_;
150 DISALLOW_COPY_AND_ASSIGN(RtcpReceiverCastLogVerification);
153 } // namespace
155 class RtcpReceiverTest : public ::testing::Test {
156 protected:
157 RtcpReceiverTest()
158 : testing_clock_(new base::SimpleTestTickClock()),
159 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)),
160 cast_environment_(new CastEnvironment(
161 scoped_ptr<base::TickClock>(testing_clock_).Pass(),
162 task_runner_,
163 task_runner_,
164 task_runner_,
165 task_runner_,
166 task_runner_,
167 task_runner_,
168 GetDefaultCastReceiverLoggingConfig())),
169 rtcp_receiver_(new RtcpReceiver(cast_environment_,
170 &mock_sender_feedback_,
171 &mock_receiver_feedback_,
172 &mock_rtt_feedback_,
173 kSourceSsrc)) {
174 EXPECT_CALL(mock_receiver_feedback_, OnReceivedSenderReport(_)).Times(0);
175 EXPECT_CALL(mock_receiver_feedback_, OnReceiverReferenceTimeReport(_))
176 .Times(0);
177 EXPECT_CALL(mock_receiver_feedback_, OnReceivedSendReportRequest())
178 .Times(0);
179 EXPECT_CALL(mock_sender_feedback_, OnReceivedCastFeedback(_)).Times(0);
180 EXPECT_CALL(mock_rtt_feedback_, OnReceivedDelaySinceLastReport(_, _, _))
181 .Times(0);
183 expected_sender_info_.ntp_seconds = kNtpHigh;
184 expected_sender_info_.ntp_fraction = kNtpLow;
185 expected_sender_info_.rtp_timestamp = kRtpTimestamp;
186 expected_sender_info_.send_packet_count = kSendPacketCount;
187 expected_sender_info_.send_octet_count = kSendOctetCount;
189 expected_report_block_.remote_ssrc = kSenderSsrc;
190 expected_report_block_.media_ssrc = kSourceSsrc;
191 expected_report_block_.fraction_lost = kLoss >> 24;
192 expected_report_block_.cumulative_lost = kLoss & 0xffffff;
193 expected_report_block_.extended_high_sequence_number = kExtendedMax;
194 expected_report_block_.jitter = kTestJitter;
195 expected_report_block_.last_sr = kLastSr;
196 expected_report_block_.delay_since_last_sr = kDelayLastSr;
197 expected_receiver_reference_report_.remote_ssrc = kSenderSsrc;
198 expected_receiver_reference_report_.ntp_seconds = kNtpHigh;
199 expected_receiver_reference_report_.ntp_fraction = kNtpLow;
202 virtual ~RtcpReceiverTest() {}
204 // Injects an RTCP packet into the receiver.
205 void InjectRtcpPacket(const uint8* packet, uint16 length) {
206 RtcpParser rtcp_parser(packet, length);
207 rtcp_receiver_->IncomingRtcpPacket(&rtcp_parser);
210 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
211 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
212 scoped_refptr<CastEnvironment> cast_environment_;
213 MockRtcpReceiverFeedback mock_receiver_feedback_;
214 MockRtcpRttFeedback mock_rtt_feedback_;
215 MockRtcpSenderFeedback mock_sender_feedback_;
216 scoped_ptr<RtcpReceiver> rtcp_receiver_;
217 transport::RtcpSenderInfo expected_sender_info_;
218 transport::RtcpReportBlock expected_report_block_;
219 RtcpReceiverReferenceTimeReport expected_receiver_reference_report_;
221 DISALLOW_COPY_AND_ASSIGN(RtcpReceiverTest);
224 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) {
225 const uint8 bad_packet[] = {0, 0, 0, 0};
226 InjectRtcpPacket(bad_packet, sizeof(bad_packet));
229 TEST_F(RtcpReceiverTest, InjectSenderReportPacket) {
230 TestRtcpPacketBuilder p;
231 p.AddSr(kSenderSsrc, 0);
233 // Expected to be ignored since the sender ssrc does not match our
234 // remote ssrc.
235 InjectRtcpPacket(p.Data(), p.Length());
237 EXPECT_CALL(mock_receiver_feedback_,
238 OnReceivedSenderReport(expected_sender_info_)).Times(1);
239 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
241 // Expected to be pass through since the sender ssrc match our remote ssrc.
242 InjectRtcpPacket(p.Data(), p.Length());
245 TEST_F(RtcpReceiverTest, InjectReceiveReportPacket) {
246 TestRtcpPacketBuilder p1;
247 p1.AddRr(kSenderSsrc, 1);
248 p1.AddRb(kUnknownSsrc);
250 // Expected to be ignored since the source ssrc does not match our
251 // local ssrc.
252 InjectRtcpPacket(p1.Data(), p1.Length());
254 EXPECT_CALL(mock_rtt_feedback_,
255 OnReceivedDelaySinceLastReport(
256 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
258 TestRtcpPacketBuilder p2;
259 p2.AddRr(kSenderSsrc, 1);
260 p2.AddRb(kSourceSsrc);
262 // Expected to be pass through since the sender ssrc match our local ssrc.
263 InjectRtcpPacket(p2.Data(), p2.Length());
266 TEST_F(RtcpReceiverTest, InjectSenderReportWithReportBlockPacket) {
267 TestRtcpPacketBuilder p1;
268 p1.AddSr(kSenderSsrc, 1);
269 p1.AddRb(kUnknownSsrc);
271 // Sender report expected to be ignored since the sender ssrc does not match
272 // our remote ssrc.
273 // Report block expected to be ignored since the source ssrc does not match
274 // our local ssrc.
275 InjectRtcpPacket(p1.Data(), p1.Length());
277 EXPECT_CALL(mock_receiver_feedback_,
278 OnReceivedSenderReport(expected_sender_info_)).Times(1);
279 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
281 // Sender report expected to be pass through since the sender ssrc match our
282 // remote ssrc.
283 // Report block expected to be ignored since the source ssrc does not match
284 // our local ssrc.
285 InjectRtcpPacket(p1.Data(), p1.Length());
287 EXPECT_CALL(mock_receiver_feedback_, OnReceivedSenderReport(_)).Times(0);
288 EXPECT_CALL(mock_rtt_feedback_,
289 OnReceivedDelaySinceLastReport(
290 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
292 rtcp_receiver_->SetRemoteSSRC(0);
294 TestRtcpPacketBuilder p2;
295 p2.AddSr(kSenderSsrc, 1);
296 p2.AddRb(kSourceSsrc);
298 // Sender report expected to be ignored since the sender ssrc does not match
299 // our remote ssrc.
300 // Receiver report expected to be pass through since the sender ssrc match
301 // our local ssrc.
302 InjectRtcpPacket(p2.Data(), p2.Length());
304 EXPECT_CALL(mock_receiver_feedback_,
305 OnReceivedSenderReport(expected_sender_info_)).Times(1);
306 EXPECT_CALL(mock_rtt_feedback_,
307 OnReceivedDelaySinceLastReport(
308 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
310 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
312 // Sender report expected to be pass through since the sender ssrc match our
313 // remote ssrc.
314 // Receiver report expected to be pass through since the sender ssrc match
315 // our local ssrc.
316 InjectRtcpPacket(p2.Data(), p2.Length());
319 TEST_F(RtcpReceiverTest, InjectSenderReportPacketWithDlrr) {
320 TestRtcpPacketBuilder p;
321 p.AddSr(kSenderSsrc, 0);
322 p.AddXrHeader(kSenderSsrc);
323 p.AddXrUnknownBlock();
324 p.AddXrExtendedDlrrBlock(kSenderSsrc);
325 p.AddXrUnknownBlock();
326 p.AddSdesCname(kSenderSsrc, kCName);
328 // Expected to be ignored since the source ssrc does not match our
329 // local ssrc.
330 InjectRtcpPacket(p.Data(), p.Length());
332 EXPECT_CALL(mock_receiver_feedback_,
333 OnReceivedSenderReport(expected_sender_info_)).Times(1);
334 EXPECT_CALL(mock_rtt_feedback_,
335 OnReceivedDelaySinceLastReport(
336 kSenderSsrc, kLastSr, kDelayLastSr)).Times(1);
338 // Enable receiving sender report.
339 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
341 // Expected to be pass through since the sender ssrc match our local ssrc.
342 InjectRtcpPacket(p.Data(), p.Length());
345 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithRrtr) {
346 TestRtcpPacketBuilder p1;
347 p1.AddRr(kSenderSsrc, 1);
348 p1.AddRb(kUnknownSsrc);
349 p1.AddXrHeader(kSenderSsrc);
350 p1.AddXrRrtrBlock();
352 // Expected to be ignored since the source ssrc does not match our
353 // local ssrc.
354 InjectRtcpPacket(p1.Data(), p1.Length());
356 EXPECT_CALL(mock_rtt_feedback_,
357 OnReceivedDelaySinceLastReport(
358 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
359 EXPECT_CALL(mock_receiver_feedback_,
360 OnReceiverReferenceTimeReport(
361 expected_receiver_reference_report_)).Times(1);
363 // Enable receiving reference time report.
364 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
366 TestRtcpPacketBuilder p2;
367 p2.AddRr(kSenderSsrc, 1);
368 p2.AddRb(kSourceSsrc);
369 p2.AddXrHeader(kSenderSsrc);
370 p2.AddXrRrtrBlock();
372 // Expected to be pass through since the sender ssrc match our local ssrc.
373 InjectRtcpPacket(p2.Data(), p2.Length());
376 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithIntraFrameRequest) {
377 TestRtcpPacketBuilder p1;
378 p1.AddRr(kSenderSsrc, 1);
379 p1.AddRb(kUnknownSsrc);
380 p1.AddPli(kSenderSsrc, kUnknownSsrc);
382 // Expected to be ignored since the source ssrc does not match our
383 // local ssrc.
384 InjectRtcpPacket(p1.Data(), p1.Length());
386 EXPECT_CALL(mock_rtt_feedback_,
387 OnReceivedDelaySinceLastReport(
388 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
390 TestRtcpPacketBuilder p2;
391 p2.AddRr(kSenderSsrc, 1);
392 p2.AddRb(kSourceSsrc);
393 p2.AddPli(kSenderSsrc, kSourceSsrc);
395 // Expected to be pass through since the sender ssrc match our local ssrc.
396 InjectRtcpPacket(p2.Data(), p2.Length());
399 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastFeedback) {
400 TestRtcpPacketBuilder p1;
401 p1.AddRr(kSenderSsrc, 1);
402 p1.AddRb(kUnknownSsrc);
403 p1.AddCast(kSenderSsrc, kUnknownSsrc);
405 // Expected to be ignored since the source ssrc does not match our
406 // local ssrc.
407 InjectRtcpPacket(p1.Data(), p1.Length());
409 EXPECT_CALL(mock_rtt_feedback_,
410 OnReceivedDelaySinceLastReport(
411 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
412 EXPECT_CALL(mock_sender_feedback_, OnReceivedCastFeedback(_)).Times(1);
414 // Enable receiving the cast feedback.
415 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc);
417 TestRtcpPacketBuilder p2;
418 p2.AddRr(kSenderSsrc, 1);
419 p2.AddRb(kSourceSsrc);
420 p2.AddCast(kSenderSsrc, kSourceSsrc);
422 // Expected to be pass through since the sender ssrc match our local ssrc.
423 InjectRtcpPacket(p2.Data(), p2.Length());
426 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastVerification) {
427 SenderFeedbackCastVerification sender_feedback_cast_verification;
428 RtcpReceiver rtcp_receiver(cast_environment_,
429 &sender_feedback_cast_verification,
430 &mock_receiver_feedback_,
431 &mock_rtt_feedback_,
432 kSourceSsrc);
434 EXPECT_CALL(mock_rtt_feedback_,
435 OnReceivedDelaySinceLastReport(
436 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
438 // Enable receiving the cast feedback.
439 rtcp_receiver.SetRemoteSSRC(kSenderSsrc);
441 TestRtcpPacketBuilder p;
442 p.AddRr(kSenderSsrc, 1);
443 p.AddRb(kSourceSsrc);
444 p.AddCast(kSenderSsrc, kSourceSsrc);
446 // Expected to be pass through since the sender ssrc match our local ssrc.
447 RtcpParser rtcp_parser(p.Data(), p.Length());
448 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser);
450 EXPECT_TRUE(sender_feedback_cast_verification.called());
453 TEST_F(RtcpReceiverTest, InjectSenderReportWithCastSenderLogVerification) {
454 RtcpReceiverCastLogVerification cast_log_verification;
455 RtcpReceiver rtcp_receiver(cast_environment_,
456 &mock_sender_feedback_,
457 &cast_log_verification,
458 &mock_rtt_feedback_,
459 kSourceSsrc);
460 rtcp_receiver.SetRemoteSSRC(kSenderSsrc);
462 transport::RtcpSenderLogMessage sender_log;
463 for (int j = 0; j < 359; ++j) {
464 transport::RtcpSenderFrameLogMessage sender_frame_log;
465 sender_frame_log.frame_status =
466 transport::kRtcpSenderFrameStatusSentToNetwork;
467 sender_frame_log.rtp_timestamp = kRtpTimestamp + j * 90;
468 sender_log.push_back(sender_frame_log);
470 cast_log_verification.SetExpectedSenderLog(sender_log);
472 TestRtcpPacketBuilder p;
473 p.AddSr(kSenderSsrc, 0);
474 p.AddSdesCname(kSenderSsrc, kCName);
475 p.AddSenderLog(kSenderSsrc);
477 for (int i = 0; i < 359; ++i) {
478 p.AddSenderFrameLog(transport::kRtcpSenderFrameStatusSentToNetwork,
479 kRtpTimestamp + i * 90);
481 RtcpParser rtcp_parser(p.Data(), p.Length());
482 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser);
484 EXPECT_TRUE(cast_log_verification.OnReceivedSenderLogCalled());
487 TEST_F(RtcpReceiverTest, InjectReceiverReportWithReceiverLogVerificationBase) {
488 static const uint32 kTimeBaseMs = 12345678;
489 static const uint32 kTimeDelayMs = 10;
490 static const uint32 kDelayDeltaMs = 123;
491 base::SimpleTestTickClock testing_clock;
492 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs));
494 RtcpReceiverCastLogVerification cast_log_verification;
495 RtcpReceiver rtcp_receiver(cast_environment_,
496 &mock_sender_feedback_,
497 &cast_log_verification,
498 &mock_rtt_feedback_,
499 kSourceSsrc);
500 rtcp_receiver.SetRemoteSSRC(kSenderSsrc);
502 RtcpReceiverLogMessage receiver_log;
503 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp);
504 RtcpReceiverEventLogMessage event_log;
506 event_log.type = kVideoAckSent;
507 event_log.event_timestamp = testing_clock.NowTicks();
508 event_log.delay_delta = base::TimeDelta::FromMilliseconds(kDelayDeltaMs);
509 frame_log.event_log_messages_.push_back(event_log);
511 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeDelayMs));
512 event_log.type = kVideoPacketReceived;
513 event_log.event_timestamp = testing_clock.NowTicks();
514 event_log.packet_id = kLostPacketId1;
515 frame_log.event_log_messages_.push_back(event_log);
516 receiver_log.push_back(frame_log);
518 cast_log_verification.SetExpectedReceiverLog(receiver_log);
520 TestRtcpPacketBuilder p;
521 p.AddRr(kSenderSsrc, 1);
522 p.AddRb(kSourceSsrc);
523 p.AddReceiverLog(kSenderSsrc);
524 p.AddReceiverFrameLog(kRtpTimestamp, 2, kTimeBaseMs);
525 p.AddReceiverEventLog(kDelayDeltaMs, 5, 0);
526 p.AddReceiverEventLog(kLostPacketId1, 8, kTimeDelayMs);
528 EXPECT_CALL(mock_rtt_feedback_,
529 OnReceivedDelaySinceLastReport(
530 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
532 RtcpParser rtcp_parser(p.Data(), p.Length());
533 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser);
535 EXPECT_TRUE(cast_log_verification.OnReceivedReceiverLogCalled());
538 TEST_F(RtcpReceiverTest, InjectReceiverReportWithReceiverLogVerificationMulti) {
539 static const uint32 kTimeBaseMs = 12345678;
540 static const uint32 kTimeDelayMs = 10;
541 static const uint32 kDelayDeltaMs = 123;
542 base::SimpleTestTickClock testing_clock;
543 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs));
545 RtcpReceiverCastLogVerification cast_log_verification;
546 RtcpReceiver rtcp_receiver(cast_environment_,
547 &mock_sender_feedback_,
548 &cast_log_verification,
549 &mock_rtt_feedback_,
550 kSourceSsrc);
551 rtcp_receiver.SetRemoteSSRC(kSenderSsrc);
553 RtcpReceiverLogMessage receiver_log;
555 for (int j = 0; j < 100; ++j) {
556 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp);
557 RtcpReceiverEventLogMessage event_log;
558 event_log.type = kVideoAckSent;
559 event_log.event_timestamp = testing_clock.NowTicks();
560 event_log.delay_delta = base::TimeDelta::FromMilliseconds(kDelayDeltaMs);
561 frame_log.event_log_messages_.push_back(event_log);
562 receiver_log.push_back(frame_log);
563 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeDelayMs));
566 cast_log_verification.SetExpectedReceiverLog(receiver_log);
568 TestRtcpPacketBuilder p;
569 p.AddRr(kSenderSsrc, 1);
570 p.AddRb(kSourceSsrc);
571 p.AddReceiverLog(kSenderSsrc);
572 for (int i = 0; i < 100; ++i) {
573 p.AddReceiverFrameLog(kRtpTimestamp, 1, kTimeBaseMs + i * kTimeDelayMs);
574 p.AddReceiverEventLog(kDelayDeltaMs, 5, 0);
577 EXPECT_CALL(mock_rtt_feedback_,
578 OnReceivedDelaySinceLastReport(
579 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1);
581 RtcpParser rtcp_parser(p.Data(), p.Length());
582 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser);
584 EXPECT_TRUE(cast_log_verification.OnReceivedReceiverLogCalled());
587 } // namespace cast
588 } // namespace media