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

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

Issue 1367193002: Fix bug where rtcp::TransportFeedback may generate incorrect messages. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed associated bug in rtcp_receiver plus added tests Created 5 years, 2 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
11 11
12 /* 12 /*
13 * This file includes unit tests for the RTCPReceiver. 13 * This file includes unit tests for the RTCPReceiver.
14 */ 14 */
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 // Note: This file has no directory. Lint warning must be ignored. 18 // Note: This file has no directory. Lint warning must be ignored.
19 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_observer.h" 20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_observer.h"
21 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h" 21 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
27 29
28 namespace webrtc { 30 namespace webrtc {
29 31
30 namespace { // Anonymous namespace; hide utility functions and classes. 32 namespace { // Anonymous namespace; hide utility functions and classes.
31 33
32 // This test transport verifies that no functions get called. 34 // This test transport verifies that no functions get called.
33 class TestTransport : public Transport, 35 class TestTransport : public Transport,
34 public NullRtpData { 36 public NullRtpData {
35 public: 37 public:
36 explicit TestTransport() : rtcp_receiver_(nullptr) {} 38 explicit TestTransport() : rtcp_receiver_(nullptr) {}
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 rtcp_packet_info_.interArrivalJitter = 115 rtcp_packet_info_.interArrivalJitter =
114 rtcpPacketInformation.interArrivalJitter; 116 rtcpPacketInformation.interArrivalJitter;
115 rtcp_packet_info_.sliPictureId = rtcpPacketInformation.sliPictureId; 117 rtcp_packet_info_.sliPictureId = rtcpPacketInformation.sliPictureId;
116 rtcp_packet_info_.rpsiPictureId = rtcpPacketInformation.rpsiPictureId; 118 rtcp_packet_info_.rpsiPictureId = rtcpPacketInformation.rpsiPictureId;
117 rtcp_packet_info_.receiverEstimatedMaxBitrate = 119 rtcp_packet_info_.receiverEstimatedMaxBitrate =
118 rtcpPacketInformation.receiverEstimatedMaxBitrate; 120 rtcpPacketInformation.receiverEstimatedMaxBitrate;
119 rtcp_packet_info_.ntp_secs = rtcpPacketInformation.ntp_secs; 121 rtcp_packet_info_.ntp_secs = rtcpPacketInformation.ntp_secs;
120 rtcp_packet_info_.ntp_frac = rtcpPacketInformation.ntp_frac; 122 rtcp_packet_info_.ntp_frac = rtcpPacketInformation.ntp_frac;
121 rtcp_packet_info_.rtp_timestamp = rtcpPacketInformation.rtp_timestamp; 123 rtcp_packet_info_.rtp_timestamp = rtcpPacketInformation.rtp_timestamp;
122 rtcp_packet_info_.xr_dlrr_item = rtcpPacketInformation.xr_dlrr_item; 124 rtcp_packet_info_.xr_dlrr_item = rtcpPacketInformation.xr_dlrr_item;
123 if (rtcpPacketInformation.VoIPMetric) { 125 if (rtcpPacketInformation.VoIPMetric)
124 rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric); 126 rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric);
125 } 127 rtcp_packet_info_.transport_feedback_.reset(
128 rtcpPacketInformation.transport_feedback_.release());
126 return 0; 129 return 0;
127 } 130 }
128 131
129 OverUseDetectorOptions over_use_detector_options_; 132 OverUseDetectorOptions over_use_detector_options_;
130 SimulatedClock system_clock_; 133 SimulatedClock system_clock_;
131 ModuleRtpRtcpImpl* rtp_rtcp_impl_; 134 ModuleRtpRtcpImpl* rtp_rtcp_impl_;
132 RTCPReceiver* rtcp_receiver_; 135 RTCPReceiver* rtcp_receiver_;
133 TestTransport* test_transport_; 136 TestTransport* test_transport_;
134 RTCPHelp::RTCPPacketInformation rtcp_packet_info_; 137 RTCPHelp::RTCPPacketInformation rtcp_packet_info_;
135 MockRemoteBitrateObserver remote_bitrate_observer_; 138 MockRemoteBitrateObserver remote_bitrate_observer_;
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 1024
1022 rtcp::ReceiverReport rr2; 1025 rtcp::ReceiverReport rr2;
1023 rr2.From(kSenderSsrc); 1026 rr2.From(kSenderSsrc);
1024 rr2.WithReportBlock(rb2); 1027 rr2.WithReportBlock(rb2);
1025 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); 1028 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build());
1026 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); 1029 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length()));
1027 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss, 1030 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss,
1028 kCumulativeLoss, kJitter)); 1031 kCumulativeLoss, kJitter));
1029 } 1032 }
1030 1033
1034 TEST_F(RtcpReceiverTest, ReceivesTransportFeedback) {
1035 const uint32_t kSenderSsrc = 0x10203;
1036 const uint32_t kSourceSsrc = 0x123456;
1037
1038 std::set<uint32_t> ssrcs;
1039 ssrcs.insert(kSourceSsrc);
1040 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
1041
1042 // Send a compound packet with a TransportFeedback followed by something else.
stefan-webrtc 2015/09/30 10:45:27 Where's the "followed by something else" part? I o
sprang_webrtc 2015/09/30 11:09:27 Copy/paste mistake. Removed comment.
1043 rtcp::TransportFeedback packet;
1044 packet.WithMediaSourceSsrc(kSourceSsrc);
1045 packet.WithPacketSenderSsrc(kSenderSsrc);
1046 packet.WithBase(1, 1000);
1047 packet.WithReceivedPacket(1, 1000);
1048
1049 rtc::scoped_ptr<rtcp::RawPacket> built_packet = packet.Build();
1050 ASSERT_TRUE(built_packet.get() != nullptr);
1051
1052 EXPECT_EQ(0,
1053 InjectRtcpPacket(built_packet->Buffer(), built_packet->Length()));
1054
1055 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback);
1056 EXPECT_TRUE(rtcp_packet_info_.transport_feedback_.get() != nullptr);
1057 }
1058
1059 TEST_F(RtcpReceiverTest, HandlesInvalidTransportFeedback) {
1060 const uint32_t kSenderSsrc = 0x10203;
1061 const uint32_t kSourceSsrc = 0x123456;
1062
1063 std::set<uint32_t> ssrcs;
1064 ssrcs.insert(kSourceSsrc);
1065 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
1066
1067 // Send a compound packet with a TransportFeedback followed by something else.
1068 rtcp::TransportFeedback packet;
1069 packet.WithMediaSourceSsrc(kSourceSsrc);
1070 packet.WithPacketSenderSsrc(kSenderSsrc);
1071 packet.WithBase(1, 1000);
1072 packet.WithReceivedPacket(1, 1000);
1073
1074 static uint32_t kBitrateBps = 50000;
1075 rtcp::Remb remb;
1076 remb.From(kSourceSsrc);
1077 remb.WithBitrateBps(kBitrateBps);
1078 packet.Append(&remb);
1079
1080 rtc::scoped_ptr<rtcp::RawPacket> built_packet = packet.Build();
1081 ASSERT_TRUE(built_packet.get() != nullptr);
1082
1083 // Modify the TransportFeedback packet so that it is invalid.
1084 const size_t kStatusCountOffset = 14;
1085 ByteWriter<uint16_t>::WriteBigEndian(
1086 &built_packet->MutableBuffer()[kStatusCountOffset], 42);
stefan-webrtc 2015/09/30 10:45:27 Sounds like we may want to fuzz this code. Maybe a
sprang_webrtc 2015/09/30 11:09:27 Acknowledged.
1087
1088 EXPECT_EQ(0,
1089 InjectRtcpPacket(built_packet->Buffer(), built_packet->Length()));
1090
1091 // Transport feedback should be ignored, but next packet should work.
1092 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback);
1093 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb);
1094 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate);
1095 }
1096
1031 } // Anonymous namespace 1097 } // Anonymous namespace
1032 1098
1033 } // namespace webrtc 1099 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698