Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc

Issue 2947133002: Fix timing frames and FEC conflict (Closed)
Patch Set: Fix typo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 fake_clock_.TimeInMilliseconds(), false, 456 fake_clock_.TimeInMilliseconds(), false,
457 PacedPacketInfo()); 457 PacedPacketInfo());
458 458
459 const auto& packet = transport_.last_sent_packet(); 459 const auto& packet = transport_.last_sent_packet();
460 uint16_t transport_seq_no; 460 uint16_t transport_seq_no;
461 EXPECT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no)); 461 EXPECT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no));
462 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no); 462 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no);
463 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no); 463 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no);
464 } 464 }
465 465
466 // Disabled due to webrtc:7859. Until issues with FEC resolved, pacer exit 466 TEST_P(RtpSenderTestWithoutPacer, WritesTimestampToTimingExtension) {
467 // timstamp is not updated in the pacer.
468 TEST_P(RtpSenderTestWithoutPacer, DISABLED_WritesTimestampToTimingExtension) {
469 rtp_sender_->SetStorePacketsStatus(true, 10); 467 rtp_sender_->SetStorePacketsStatus(true, 10);
470 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( 468 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
471 kRtpExtensionVideoTiming, kVideoTimingExtensionId)); 469 kRtpExtensionVideoTiming, kVideoTimingExtensionId));
472 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); 470 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
473 auto packet = rtp_sender_->AllocatePacket(); 471 auto packet = rtp_sender_->AllocatePacket();
474 packet->SetPayloadType(kPayload); 472 packet->SetPayloadType(kPayload);
475 packet->SetMarker(true); 473 packet->SetMarker(true);
476 packet->SetTimestamp(kTimestamp); 474 packet->SetTimestamp(kTimestamp);
477 packet->set_capture_time_ms(capture_time_ms); 475 packet->set_capture_time_ms(capture_time_ms);
478 const VideoTiming kVideoTiming = {0u, 0u, 0u, 0u, 0u, 0u, true}; 476 const VideoTiming kVideoTiming = {0u, 0u, 0u, 0u, 0u, 0u, true};
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; 935 const RtpPacketReceived& media_packet = transport_.sent_packets_[0];
938 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); 936 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType());
939 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber()); 937 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber());
940 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); 938 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc());
941 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1]; 939 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1];
942 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType()); 940 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType());
943 EXPECT_EQ(flexfec_seq_num, flexfec_packet.SequenceNumber()); 941 EXPECT_EQ(flexfec_seq_num, flexfec_packet.SequenceNumber());
944 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc()); 942 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc());
945 } 943 }
946 944
945 // TODO(ilnik): because of webrtc:7859. Once FEC moved below pacer, this test
946 // should be removed.
947 TEST_P(RtpSenderTest, NoFlexfecForTimingFrames) {
948 constexpr int kMediaPayloadType = 127;
949 constexpr int kFlexfecPayloadType = 118;
950 constexpr uint32_t kMediaSsrc = 1234;
951 constexpr uint32_t kFlexfecSsrc = 5678;
952 const std::vector<RtpExtension> kNoRtpExtensions;
953 const std::vector<RtpExtensionSize> kNoRtpExtensionSizes;
954 FlexfecSender flexfec_sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc,
955 kNoRtpExtensions, kNoRtpExtensionSizes,
956 nullptr /* rtp_state */, &fake_clock_);
957
958 // Reset |rtp_sender_| to use FlexFEC.
959 rtp_sender_.reset(new RTPSender(
960 false, &fake_clock_, &transport_, &mock_paced_sender_, &flexfec_sender,
961 &seq_num_allocator_, nullptr, nullptr, nullptr, nullptr,
962 &mock_rtc_event_log_, &send_packet_observer_,
963 &retransmission_rate_limiter_, nullptr));
964 rtp_sender_->SetSSRC(kMediaSsrc);
965 rtp_sender_->SetSequenceNumber(kSeqNum);
966 rtp_sender_->SetSendPayloadType(kMediaPayloadType);
967 rtp_sender_->SetStorePacketsStatus(true, 10);
968
969 // Parameters selected to generate a single FEC packet per media packet.
970 FecProtectionParams params;
971 params.fec_rate = 15;
972 params.max_fec_frames = 1;
973 params.fec_mask_type = kFecMaskRandom;
974 rtp_sender_->SetFecParameters(params, params);
975
976 EXPECT_CALL(mock_paced_sender_,
977 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc, kSeqNum,
978 _, _, false));
979 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority,
980 kFlexfecSsrc, _, _, _, false))
981 .Times(0); // Not called because packet should not be protected.
982
983 const uint32_t kTimestamp = 1234;
984 const uint8_t kPayloadType = 127;
985 const int64_t kCaptureTimeMs = fake_clock_.TimeInMilliseconds();
986 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC";
987 EXPECT_EQ(0, rtp_sender_->RegisterPayload(payload_name, kPayloadType, 90000,
988 0, 1500));
989 RTPVideoHeader video_header;
990 memset(&video_header, 0, sizeof(RTPVideoHeader));
991 video_header.video_timing.is_timing_frame = true;
992 EXPECT_TRUE(rtp_sender_->SendOutgoingData(
993 kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs, kPayloadData,
994 sizeof(kPayloadData), nullptr, &video_header, nullptr));
995
996 EXPECT_CALL(mock_rtc_event_log_,
997 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _))
998 .Times(1);
999 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum,
1000 fake_clock_.TimeInMilliseconds(),
1001 false, PacedPacketInfo()));
1002 ASSERT_EQ(1, transport_.packets_sent());
1003 const RtpPacketReceived& media_packet = transport_.sent_packets_[0];
1004 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType());
1005 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber());
1006 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc());
1007
1008 // Now try to send not a timing frame.
1009 uint16_t flexfec_seq_num;
1010 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority,
1011 kFlexfecSsrc, _, _, _, false))
1012 .WillOnce(testing::SaveArg<2>(&flexfec_seq_num));
1013 EXPECT_CALL(mock_paced_sender_,
1014 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc,
1015 kSeqNum + 1, _, _, false));
1016 video_header.video_timing.is_timing_frame = false;
1017 EXPECT_TRUE(rtp_sender_->SendOutgoingData(
1018 kVideoFrameKey, kPayloadType, kTimestamp + 1, kCaptureTimeMs + 1,
1019 kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr));
1020
1021 EXPECT_CALL(mock_rtc_event_log_,
1022 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _))
1023 .Times(2);
1024 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum + 1,
1025 fake_clock_.TimeInMilliseconds(),
1026 false, PacedPacketInfo()));
1027 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kFlexfecSsrc, flexfec_seq_num,
1028 fake_clock_.TimeInMilliseconds(),
1029 false, PacedPacketInfo()));
1030 ASSERT_EQ(3, transport_.packets_sent());
1031 const RtpPacketReceived& media_packet2 = transport_.sent_packets_[1];
1032 EXPECT_EQ(kMediaPayloadType, media_packet2.PayloadType());
1033 EXPECT_EQ(kSeqNum + 1, media_packet2.SequenceNumber());
1034 EXPECT_EQ(kMediaSsrc, media_packet2.Ssrc());
1035 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[2];
1036 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType());
1037 EXPECT_EQ(flexfec_seq_num, flexfec_packet.SequenceNumber());
1038 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc());
1039 }
1040
947 TEST_P(RtpSenderTestWithoutPacer, SendFlexfecPackets) { 1041 TEST_P(RtpSenderTestWithoutPacer, SendFlexfecPackets) {
948 constexpr int kMediaPayloadType = 127; 1042 constexpr int kMediaPayloadType = 127;
949 constexpr int kFlexfecPayloadType = 118; 1043 constexpr int kFlexfecPayloadType = 118;
950 constexpr uint32_t kMediaSsrc = 1234; 1044 constexpr uint32_t kMediaSsrc = 1234;
951 constexpr uint32_t kFlexfecSsrc = 5678; 1045 constexpr uint32_t kFlexfecSsrc = 5678;
952 const std::vector<RtpExtension> kNoRtpExtensions; 1046 const std::vector<RtpExtension> kNoRtpExtensions;
953 const std::vector<RtpExtensionSize> kNoRtpExtensionSizes; 1047 const std::vector<RtpExtensionSize> kNoRtpExtensionSizes;
954 FlexfecSender flexfec_sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc, 1048 FlexfecSender flexfec_sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc,
955 kNoRtpExtensions, kNoRtpExtensionSizes, 1049 kNoRtpExtensions, kNoRtpExtensionSizes,
956 nullptr /* rtp_state */, &fake_clock_); 1050 nullptr /* rtp_state */, &fake_clock_);
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1712 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1619 RtpSenderTestWithoutPacer, 1713 RtpSenderTestWithoutPacer,
1620 ::testing::Bool()); 1714 ::testing::Bool());
1621 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1715 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1622 RtpSenderVideoTest, 1716 RtpSenderVideoTest,
1623 ::testing::Bool()); 1717 ::testing::Bool());
1624 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, 1718 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead,
1625 RtpSenderAudioTest, 1719 RtpSenderAudioTest,
1626 ::testing::Bool()); 1720 ::testing::Bool());
1627 } // namespace webrtc 1721 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698