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 11 matching lines...) Expand all Loading... |
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
| 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |
36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
37 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" | 38 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" |
38 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 39 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" |
39 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 40 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
40 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 41 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
41 #include "webrtc/system_wrappers/include/ntp_time.h" | 42 #include "webrtc/system_wrappers/include/ntp_time.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | 159 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
159 } | 160 } |
160 | 161 |
161 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { | 162 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { |
162 // Too short feedback packet. | 163 // Too short feedback packet. |
163 const uint8_t bad_packet[] = {0x80, RTCPUtility::PT_RTPFB, 0, 0}; | 164 const uint8_t bad_packet[] = {0x80, RTCPUtility::PT_RTPFB, 0, 0}; |
164 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); | 165 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
165 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); | 166 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
166 } | 167 } |
167 | 168 |
| 169 TEST_F(RtcpReceiverTest, RpsiWithFractionalPaddingIsIgnored) { |
| 170 // Padding size represent fractional number of bytes. |
| 171 const uint8_t kPaddingSizeBits = 0x0b; |
| 172 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3, |
| 173 0x12, 0x34, 0x56, 0x78, |
| 174 0x98, 0x76, 0x54, 0x32, |
| 175 kPaddingSizeBits, 0x00, 0x00, 0x00}; |
| 176 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
| 177 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 178 } |
| 179 |
| 180 TEST_F(RtcpReceiverTest, RpsiWithTooLargePaddingIsIgnored) { |
| 181 // Padding size exceeds packet size. |
| 182 const uint8_t kPaddingSizeBits = 0xa8; |
| 183 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3, |
| 184 0x12, 0x34, 0x56, 0x78, |
| 185 0x98, 0x76, 0x54, 0x32, |
| 186 kPaddingSizeBits, 0x00, 0x00, 0x00}; |
| 187 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
| 188 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 189 } |
| 190 |
| 191 // With parsing using rtcp classes this test will make no sense. |
| 192 // With current stateful parser this test was failing. |
| 193 TEST_F(RtcpReceiverTest, TwoHalfValidRpsiAreIgnored) { |
| 194 const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 2, |
| 195 0x12, 0x34, 0x56, 0x78, |
| 196 0x98, 0x76, 0x54, 0x32, |
| 197 0x83, RTCPUtility::PT_PSFB, 0, 2, |
| 198 0x12, 0x34, 0x56, 0x78, |
| 199 0x98, 0x76, 0x54, 0x32}; |
| 200 EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet))); |
| 201 EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 202 } |
| 203 |
| 204 TEST_F(RtcpReceiverTest, InjectRpsiPacket) { |
| 205 const uint64_t kPictureId = 0x123456789; |
| 206 rtcp::Rpsi rpsi; |
| 207 rpsi.WithPictureId(kPictureId); |
| 208 rtc::Buffer packet = rpsi.Build(); |
| 209 EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size())); |
| 210 EXPECT_EQ(kRtcpRpsi, rtcp_packet_info_.rtcpPacketTypeFlags); |
| 211 } |
| 212 |
168 TEST_F(RtcpReceiverTest, InjectSrPacket) { | 213 TEST_F(RtcpReceiverTest, InjectSrPacket) { |
169 const uint32_t kSenderSsrc = 0x10203; | 214 const uint32_t kSenderSsrc = 0x10203; |
170 rtcp::SenderReport sr; | 215 rtcp::SenderReport sr; |
171 sr.From(kSenderSsrc); | 216 sr.From(kSenderSsrc); |
172 rtc::Buffer packet = sr.Build(); | 217 rtc::Buffer packet = sr.Build(); |
173 EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size())); | 218 EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size())); |
174 // The parser will note the remote SSRC on a SR from other than his | 219 // 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. | 220 // expected peer, but will not flag that he's gotten a packet. |
176 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); | 221 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); |
177 EXPECT_EQ(0U, kRtcpSr & rtcp_packet_info_.rtcpPacketTypeFlags); | 222 EXPECT_EQ(0U, kRtcpSr & rtcp_packet_info_.rtcpPacketTypeFlags); |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1277 |
1233 // Transport feedback should be ignored, but next packet should work. | 1278 // Transport feedback should be ignored, but next packet should work. |
1234 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); | 1279 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); |
1235 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); | 1280 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); |
1236 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); | 1281 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); |
1237 } | 1282 } |
1238 | 1283 |
1239 } // Anonymous namespace | 1284 } // Anonymous namespace |
1240 | 1285 |
1241 } // namespace webrtc | 1286 } // namespace webrtc |
OLD | NEW |