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 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 const size_t payload_size, | 212 const size_t payload_size, |
213 const WebRtcRTPHeader* rtp_header) override { | 213 const WebRtcRTPHeader* rtp_header) override { |
214 return 0; | 214 return 0; |
215 } | 215 } |
216 test::RtcpPacketParser parser_; | 216 test::RtcpPacketParser parser_; |
217 }; | 217 }; |
218 | 218 |
219 namespace { | 219 namespace { |
220 static const uint32_t kSenderSsrc = 0x11111111; | 220 static const uint32_t kSenderSsrc = 0x11111111; |
221 static const uint32_t kRemoteSsrc = 0x22222222; | 221 static const uint32_t kRemoteSsrc = 0x22222222; |
222 static const uint32_t kStartRtpTimestamp = 0x34567; | |
223 static const uint32_t kRtpTimestamp = 0x45678; | |
222 } | 224 } |
223 | 225 |
224 class RtcpSenderTest : public ::testing::Test { | 226 class RtcpSenderTest : public ::testing::Test { |
225 protected: | 227 protected: |
226 RtcpSenderTest() | 228 RtcpSenderTest() |
227 : clock_(1335900000), | 229 : clock_(1335900000), |
228 receive_statistics_(ReceiveStatistics::Create(&clock_)) { | 230 receive_statistics_(ReceiveStatistics::Create(&clock_)) { |
229 RtpRtcp::Configuration configuration; | 231 RtpRtcp::Configuration configuration; |
230 configuration.audio = false; | 232 configuration.audio = false; |
231 configuration.clock = &clock_; | 233 configuration.clock = &clock_; |
232 configuration.outgoing_transport = &test_transport_; | 234 configuration.outgoing_transport = &test_transport_; |
233 | 235 |
234 rtp_rtcp_impl_.reset(new ModuleRtpRtcpImpl(configuration)); | 236 rtp_rtcp_impl_.reset(new ModuleRtpRtcpImpl(configuration)); |
235 rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(), | 237 rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(), |
236 nullptr, nullptr, &test_transport_)); | 238 nullptr, nullptr, &test_transport_)); |
237 rtcp_sender_->SetSSRC(kSenderSsrc); | 239 rtcp_sender_->SetSSRC(kSenderSsrc); |
238 rtcp_sender_->SetRemoteSSRC(kRemoteSsrc); | 240 rtcp_sender_->SetRemoteSSRC(kRemoteSsrc); |
241 rtcp_sender_->SetStartTimestamp(kStartRtpTimestamp); | |
242 rtcp_sender_->SetLastRtpTime(kRtpTimestamp, clock_.TimeInMilliseconds()); | |
239 } | 243 } |
240 | 244 |
241 void InsertIncomingPacket(uint32_t remote_ssrc, uint16_t seq_num) { | 245 void InsertIncomingPacket(uint32_t remote_ssrc, uint16_t seq_num) { |
242 RTPHeader header; | 246 RTPHeader header; |
243 header.ssrc = remote_ssrc; | 247 header.ssrc = remote_ssrc; |
244 header.sequenceNumber = seq_num; | 248 header.sequenceNumber = seq_num; |
245 header.timestamp = 12345; | 249 header.timestamp = 12345; |
246 header.headerLength = 12; | 250 header.headerLength = 12; |
247 size_t kPacketLength = 100; | 251 size_t kPacketLength = 100; |
248 receive_statistics_->IncomingPacket(header, kPacketLength, false); | 252 receive_statistics_->IncomingPacket(header, kPacketLength, false); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 uint32_t ntp_secs; | 292 uint32_t ntp_secs; |
289 uint32_t ntp_frac; | 293 uint32_t ntp_frac; |
290 clock_.CurrentNtp(ntp_secs, ntp_frac); | 294 clock_.CurrentNtp(ntp_secs, ntp_frac); |
291 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr)); | 295 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr)); |
292 EXPECT_EQ(1, parser()->sender_report()->num_packets()); | 296 EXPECT_EQ(1, parser()->sender_report()->num_packets()); |
293 EXPECT_EQ(kSenderSsrc, parser()->sender_report()->Ssrc()); | 297 EXPECT_EQ(kSenderSsrc, parser()->sender_report()->Ssrc()); |
294 EXPECT_EQ(ntp_secs, parser()->sender_report()->NtpSec()); | 298 EXPECT_EQ(ntp_secs, parser()->sender_report()->NtpSec()); |
295 EXPECT_EQ(ntp_frac, parser()->sender_report()->NtpFrac()); | 299 EXPECT_EQ(ntp_frac, parser()->sender_report()->NtpFrac()); |
296 EXPECT_EQ(kPacketCount, parser()->sender_report()->PacketCount()); | 300 EXPECT_EQ(kPacketCount, parser()->sender_report()->PacketCount()); |
297 EXPECT_EQ(kOctetCount, parser()->sender_report()->OctetCount()); | 301 EXPECT_EQ(kOctetCount, parser()->sender_report()->OctetCount()); |
302 EXPECT_EQ(kStartRtpTimestamp + kRtpTimestamp, | |
303 parser()->sender_report()->RtpTimestamp()); | |
298 EXPECT_EQ(0, parser()->report_block()->num_packets()); | 304 EXPECT_EQ(0, parser()->report_block()->num_packets()); |
299 } | 305 } |
stefan-webrtc
2016/02/01 17:32:07
Should we add a test which verifies we don't send
danilchap
2016/02/01 18:24:18
test in video/end_to_end is one way to see this CL
| |
300 | 306 |
301 TEST_F(RtcpSenderTest, SendRr) { | 307 TEST_F(RtcpSenderTest, SendRr) { |
302 rtcp_sender_->SetRTCPStatus(RtcpMode::kReducedSize); | 308 rtcp_sender_->SetRTCPStatus(RtcpMode::kReducedSize); |
303 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpRr)); | 309 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpRr)); |
304 EXPECT_EQ(1, parser()->receiver_report()->num_packets()); | 310 EXPECT_EQ(1, parser()->receiver_report()->num_packets()); |
305 EXPECT_EQ(kSenderSsrc, parser()->receiver_report()->Ssrc()); | 311 EXPECT_EQ(kSenderSsrc, parser()->receiver_report()->Ssrc()); |
306 EXPECT_EQ(0, parser()->report_block()->num_packets()); | 312 EXPECT_EQ(0, parser()->report_block()->num_packets()); |
307 } | 313 } |
308 | 314 |
309 TEST_F(RtcpSenderTest, SendRrWithOneReportBlock) { | 315 TEST_F(RtcpSenderTest, SendRrWithOneReportBlock) { |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 rtcp_sender_->SetREMBData(kBitrate, ssrcs); | 761 rtcp_sender_->SetREMBData(kBitrate, ssrcs); |
756 std::set<RTCPPacketType> packet_types; | 762 std::set<RTCPPacketType> packet_types; |
757 packet_types.insert(kRtcpRemb); | 763 packet_types.insert(kRtcpRemb); |
758 packet_types.insert(kRtcpPli); | 764 packet_types.insert(kRtcpPli); |
759 EXPECT_EQ(0, rtcp_sender_->SendCompoundRTCP(feedback_state(), packet_types)); | 765 EXPECT_EQ(0, rtcp_sender_->SendCompoundRTCP(feedback_state(), packet_types)); |
760 EXPECT_EQ(1, parser()->remb_item()->num_packets()); | 766 EXPECT_EQ(1, parser()->remb_item()->num_packets()); |
761 EXPECT_EQ(1, parser()->pli()->num_packets()); | 767 EXPECT_EQ(1, parser()->pli()->num_packets()); |
762 } | 768 } |
763 | 769 |
764 } // namespace webrtc | 770 } // namespace webrtc |
OLD | NEW |