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

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

Issue 1888793003: Fixed undefined shift in parsing Tmmbr, Tmmbn and Remb (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_utility.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 packet.WithReceivedPacket(1, 1000); 1237 packet.WithReceivedPacket(1, 1000);
1238 1238
1239 rtc::Buffer built_packet = packet.Build(); 1239 rtc::Buffer built_packet = packet.Build();
1240 1240
1241 EXPECT_EQ(0, InjectRtcpPacket(built_packet.data(), built_packet.size())); 1241 EXPECT_EQ(0, InjectRtcpPacket(built_packet.data(), built_packet.size()));
1242 1242
1243 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); 1243 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback);
1244 EXPECT_TRUE(rtcp_packet_info_.transport_feedback_.get() != nullptr); 1244 EXPECT_TRUE(rtcp_packet_info_.transport_feedback_.get() != nullptr);
1245 } 1245 }
1246 1246
1247 TEST_F(RtcpReceiverTest, ReceivesRemb) {
1248 const uint32_t kSenderSsrc = 0x123456;
1249 const uint32_t kBitrateBps = 500000;
1250 rtcp::Remb remb;
1251 remb.From(kSenderSsrc);
1252 remb.WithBitrateBps(kBitrateBps);
1253 rtc::Buffer built_packet = remb.Build();
1254
1255 EXPECT_EQ(0, InjectRtcpPacket(built_packet.data(), built_packet.size()));
1256
1257 EXPECT_EQ(kRtcpRemb, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb);
1258 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate);
1259 }
1260
1247 TEST_F(RtcpReceiverTest, HandlesInvalidTransportFeedback) { 1261 TEST_F(RtcpReceiverTest, HandlesInvalidTransportFeedback) {
1248 const uint32_t kSenderSsrc = 0x10203; 1262 const uint32_t kSenderSsrc = 0x10203;
1249 const uint32_t kSourceSsrc = 0x123456; 1263 const uint32_t kSourceSsrc = 0x123456;
1250 1264
1251 std::set<uint32_t> ssrcs; 1265 std::set<uint32_t> ssrcs;
1252 ssrcs.insert(kSourceSsrc); 1266 ssrcs.insert(kSourceSsrc);
1253 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); 1267 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs);
1254 1268
1255 // Send a compound packet with a TransportFeedback followed by something else. 1269 // Send a compound packet with a TransportFeedback followed by something else.
1256 rtcp::TransportFeedback packet; 1270 rtcp::TransportFeedback packet;
1257 packet.WithMediaSourceSsrc(kSourceSsrc); 1271 packet.WithMediaSourceSsrc(kSourceSsrc);
1258 packet.WithPacketSenderSsrc(kSenderSsrc); 1272 packet.WithPacketSenderSsrc(kSenderSsrc);
1259 packet.WithBase(1, 1000); 1273 packet.WithBase(1, 1000);
1260 packet.WithReceivedPacket(1, 1000); 1274 packet.WithReceivedPacket(1, 1000);
1261 1275
1262 static uint32_t kBitrateBps = 50000; 1276 static uint32_t kBitrateBps = 50000;
1263 rtcp::Remb remb; 1277 rtcp::Remb remb;
1264 remb.From(kSourceSsrc); 1278 remb.From(kSenderSsrc);
1265 remb.WithBitrateBps(kBitrateBps); 1279 remb.WithBitrateBps(kBitrateBps);
1266 rtcp::CompoundPacket compound; 1280 rtcp::CompoundPacket compound;
1267 compound.Append(&packet); 1281 compound.Append(&packet);
1268 compound.Append(&remb); 1282 compound.Append(&remb);
1269 rtc::Buffer built_packet = compound.Build(); 1283 rtc::Buffer built_packet = compound.Build();
1270 1284
1271 // Modify the TransportFeedback packet so that it is invalid. 1285 // Modify the TransportFeedback packet so that it is invalid.
1272 const size_t kStatusCountOffset = 14; 1286 const size_t kStatusCountOffset = 14;
1273 ByteWriter<uint16_t>::WriteBigEndian( 1287 ByteWriter<uint16_t>::WriteBigEndian(
1274 &built_packet.data()[kStatusCountOffset], 42); 1288 &built_packet.data()[kStatusCountOffset], 42);
1275 1289
1276 EXPECT_EQ(0, InjectRtcpPacket(built_packet.data(), built_packet.size())); 1290 EXPECT_EQ(0, InjectRtcpPacket(built_packet.data(), built_packet.size()));
1277 1291
1278 // Transport feedback should be ignored, but next packet should work. 1292 // Transport feedback should be ignored, but next packet should work.
1279 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback); 1293 EXPECT_EQ(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpTransportFeedback);
1280 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb); 1294 EXPECT_NE(0u, rtcp_packet_info_.rtcpPacketTypeFlags & kRtcpRemb);
1281 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate); 1295 EXPECT_EQ(kBitrateBps, rtcp_packet_info_.receiverEstimatedMaxBitrate);
1282 } 1296 }
1283 1297
1284 } // Anonymous namespace 1298 } // Anonymous namespace
1285 1299
1286 } // namespace webrtc 1300 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_utility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698