| OLD | NEW |
| 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 #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/net/cast_transport_defines.h" | 8 #include "media/cast/net/cast_transport_defines.h" |
| 9 #include "media/cast/net/rtcp/mock_rtcp_receiver_feedback.h" | 9 #include "media/cast/net/rtcp/mock_rtcp_receiver_feedback.h" |
| 10 #include "media/cast/net/rtcp/rtcp_receiver.h" | 10 #include "media/cast/net/rtcp/rtcp_receiver.h" |
| 11 #include "media/cast/net/rtcp/rtcp_utility.h" | 11 #include "media/cast/net/rtcp/rtcp_utility.h" |
| 12 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" | 12 #include "media/cast/net/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 "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 namespace cast { | 17 namespace cast { |
| 18 | 18 |
| 19 using testing::_; | 19 using testing::_; |
| 20 | 20 |
| 21 static const uint32 kSenderSsrc = 0x10203; | 21 static const uint32 kSenderSsrc = 0x10203; |
| 22 static const uint32 kSourceSsrc = 0x40506; | 22 static const uint32 kSourceSsrc = 0x40506; |
| 23 static const uint32 kUnknownSsrc = 0xDEAD; | 23 static const uint32 kUnknownSsrc = 0xDEAD; |
| 24 static const base::TimeDelta kTargetDelay = | 24 static const base::TimeDelta kTargetDelay = |
| 25 base::TimeDelta::FromMilliseconds(100); | 25 base::TimeDelta::FromMilliseconds(100); |
| 26 static const std::string kCName("test@10.1.1.1"); | |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 class RtcpMessageVerification : public MockRtcpReceiverFeedback { | 29 class RtcpMessageVerification : public MockRtcpReceiverFeedback { |
| 31 public: | 30 public: |
| 32 RtcpMessageVerification() | 31 RtcpMessageVerification() |
| 33 : called_on_received_sender_log_(false), | 32 : called_on_received_sender_log_(false), |
| 34 called_on_received_receiver_log_(false), | 33 called_on_received_receiver_log_(false), |
| 35 called_on_received_cast_message_(false) {} | 34 called_on_received_cast_message_(false) {} |
| 36 | 35 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 InjectRtcpPacket(p2.Data(), p2.Length()); | 260 InjectRtcpPacket(p2.Data(), p2.Length()); |
| 262 } | 261 } |
| 263 | 262 |
| 264 TEST_F(RtcpReceiverTest, InjectSenderReportPacketWithDlrr) { | 263 TEST_F(RtcpReceiverTest, InjectSenderReportPacketWithDlrr) { |
| 265 TestRtcpPacketBuilder p; | 264 TestRtcpPacketBuilder p; |
| 266 p.AddSr(kSenderSsrc, 0); | 265 p.AddSr(kSenderSsrc, 0); |
| 267 p.AddXrHeader(kSenderSsrc); | 266 p.AddXrHeader(kSenderSsrc); |
| 268 p.AddXrUnknownBlock(); | 267 p.AddXrUnknownBlock(); |
| 269 p.AddXrExtendedDlrrBlock(kSenderSsrc); | 268 p.AddXrExtendedDlrrBlock(kSenderSsrc); |
| 270 p.AddXrUnknownBlock(); | 269 p.AddXrUnknownBlock(); |
| 271 p.AddSdesCname(kSenderSsrc, kCName); | |
| 272 | 270 |
| 273 // Expected to be ignored since the source ssrc does not match our | 271 // Expected to be ignored since the source ssrc does not match our |
| 274 // local ssrc. | 272 // local ssrc. |
| 275 InjectRtcpPacket(p.Data(), p.Length()); | 273 InjectRtcpPacket(p.Data(), p.Length()); |
| 276 | 274 |
| 277 EXPECT_CALL(mock_receiver_feedback_, | 275 EXPECT_CALL(mock_receiver_feedback_, |
| 278 OnReceivedSenderReport(expected_sender_info_)).Times(1); | 276 OnReceivedSenderReport(expected_sender_info_)).Times(1); |
| 279 EXPECT_CALL(mock_receiver_feedback_, | 277 EXPECT_CALL(mock_receiver_feedback_, |
| 280 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); | 278 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); |
| 281 | 279 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 p2.AddXrRrtrBlock(); | 311 p2.AddXrRrtrBlock(); |
| 314 | 312 |
| 315 // Expected to be pass through since the sender ssrc match our local ssrc. | 313 // Expected to be pass through since the sender ssrc match our local ssrc. |
| 316 InjectRtcpPacket(p2.Data(), p2.Length()); | 314 InjectRtcpPacket(p2.Data(), p2.Length()); |
| 317 } | 315 } |
| 318 | 316 |
| 319 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithIntraFrameRequest) { | 317 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithIntraFrameRequest) { |
| 320 TestRtcpPacketBuilder p1; | 318 TestRtcpPacketBuilder p1; |
| 321 p1.AddRr(kSenderSsrc, 1); | 319 p1.AddRr(kSenderSsrc, 1); |
| 322 p1.AddRb(kUnknownSsrc); | 320 p1.AddRb(kUnknownSsrc); |
| 323 p1.AddPli(kSenderSsrc, kUnknownSsrc); | |
| 324 | 321 |
| 325 // Expected to be ignored since the source ssrc does not match our | 322 // Expected to be ignored since the source ssrc does not match our |
| 326 // local ssrc. | 323 // local ssrc. |
| 327 InjectRtcpPacket(p1.Data(), p1.Length()); | 324 InjectRtcpPacket(p1.Data(), p1.Length()); |
| 328 | 325 |
| 329 EXPECT_CALL(mock_receiver_feedback_, | 326 EXPECT_CALL(mock_receiver_feedback_, |
| 330 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); | 327 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); |
| 331 | 328 |
| 332 TestRtcpPacketBuilder p2; | 329 TestRtcpPacketBuilder p2; |
| 333 p2.AddRr(kSenderSsrc, 1); | 330 p2.AddRr(kSenderSsrc, 1); |
| 334 p2.AddRb(kSourceSsrc); | 331 p2.AddRb(kSourceSsrc); |
| 335 p2.AddPli(kSenderSsrc, kSourceSsrc); | |
| 336 | 332 |
| 337 // Expected to be pass through since the sender ssrc match our local ssrc. | 333 // Expected to be pass through since the sender ssrc match our local ssrc. |
| 338 InjectRtcpPacket(p2.Data(), p2.Length()); | 334 InjectRtcpPacket(p2.Data(), p2.Length()); |
| 339 } | 335 } |
| 340 | 336 |
| 341 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastFeedback) { | 337 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastFeedback) { |
| 342 TestRtcpPacketBuilder p1; | 338 TestRtcpPacketBuilder p1; |
| 343 p1.AddRr(kSenderSsrc, 1); | 339 p1.AddRr(kSenderSsrc, 1); |
| 344 p1.AddRb(kUnknownSsrc); | 340 p1.AddRb(kUnknownSsrc); |
| 345 p1.AddCast(kSenderSsrc, kUnknownSsrc, kTargetDelay); | 341 p1.AddCast(kSenderSsrc, kUnknownSsrc, kTargetDelay); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); | 483 OnReceivedDelaySinceLastReport(kLastSr, kDelayLastSr)).Times(1); |
| 488 | 484 |
| 489 RtcpParser rtcp_parser(p.Data(), p.Length()); | 485 RtcpParser rtcp_parser(p.Data(), p.Length()); |
| 490 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); | 486 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); |
| 491 | 487 |
| 492 EXPECT_TRUE(verification.OnReceivedReceiverLogCalled()); | 488 EXPECT_TRUE(verification.OnReceivedReceiverLogCalled()); |
| 493 } | 489 } |
| 494 | 490 |
| 495 } // namespace cast | 491 } // namespace cast |
| 496 } // namespace media | 492 } // namespace media |
| OLD | NEW |