| 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 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/test/simple_test_tick_clock.h" | 6 #include "base/test/simple_test_tick_clock.h" |
| 7 #include "media/cast/cast_environment.h" | 7 #include "media/cast/cast_environment.h" |
| 8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" | 8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" |
| 9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" | 9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" |
| 10 #include "media/cast/rtcp/rtcp_receiver.h" | 10 #include "media/cast/rtcp/rtcp_receiver.h" |
| 11 #include "media/cast/rtcp/rtcp_utility.h" | 11 #include "media/cast/rtcp/rtcp_utility.h" |
| 12 #include "media/cast/rtcp/test_rtcp_packet_builder.h" | 12 #include "media/cast/rtcp/test_rtcp_packet_builder.h" |
| 13 #include "media/cast/test/fake_single_thread_task_runner.h" | 13 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 14 #include "media/cast/transport/cast_transport_defines.h" | 14 #include "media/cast/transport/cast_transport_defines.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 namespace cast { | 18 namespace cast { |
| 19 | 19 |
| 20 using testing::_; | 20 using testing::_; |
| 21 | 21 |
| 22 static const uint32 kSenderSsrc = 0x10203; | 22 static const uint32 kSenderSsrc = 0x10203; |
| 23 static const uint32 kSourceSsrc = 0x40506; | 23 static const uint32 kSourceSsrc = 0x40506; |
| 24 static const uint32 kUnknownSsrc = 0xDEAD; | 24 static const uint32 kUnknownSsrc = 0xDEAD; |
| 25 static const uint16 kTargetDelayMs = 100; |
| 25 static const std::string kCName("test@10.1.1.1"); | 26 static const std::string kCName("test@10.1.1.1"); |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 class SenderFeedbackCastVerification : public RtcpSenderFeedback { | 29 class SenderFeedbackCastVerification : public RtcpSenderFeedback { |
| 29 public: | 30 public: |
| 30 SenderFeedbackCastVerification() : called_(false) {} | 31 SenderFeedbackCastVerification() : called_(false) {} |
| 31 | 32 |
| 32 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) | 33 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) |
| 33 OVERRIDE { | 34 OVERRIDE { |
| 34 EXPECT_EQ(cast_feedback.media_ssrc_, kSenderSsrc); | 35 EXPECT_EQ(cast_feedback.media_ssrc_, kSenderSsrc); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 p2.AddPli(kSenderSsrc, kSourceSsrc); | 394 p2.AddPli(kSenderSsrc, kSourceSsrc); |
| 394 | 395 |
| 395 // Expected to be pass through since the sender ssrc match our local ssrc. | 396 // Expected to be pass through since the sender ssrc match our local ssrc. |
| 396 InjectRtcpPacket(p2.Data(), p2.Length()); | 397 InjectRtcpPacket(p2.Data(), p2.Length()); |
| 397 } | 398 } |
| 398 | 399 |
| 399 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastFeedback) { | 400 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastFeedback) { |
| 400 TestRtcpPacketBuilder p1; | 401 TestRtcpPacketBuilder p1; |
| 401 p1.AddRr(kSenderSsrc, 1); | 402 p1.AddRr(kSenderSsrc, 1); |
| 402 p1.AddRb(kUnknownSsrc); | 403 p1.AddRb(kUnknownSsrc); |
| 403 p1.AddCast(kSenderSsrc, kUnknownSsrc); | 404 p1.AddCast(kSenderSsrc, kUnknownSsrc, kTargetDelayMs); |
| 404 | 405 |
| 405 // Expected to be ignored since the source ssrc does not match our | 406 // Expected to be ignored since the source ssrc does not match our |
| 406 // local ssrc. | 407 // local ssrc. |
| 407 InjectRtcpPacket(p1.Data(), p1.Length()); | 408 InjectRtcpPacket(p1.Data(), p1.Length()); |
| 408 | 409 |
| 409 EXPECT_CALL(mock_rtt_feedback_, | 410 EXPECT_CALL(mock_rtt_feedback_, |
| 410 OnReceivedDelaySinceLastReport( | 411 OnReceivedDelaySinceLastReport( |
| 411 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); | 412 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); |
| 412 EXPECT_CALL(mock_sender_feedback_, OnReceivedCastFeedback(_)).Times(1); | 413 EXPECT_CALL(mock_sender_feedback_, OnReceivedCastFeedback(_)).Times(1); |
| 413 | 414 |
| 414 // Enable receiving the cast feedback. | 415 // Enable receiving the cast feedback. |
| 415 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc); | 416 rtcp_receiver_->SetRemoteSSRC(kSenderSsrc); |
| 416 | 417 |
| 417 TestRtcpPacketBuilder p2; | 418 TestRtcpPacketBuilder p2; |
| 418 p2.AddRr(kSenderSsrc, 1); | 419 p2.AddRr(kSenderSsrc, 1); |
| 419 p2.AddRb(kSourceSsrc); | 420 p2.AddRb(kSourceSsrc); |
| 420 p2.AddCast(kSenderSsrc, kSourceSsrc); | 421 p2.AddCast(kSenderSsrc, kSourceSsrc, kTargetDelayMs); |
| 421 | 422 |
| 422 // Expected to be pass through since the sender ssrc match our local ssrc. | 423 // Expected to be pass through since the sender ssrc match our local ssrc. |
| 423 InjectRtcpPacket(p2.Data(), p2.Length()); | 424 InjectRtcpPacket(p2.Data(), p2.Length()); |
| 424 } | 425 } |
| 425 | 426 |
| 426 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastVerification) { | 427 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastVerification) { |
| 427 SenderFeedbackCastVerification sender_feedback_cast_verification; | 428 SenderFeedbackCastVerification sender_feedback_cast_verification; |
| 428 RtcpReceiver rtcp_receiver(cast_environment_, | 429 RtcpReceiver rtcp_receiver(cast_environment_, |
| 429 &sender_feedback_cast_verification, | 430 &sender_feedback_cast_verification, |
| 430 &mock_receiver_feedback_, | 431 &mock_receiver_feedback_, |
| 431 &mock_rtt_feedback_, | 432 &mock_rtt_feedback_, |
| 432 kSourceSsrc); | 433 kSourceSsrc); |
| 433 | 434 |
| 434 EXPECT_CALL(mock_rtt_feedback_, | 435 EXPECT_CALL(mock_rtt_feedback_, |
| 435 OnReceivedDelaySinceLastReport( | 436 OnReceivedDelaySinceLastReport( |
| 436 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); | 437 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); |
| 437 | 438 |
| 438 // Enable receiving the cast feedback. | 439 // Enable receiving the cast feedback. |
| 439 rtcp_receiver.SetRemoteSSRC(kSenderSsrc); | 440 rtcp_receiver.SetRemoteSSRC(kSenderSsrc); |
| 440 | 441 |
| 441 TestRtcpPacketBuilder p; | 442 TestRtcpPacketBuilder p; |
| 442 p.AddRr(kSenderSsrc, 1); | 443 p.AddRr(kSenderSsrc, 1); |
| 443 p.AddRb(kSourceSsrc); | 444 p.AddRb(kSourceSsrc); |
| 444 p.AddCast(kSenderSsrc, kSourceSsrc); | 445 p.AddCast(kSenderSsrc, kSourceSsrc, kTargetDelayMs); |
| 445 | 446 |
| 446 // Expected to be pass through since the sender ssrc match our local ssrc. | 447 // Expected to be pass through since the sender ssrc match our local ssrc. |
| 447 RtcpParser rtcp_parser(p.Data(), p.Length()); | 448 RtcpParser rtcp_parser(p.Data(), p.Length()); |
| 448 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); | 449 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); |
| 449 | 450 |
| 450 EXPECT_TRUE(sender_feedback_cast_verification.called()); | 451 EXPECT_TRUE(sender_feedback_cast_verification.called()); |
| 451 } | 452 } |
| 452 | 453 |
| 453 TEST_F(RtcpReceiverTest, InjectSenderReportWithCastSenderLogVerification) { | 454 TEST_F(RtcpReceiverTest, InjectSenderReportWithCastSenderLogVerification) { |
| 454 RtcpReceiverCastLogVerification cast_log_verification; | 455 RtcpReceiverCastLogVerification cast_log_verification; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); | 586 kSourceSsrc, kLastSr, kDelayLastSr)).Times(1); |
| 586 | 587 |
| 587 RtcpParser rtcp_parser(p.Data(), p.Length()); | 588 RtcpParser rtcp_parser(p.Data(), p.Length()); |
| 588 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); | 589 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); |
| 589 | 590 |
| 590 EXPECT_TRUE(cast_log_verification.OnReceivedReceiverLogCalled()); | 591 EXPECT_TRUE(cast_log_verification.OnReceivedReceiverLogCalled()); |
| 591 } | 592 } |
| 592 | 593 |
| 593 } // namespace cast | 594 } // namespace cast |
| 594 } // namespace media | 595 } // namespace media |
| OLD | NEW |