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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc

Issue 1294393002: Fixed base time in TransportFeedback message writing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Constant overflow Created 5 years, 3 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 | « webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.cc ('k') | no next file » | 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 // Too large negative delta. 383 // Too large negative delta.
384 packet.reset(new TransportFeedback()); 384 packet.reset(new TransportFeedback());
385 packet->WithBase(0, 0); 385 packet->WithBase(0, 0);
386 int64_t kMaxNegativeTimeDelta = std::numeric_limits<int16_t>::min() * 386 int64_t kMaxNegativeTimeDelta = std::numeric_limits<int16_t>::min() *
387 TransportFeedback::kDeltaScaleFactor; 387 TransportFeedback::kDeltaScaleFactor;
388 EXPECT_FALSE(packet->WithReceivedPacket( 388 EXPECT_FALSE(packet->WithReceivedPacket(
389 1, kMaxNegativeTimeDelta - TransportFeedback::kDeltaScaleFactor)); 389 1, kMaxNegativeTimeDelta - TransportFeedback::kDeltaScaleFactor));
390 EXPECT_TRUE(packet->WithReceivedPacket(1, kMaxNegativeTimeDelta)); 390 EXPECT_TRUE(packet->WithReceivedPacket(1, kMaxNegativeTimeDelta));
391 391
392 // Base time at maximum value.
393 int64_t kMaxBaseTime =
394 static_cast<int64_t>(TransportFeedback::kDeltaScaleFactor) * (1L << 8) *
395 ((1L << 23) - 1);
396 packet.reset(new TransportFeedback());
397 packet->WithBase(0, kMaxBaseTime);
398 packet->WithReceivedPacket(0, kMaxBaseTime);
399 // Serialize and de-serialize (verify 24bit parsing).
400 rtc::scoped_ptr<rtcp::RawPacket> raw_packet = packet->Build();
401 packet =
402 TransportFeedback::ParseFrom(raw_packet->Buffer(), raw_packet->Length());
403 EXPECT_EQ(kMaxBaseTime, packet->GetBaseTimeUs());
404
405 // Base time above maximum value.
406 int64_t kTooLargeBaseTime =
407 kMaxBaseTime + (TransportFeedback::kDeltaScaleFactor * (1L << 8));
408 packet.reset(new TransportFeedback());
409 packet->WithBase(0, kTooLargeBaseTime);
410 packet->WithReceivedPacket(0, kTooLargeBaseTime);
411 raw_packet = packet->Build();
412 packet =
413 TransportFeedback::ParseFrom(raw_packet->Buffer(), raw_packet->Length());
414 EXPECT_NE(kTooLargeBaseTime, packet->GetBaseTimeUs());
415
392 // TODO(sprang): Once we support max length lower than RTCP length limit, 416 // TODO(sprang): Once we support max length lower than RTCP length limit,
393 // add back test for max size in bytes. 417 // add back test for max size in bytes.
394 } 418 }
395 419
396 TEST(RtcpPacketTest, TransportFeedback_Padding) { 420 TEST(RtcpPacketTest, TransportFeedback_Padding) {
397 const size_t kExpectedSizeBytes = 421 const size_t kExpectedSizeBytes =
398 kHeaderSize + kStatusChunkSize + kSmallDeltaSize; 422 kHeaderSize + kStatusChunkSize + kSmallDeltaSize;
399 const size_t kExpectedSizeWords = (kExpectedSizeBytes + 3) / 4; 423 const size_t kExpectedSizeWords = (kExpectedSizeBytes + 3) / 4;
400 424
401 TransportFeedback feedback; 425 TransportFeedback feedback;
(...skipping 23 matching lines...) Expand all
425 ((kPaddingBytes + 3) / 4)); 449 ((kPaddingBytes + 3) / 4));
426 450
427 rtc::scoped_ptr<TransportFeedback> parsed_packet( 451 rtc::scoped_ptr<TransportFeedback> parsed_packet(
428 TransportFeedback::ParseFrom(mod_buffer, kExpectedSizeWithPadding)); 452 TransportFeedback::ParseFrom(mod_buffer, kExpectedSizeWithPadding));
429 ASSERT_TRUE(parsed_packet.get() != nullptr); 453 ASSERT_TRUE(parsed_packet.get() != nullptr);
430 EXPECT_EQ(kExpectedSizeWords * 4, packet->Length()); // Padding not included. 454 EXPECT_EQ(kExpectedSizeWords * 4, packet->Length()); // Padding not included.
431 } 455 }
432 456
433 } // namespace 457 } // namespace
434 } // namespace webrtc 458 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698