Chromium Code Reviews| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | 157 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
| 158 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | 158 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { | 161 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { |
| 162 // Too short feedback packet. | 162 // Too short feedback packet. |
| 163 const uint8_t bad_packet[] = {0x80, RTCPUtility::PT_RTPFB, 0, 0}; | 163 const uint8_t bad_packet[] = {0x80, RTCPUtility::PT_RTPFB, 0, 0}; |
| 164 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | 164 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
| 165 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | 165 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 166 } | 166 } |
| 167 | 167 |
|
åsapersson
2016/04/11 09:22:55
Would also be good to tests a valid rpsi packet.
danilchap
2016/04/11 11:00:31
Done.
| |
| 168 TEST_F(RtcpReceiverTest, RpsiWithFractionalPaddingIsIgnored) { | |
| 169 // Padding size represent fractional number of bytes. | |
| 170 const uint8_t kPaddingSizeBits = 0x0b; | |
| 171 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3, | |
| 172 0x12, 0x34, 0x56, 0x78, | |
| 173 0x98, 0x76, 0x54, 0x32, | |
| 174 kPaddingSizeBits, 0x00, 0x00, 0x00}; | |
| 175 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | |
| 176 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | |
| 177 } | |
| 178 | |
| 179 TEST_F(RtcpReceiverTest, RpsiWithTooLargePaddingIsIgnored) { | |
| 180 // Padding size exceeds packet size. | |
| 181 const uint8_t kPaddingSizeBits = 0xa8; | |
| 182 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3, | |
| 183 0x12, 0x34, 0x56, 0x78, | |
| 184 0x98, 0x76, 0x54, 0x32, | |
| 185 kPaddingSizeBits, 0x00, 0x00, 0x00}; | |
| 186 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | |
| 187 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | |
| 188 } | |
| 189 | |
| 190 // With parsing using rtcp classes this test will make no sense. | |
| 191 // With current stateful parser this test was failing. | |
| 192 TEST_F(RtcpReceiverTest, TooHalfValidRpsiAreIgnored) { | |
|
åsapersson
2016/04/11 09:22:55
Too->Two
danilchap
2016/04/11 11:00:31
oops, Done
| |
| 193 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 2, | |
| 194 0x12, 0x34, 0x56, 0x78, | |
| 195 0x98, 0x76, 0x54, 0x32, | |
| 196 0x83, RTCPUtility::PT_PSFB, 0, 2, | |
| 197 0x12, 0x34, 0x56, 0x78, | |
| 198 0x98, 0x76, 0x54, 0x32}; | |
| 199 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | |
| 200 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | |
| 201 } | |
| 202 | |
| 168 TEST_F(RtcpReceiverTest, InjectSrPacket) { | 203 TEST_F(RtcpReceiverTest, InjectSrPacket) { |
| 169 const uint32_t kSenderSsrc = 0x10203; | 204 const uint32_t kSenderSsrc = 0x10203; |
| 170 rtcp::SenderReport sr; | 205 rtcp::SenderReport sr; |
| 171 sr.From(kSenderSsrc); | 206 sr.From(kSenderSsrc); |
| 172 rtc::Buffer packet = sr.Build(); | 207 rtc::Buffer packet = sr.Build(); |
| 173 EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size())); | 208 EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size())); |
| 174 // The parser will note the remote SSRC on a SR from other than his | 209 // The parser will note the remote SSRC on a SR from other than his |
| 175 // expected peer, but will not flag that he's gotten a packet. | 210 // expected peer, but will not flag that he's gotten a packet. |
| 176 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); | 211 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); |
| 177 EXPECT_EQ(0U, kRtcpSr & rtcp_packet_info_.rtcpPacketTypeFlags); | 212 EXPECT_EQ(0U, kRtcpSr & rtcp_packet_info_.rtcpPacketTypeFlags); |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1232 | 1267 |
| 1233 // Transport feedback should be ignored, but next packet should work. | 1268 // Transport feedback should be ignored, but next packet should work. |
| 1234 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); | 1269 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); |
| 1235 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); | 1270 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); |
| 1236 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); | 1271 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); |
| 1237 } | 1272 } |
| 1238 | 1273 |
| 1239 } // Anonymous namespace | 1274 } // Anonymous namespace |
| 1240 | 1275 |
| 1241 } // namespace webrtc | 1276 } // namespace webrtc |
| OLD | NEW |