| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <vector> | 13 #include <vector> |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
| 17 | 17 |
| 18 #include "webrtc/base/rate_limiter.h" |
| 18 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 21 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" |
| 22 | 23 |
| 23 namespace webrtc { | 24 namespace webrtc { |
| 24 namespace { | 25 namespace { |
| 25 #define test_rate 64000u | 26 #define test_rate 64000u |
| 26 | 27 |
| 27 class VerifyingAudioReceiver : public NullRtpData { | 28 class VerifyingAudioReceiver : public NullRtpData { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (payloadType == 96) { | 71 if (payloadType == 96) { |
| 71 EXPECT_EQ(test_rate, rate) << | 72 EXPECT_EQ(test_rate, rate) << |
| 72 "The rate should be 64K for this payloadType"; | 73 "The rate should be 64K for this payloadType"; |
| 73 } | 74 } |
| 74 return 0; | 75 return 0; |
| 75 } | 76 } |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 class RtpRtcpAudioTest : public ::testing::Test { | 79 class RtpRtcpAudioTest : public ::testing::Test { |
| 79 protected: | 80 protected: |
| 80 RtpRtcpAudioTest() : fake_clock(123456) { | 81 RtpRtcpAudioTest() |
| 82 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) { |
| 81 test_CSRC[0] = 1234; | 83 test_CSRC[0] = 1234; |
| 82 test_CSRC[2] = 2345; | 84 test_CSRC[2] = 2345; |
| 83 test_ssrc = 3456; | 85 test_ssrc = 3456; |
| 84 test_timestamp = 4567; | 86 test_timestamp = 4567; |
| 85 test_sequence_number = 2345; | 87 test_sequence_number = 2345; |
| 86 } | 88 } |
| 87 ~RtpRtcpAudioTest() {} | 89 ~RtpRtcpAudioTest() {} |
| 88 | 90 |
| 89 void SetUp() override { | 91 void SetUp() override { |
| 90 data_receiver1 = new VerifyingAudioReceiver(); | 92 data_receiver1 = new VerifyingAudioReceiver(); |
| 91 data_receiver2 = new VerifyingAudioReceiver(); | 93 data_receiver2 = new VerifyingAudioReceiver(); |
| 92 rtp_callback = new RTPCallback(); | 94 rtp_callback = new RTPCallback(); |
| 93 transport1 = new LoopBackTransport(); | 95 transport1 = new LoopBackTransport(); |
| 94 transport2 = new LoopBackTransport(); | 96 transport2 = new LoopBackTransport(); |
| 95 | 97 |
| 96 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); | 98 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); |
| 97 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); | 99 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); |
| 98 | 100 |
| 99 rtp_payload_registry1_.reset(new RTPPayloadRegistry( | 101 rtp_payload_registry1_.reset(new RTPPayloadRegistry( |
| 100 RTPPayloadStrategy::CreateStrategy(true))); | 102 RTPPayloadStrategy::CreateStrategy(true))); |
| 101 rtp_payload_registry2_.reset(new RTPPayloadRegistry( | 103 rtp_payload_registry2_.reset(new RTPPayloadRegistry( |
| 102 RTPPayloadStrategy::CreateStrategy(true))); | 104 RTPPayloadStrategy::CreateStrategy(true))); |
| 103 | 105 |
| 104 RtpRtcp::Configuration configuration; | 106 RtpRtcp::Configuration configuration; |
| 105 configuration.audio = true; | 107 configuration.audio = true; |
| 106 configuration.clock = &fake_clock; | 108 configuration.clock = &fake_clock; |
| 107 configuration.receive_statistics = receive_statistics1_.get(); | 109 configuration.receive_statistics = receive_statistics1_.get(); |
| 108 configuration.outgoing_transport = transport1; | 110 configuration.outgoing_transport = transport1; |
| 111 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
| 109 | 112 |
| 110 module1 = RtpRtcp::CreateRtpRtcp(configuration); | 113 module1 = RtpRtcp::CreateRtpRtcp(configuration); |
| 111 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( | 114 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( |
| 112 &fake_clock, data_receiver1, NULL, rtp_payload_registry1_.get())); | 115 &fake_clock, data_receiver1, NULL, rtp_payload_registry1_.get())); |
| 113 | 116 |
| 114 configuration.receive_statistics = receive_statistics2_.get(); | 117 configuration.receive_statistics = receive_statistics2_.get(); |
| 115 configuration.outgoing_transport = transport2; | 118 configuration.outgoing_transport = transport2; |
| 116 | 119 |
| 117 module2 = RtpRtcp::CreateRtpRtcp(configuration); | 120 module2 = RtpRtcp::CreateRtpRtcp(configuration); |
| 118 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( | 121 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 145 VerifyingAudioReceiver* data_receiver1; | 148 VerifyingAudioReceiver* data_receiver1; |
| 146 VerifyingAudioReceiver* data_receiver2; | 149 VerifyingAudioReceiver* data_receiver2; |
| 147 LoopBackTransport* transport1; | 150 LoopBackTransport* transport1; |
| 148 LoopBackTransport* transport2; | 151 LoopBackTransport* transport2; |
| 149 RTPCallback* rtp_callback; | 152 RTPCallback* rtp_callback; |
| 150 uint32_t test_ssrc; | 153 uint32_t test_ssrc; |
| 151 uint32_t test_timestamp; | 154 uint32_t test_timestamp; |
| 152 uint16_t test_sequence_number; | 155 uint16_t test_sequence_number; |
| 153 uint32_t test_CSRC[webrtc::kRtpCsrcSize]; | 156 uint32_t test_CSRC[webrtc::kRtpCsrcSize]; |
| 154 SimulatedClock fake_clock; | 157 SimulatedClock fake_clock; |
| 158 RateLimiter retransmission_rate_limiter_; |
| 155 }; | 159 }; |
| 156 | 160 |
| 157 TEST_F(RtpRtcpAudioTest, Basic) { | 161 TEST_F(RtpRtcpAudioTest, Basic) { |
| 158 module1->SetSSRC(test_ssrc); | 162 module1->SetSSRC(test_ssrc); |
| 159 module1->SetStartTimestamp(test_timestamp); | 163 module1->SetStartTimestamp(test_timestamp); |
| 160 | 164 |
| 161 // Test detection at the end of a DTMF tone. | 165 // Test detection at the end of a DTMF tone. |
| 162 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); | 166 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); |
| 163 | 167 |
| 164 EXPECT_EQ(0, module1->SetSendingStatus(true)); | 168 EXPECT_EQ(0, module1->SetSendingStatus(true)); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 for (; timeStamp <= 740 * 160; timeStamp += 160) { | 343 for (; timeStamp <= 740 * 160; timeStamp += 160) { |
| 340 EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, | 344 EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, |
| 341 timeStamp, -1, test, 4)); | 345 timeStamp, -1, test, 4)); |
| 342 fake_clock.AdvanceTimeMilliseconds(20); | 346 fake_clock.AdvanceTimeMilliseconds(20); |
| 343 module1->Process(); | 347 module1->Process(); |
| 344 } | 348 } |
| 345 } | 349 } |
| 346 | 350 |
| 347 } // namespace | 351 } // namespace |
| 348 } // namespace webrtc | 352 } // namespace webrtc |
| OLD | NEW |