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

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

Issue 2589743002: Make OverheadObserver::OnOverheadChanged count RTP headers only (Closed)
Patch Set: Add explicit cast. Created 3 years, 11 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
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 }; 1387 };
1388 } // namespace 1388 } // namespace
1389 1389
1390 TEST_F(RtpSenderTest, OnOverheadChanged) { 1390 TEST_F(RtpSenderTest, OnOverheadChanged) {
1391 MockOverheadObserver mock_overhead_observer; 1391 MockOverheadObserver mock_overhead_observer;
1392 rtp_sender_.reset( 1392 rtp_sender_.reset(
1393 new RTPSender(false, &fake_clock_, &transport_, nullptr, nullptr, nullptr, 1393 new RTPSender(false, &fake_clock_, &transport_, nullptr, nullptr, nullptr,
1394 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 1394 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1395 &retransmission_rate_limiter_, &mock_overhead_observer)); 1395 &retransmission_rate_limiter_, &mock_overhead_observer));
1396 1396
1397 // Transport overhead is set to 28B.
1398 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(28)).Times(1);
1399 rtp_sender_->SetTransportOverhead(28);
1400
1401 // RTP overhead is 12B. 1397 // RTP overhead is 12B.
1402 // 28B + 12B = 40B 1398 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(12)).Times(1);
1403 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(40)).Times(1);
1404 SendGenericPayload(); 1399 SendGenericPayload();
1405 1400
1406 rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset, 1401 rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionTransmissionTimeOffset,
1407 kTransmissionTimeOffsetExtensionId); 1402 kTransmissionTimeOffsetExtensionId);
1408 1403
1409 // TransmissionTimeOffset extension has a size of 8B. 1404 // TransmissionTimeOffset extension has a size of 8B.
1410 // 28B + 12B + 8B = 48B 1405 // 12B + 8B = 20B
1411 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(48)).Times(1); 1406 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(20)).Times(1);
1412 SendGenericPayload(); 1407 SendGenericPayload();
1413 } 1408 }
1414 1409
1415 TEST_F(RtpSenderTest, DoesNotUpdateOverheadOnEqualSize) { 1410 TEST_F(RtpSenderTest, DoesNotUpdateOverheadOnEqualSize) {
1416 MockOverheadObserver mock_overhead_observer; 1411 MockOverheadObserver mock_overhead_observer;
1417 rtp_sender_.reset( 1412 rtp_sender_.reset(
1418 new RTPSender(false, &fake_clock_, &transport_, nullptr, nullptr, nullptr, 1413 new RTPSender(false, &fake_clock_, &transport_, nullptr, nullptr, nullptr,
1419 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 1414 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1420 &retransmission_rate_limiter_, &mock_overhead_observer)); 1415 &retransmission_rate_limiter_, &mock_overhead_observer));
1421 1416
1422 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(_)).Times(1); 1417 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(_)).Times(1);
1423 rtp_sender_->SetTransportOverhead(28);
1424 rtp_sender_->SetTransportOverhead(28);
1425
1426 EXPECT_CALL(mock_overhead_observer, OnOverheadChanged(_)).Times(1);
1427 SendGenericPayload(); 1418 SendGenericPayload();
1428 SendGenericPayload(); 1419 SendGenericPayload();
1429 } 1420 }
1430 1421
1431 TEST_F(RtpSenderTest, AddOverheadToTransportFeedbackObserver) { 1422 TEST_F(RtpSenderTest, AddOverheadToTransportFeedbackObserver) {
1432 constexpr int kTransportOverheadBytesPerPacket = 28;
1433 constexpr int kRtpOverheadBytesPerPacket = 12 + 8; 1423 constexpr int kRtpOverheadBytesPerPacket = 12 + 8;
1434 test::ScopedFieldTrials override_field_trials( 1424 test::ScopedFieldTrials override_field_trials(
1435 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); 1425 "WebRTC-SendSideBwe-WithOverhead/Enabled/");
1436 testing::NiceMock<MockOverheadObserver> mock_overhead_observer; 1426 testing::NiceMock<MockOverheadObserver> mock_overhead_observer;
1437 rtp_sender_.reset(new RTPSender( 1427 rtp_sender_.reset(new RTPSender(
1438 false, &fake_clock_, &transport_, nullptr, nullptr, &seq_num_allocator_, 1428 false, &fake_clock_, &transport_, nullptr, nullptr, &seq_num_allocator_,
1439 &feedback_observer_, nullptr, nullptr, nullptr, &mock_rtc_event_log_, 1429 &feedback_observer_, nullptr, nullptr, nullptr, &mock_rtc_event_log_,
1440 nullptr, &retransmission_rate_limiter_, &mock_overhead_observer)); 1430 nullptr, &retransmission_rate_limiter_, &mock_overhead_observer));
1441 rtp_sender_->SetTransportOverhead(kTransportOverheadBytesPerPacket);
1442 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( 1431 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
1443 kRtpExtensionTransportSequenceNumber, 1432 kRtpExtensionTransportSequenceNumber,
1444 kTransportSequenceNumberExtensionId)); 1433 kTransportSequenceNumberExtensionId));
1445 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) 1434 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber())
1446 .WillOnce(testing::Return(kTransportSequenceNumber)); 1435 .WillOnce(testing::Return(kTransportSequenceNumber));
1447 EXPECT_CALL(feedback_observer_, 1436 EXPECT_CALL(feedback_observer_,
1448 AddPacket(kTransportSequenceNumber, 1437 AddPacket(kTransportSequenceNumber,
1449 sizeof(kPayloadData) + kGenericHeaderLength + 1438 sizeof(kPayloadData) + kGenericHeaderLength +
1450 kRtpOverheadBytesPerPacket + 1439 kRtpOverheadBytesPerPacket,
1451 kTransportOverheadBytesPerPacket,
1452 PacketInfo::kNotAProbe)) 1440 PacketInfo::kNotAProbe))
1453 .Times(1); 1441 .Times(1);
1454 EXPECT_CALL(mock_overhead_observer, 1442 EXPECT_CALL(mock_overhead_observer,
1455 OnOverheadChanged(kTransportOverheadBytesPerPacket + 1443 OnOverheadChanged(kRtpOverheadBytesPerPacket))
1456 kRtpOverheadBytesPerPacket))
1457 .Times(1); 1444 .Times(1);
1458 SendGenericPayload(); 1445 SendGenericPayload();
1459 } 1446 }
1460 1447
1461 } // namespace webrtc 1448 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698