| 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 "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 11 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "webrtc/base/rate_limiter.h" |
| 17 #include "webrtc/test/null_transport.h" | 18 #include "webrtc/test/null_transport.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 | 21 |
| 21 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, | 22 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, |
| 22 RTPPayloadRegistry* payload_registry, | 23 RTPPayloadRegistry* payload_registry, |
| 23 RtpReceiver* receiver, | 24 RtpReceiver* receiver, |
| 24 ReceiveStatistics* receive_statistics) { | 25 ReceiveStatistics* receive_statistics) { |
| 25 rtp_rtcp_module_ = rtp_rtcp_module; | 26 rtp_rtcp_module_ = rtp_rtcp_module; |
| 26 rtp_payload_registry_ = payload_registry; | 27 rtp_payload_registry_ = payload_registry; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 const webrtc::WebRtcRTPHeader* rtp_header) { | 74 const webrtc::WebRtcRTPHeader* rtp_header) { |
| 74 EXPECT_LE(payload_size, sizeof(payload_data_)); | 75 EXPECT_LE(payload_size, sizeof(payload_data_)); |
| 75 memcpy(payload_data_, payload_data, payload_size); | 76 memcpy(payload_data_, payload_data, payload_size); |
| 76 memcpy(&rtp_header_, rtp_header, sizeof(rtp_header_)); | 77 memcpy(&rtp_header_, rtp_header, sizeof(rtp_header_)); |
| 77 payload_size_ = payload_size; | 78 payload_size_ = payload_size; |
| 78 return 0; | 79 return 0; |
| 79 } | 80 } |
| 80 | 81 |
| 81 class RtpRtcpAPITest : public ::testing::Test { | 82 class RtpRtcpAPITest : public ::testing::Test { |
| 82 protected: | 83 protected: |
| 83 RtpRtcpAPITest() : fake_clock_(123456) { | 84 RtpRtcpAPITest() |
| 85 : fake_clock_(123456), retransmission_rate_limiter_(&fake_clock_, 1000) { |
| 84 test_csrcs_.push_back(1234); | 86 test_csrcs_.push_back(1234); |
| 85 test_csrcs_.push_back(2345); | 87 test_csrcs_.push_back(2345); |
| 86 test_ssrc_ = 3456; | 88 test_ssrc_ = 3456; |
| 87 test_timestamp_ = 4567; | 89 test_timestamp_ = 4567; |
| 88 test_sequence_number_ = 2345; | 90 test_sequence_number_ = 2345; |
| 89 } | 91 } |
| 90 ~RtpRtcpAPITest() {} | 92 ~RtpRtcpAPITest() {} |
| 91 | 93 |
| 92 void SetUp() override { | 94 void SetUp() override { |
| 93 RtpRtcp::Configuration configuration; | 95 RtpRtcp::Configuration configuration; |
| 94 configuration.audio = true; | 96 configuration.audio = true; |
| 95 configuration.clock = &fake_clock_; | 97 configuration.clock = &fake_clock_; |
| 96 configuration.outgoing_transport = &null_transport_; | 98 configuration.outgoing_transport = &null_transport_; |
| 99 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
| 97 module_.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 100 module_.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
| 98 rtp_payload_registry_.reset(new RTPPayloadRegistry( | 101 rtp_payload_registry_.reset(new RTPPayloadRegistry( |
| 99 RTPPayloadStrategy::CreateStrategy(true))); | 102 RTPPayloadStrategy::CreateStrategy(true))); |
| 100 rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver( | 103 rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver( |
| 101 &fake_clock_, NULL, NULL, rtp_payload_registry_.get())); | 104 &fake_clock_, NULL, NULL, rtp_payload_registry_.get())); |
| 102 } | 105 } |
| 103 | 106 |
| 104 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 107 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 105 std::unique_ptr<RtpReceiver> rtp_receiver_; | 108 std::unique_ptr<RtpReceiver> rtp_receiver_; |
| 106 std::unique_ptr<RtpRtcp> module_; | 109 std::unique_ptr<RtpRtcp> module_; |
| 107 uint32_t test_ssrc_; | 110 uint32_t test_ssrc_; |
| 108 uint32_t test_timestamp_; | 111 uint32_t test_timestamp_; |
| 109 uint16_t test_sequence_number_; | 112 uint16_t test_sequence_number_; |
| 110 std::vector<uint32_t> test_csrcs_; | 113 std::vector<uint32_t> test_csrcs_; |
| 111 SimulatedClock fake_clock_; | 114 SimulatedClock fake_clock_; |
| 112 test::NullTransport null_transport_; | 115 test::NullTransport null_transport_; |
| 116 RateLimiter retransmission_rate_limiter_; |
| 113 }; | 117 }; |
| 114 | 118 |
| 115 TEST_F(RtpRtcpAPITest, Basic) { | 119 TEST_F(RtpRtcpAPITest, Basic) { |
| 116 module_->SetSequenceNumber(test_sequence_number_); | 120 module_->SetSequenceNumber(test_sequence_number_); |
| 117 EXPECT_EQ(test_sequence_number_, module_->SequenceNumber()); | 121 EXPECT_EQ(test_sequence_number_, module_->SequenceNumber()); |
| 118 | 122 |
| 119 module_->SetStartTimestamp(test_timestamp_); | 123 module_->SetStartTimestamp(test_timestamp_); |
| 120 EXPECT_EQ(test_timestamp_, module_->StartTimestamp()); | 124 EXPECT_EQ(test_timestamp_, module_->StartTimestamp()); |
| 121 | 125 |
| 122 EXPECT_FALSE(module_->Sending()); | 126 EXPECT_FALSE(module_->Sending()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 rtx_header.payloadType = kRtxPayloadType; | 182 rtx_header.payloadType = kRtxPayloadType; |
| 179 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 183 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
| 180 rtx_header.ssrc = 0; | 184 rtx_header.ssrc = 0; |
| 181 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); | 185 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); |
| 182 rtx_header.ssrc = kRtxSsrc; | 186 rtx_header.ssrc = kRtxSsrc; |
| 183 rtx_header.payloadType = 0; | 187 rtx_header.payloadType = 0; |
| 184 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 188 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
| 185 } | 189 } |
| 186 | 190 |
| 187 } // namespace webrtc | 191 } // namespace webrtc |
| OLD | NEW |