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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 private: | 99 private: |
100 int packets_sent_; | 100 int packets_sent_; |
101 int padding_sent_; | 101 int padding_sent_; |
102 }; | 102 }; |
103 | 103 |
104 class PacedSenderTest : public ::testing::Test { | 104 class PacedSenderTest : public ::testing::Test { |
105 protected: | 105 protected: |
106 PacedSenderTest() : clock_(123456) { | 106 PacedSenderTest() : clock_(123456) { |
107 srand(0); | 107 srand(0); |
108 // Need to initialize PacedSender after we initialize clock. | 108 // Need to initialize PacedSender after we initialize clock. |
109 send_bucket_.reset(new PacedSender(&clock_, &callback_, nullptr)); | 109 send_bucket_.reset(new PacedSender(&clock_, &callback_)); |
110 send_bucket_->CreateProbeCluster(kFirstClusterBps); | 110 send_bucket_->CreateProbeCluster(kFirstClusterBps); |
111 send_bucket_->CreateProbeCluster(kSecondClusterBps); | 111 send_bucket_->CreateProbeCluster(kSecondClusterBps); |
112 // Default to bitrate probing disabled for testing purposes. Probing tests | 112 // Default to bitrate probing disabled for testing purposes. Probing tests |
113 // have to enable probing, either by creating a new PacedSender instance or | 113 // have to enable probing, either by creating a new PacedSender instance or |
114 // by calling SetProbingEnabled(true). | 114 // by calling SetProbingEnabled(true). |
115 send_bucket_->SetProbingEnabled(false); | 115 send_bucket_->SetProbingEnabled(false); |
116 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps); | 116 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps); |
117 | 117 |
118 clock_.AdvanceTimeMilliseconds(send_bucket_->TimeUntilNextProcess()); | 118 clock_.AdvanceTimeMilliseconds(send_bucket_->TimeUntilNextProcess()); |
119 } | 119 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) { | 406 TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) { |
407 uint32_t ssrc = 12345; | 407 uint32_t ssrc = 12345; |
408 uint16_t sequence_number = 1234; | 408 uint16_t sequence_number = 1234; |
409 int64_t capture_time_ms = 56789; | 409 int64_t capture_time_ms = 56789; |
410 const int kTimeStep = 5; | 410 const int kTimeStep = 5; |
411 const int64_t kBitrateWindow = 10000; | 411 const int64_t kBitrateWindow = 10000; |
412 PacedSenderPadding callback; | 412 PacedSenderPadding callback; |
413 send_bucket_.reset(new PacedSender(&clock_, &callback, nullptr)); | 413 send_bucket_.reset(new PacedSender(&clock_, &callback)); |
414 send_bucket_->SetProbingEnabled(false); | 414 send_bucket_->SetProbingEnabled(false); |
415 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps); | 415 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps); |
416 | 416 |
417 send_bucket_->SetSendBitrateLimits( | 417 send_bucket_->SetSendBitrateLimits( |
418 0 /*allocated_bitrate_bps*/, | 418 0 /*allocated_bitrate_bps*/, |
419 kTargetBitrateBps * 2 /* max_padding_bitrate_bps */); | 419 kTargetBitrateBps * 2 /* max_padding_bitrate_bps */); |
420 | 420 |
421 int64_t start_time = clock_.TimeInMilliseconds(); | 421 int64_t start_time = clock_.TimeInMilliseconds(); |
422 size_t media_bytes = 0; | 422 size_t media_bytes = 0; |
423 while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) { | 423 while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 798 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
799 } | 799 } |
800 | 800 |
801 TEST_F(PacedSenderTest, ProbingWithInsertedPackets) { | 801 TEST_F(PacedSenderTest, ProbingWithInsertedPackets) { |
802 const size_t kPacketSize = 1200; | 802 const size_t kPacketSize = 1200; |
803 const int kInitialBitrateBps = 300000; | 803 const int kInitialBitrateBps = 300000; |
804 uint32_t ssrc = 12346; | 804 uint32_t ssrc = 12346; |
805 uint16_t sequence_number = 1234; | 805 uint16_t sequence_number = 1234; |
806 | 806 |
807 PacedSenderProbing packet_sender; | 807 PacedSenderProbing packet_sender; |
808 send_bucket_.reset(new PacedSender(&clock_, &packet_sender, nullptr)); | 808 send_bucket_.reset(new PacedSender(&clock_, &packet_sender)); |
809 send_bucket_->CreateProbeCluster(kFirstClusterBps); | 809 send_bucket_->CreateProbeCluster(kFirstClusterBps); |
810 send_bucket_->CreateProbeCluster(kSecondClusterBps); | 810 send_bucket_->CreateProbeCluster(kSecondClusterBps); |
811 send_bucket_->SetEstimatedBitrate(kInitialBitrateBps); | 811 send_bucket_->SetEstimatedBitrate(kInitialBitrateBps); |
812 | 812 |
813 for (int i = 0; i < 10; ++i) { | 813 for (int i = 0; i < 10; ++i) { |
814 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, | 814 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
815 sequence_number++, clock_.TimeInMilliseconds(), | 815 sequence_number++, clock_.TimeInMilliseconds(), |
816 kPacketSize, false); | 816 kPacketSize, false); |
817 } | 817 } |
818 | 818 |
(...skipping 25 matching lines...) Expand all Loading... |
844 kSecondClusterBps, kBitrateProbingError); | 844 kSecondClusterBps, kBitrateProbingError); |
845 } | 845 } |
846 | 846 |
847 TEST_F(PacedSenderTest, ProbingWithPaddingSupport) { | 847 TEST_F(PacedSenderTest, ProbingWithPaddingSupport) { |
848 const size_t kPacketSize = 1200; | 848 const size_t kPacketSize = 1200; |
849 const int kInitialBitrateBps = 300000; | 849 const int kInitialBitrateBps = 300000; |
850 uint32_t ssrc = 12346; | 850 uint32_t ssrc = 12346; |
851 uint16_t sequence_number = 1234; | 851 uint16_t sequence_number = 1234; |
852 | 852 |
853 PacedSenderProbing packet_sender; | 853 PacedSenderProbing packet_sender; |
854 send_bucket_.reset(new PacedSender(&clock_, &packet_sender, nullptr)); | 854 send_bucket_.reset(new PacedSender(&clock_, &packet_sender)); |
855 send_bucket_->CreateProbeCluster(kFirstClusterBps); | 855 send_bucket_->CreateProbeCluster(kFirstClusterBps); |
856 send_bucket_->SetEstimatedBitrate(kInitialBitrateBps); | 856 send_bucket_->SetEstimatedBitrate(kInitialBitrateBps); |
857 | 857 |
858 for (int i = 0; i < 3; ++i) { | 858 for (int i = 0; i < 3; ++i) { |
859 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, | 859 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
860 sequence_number++, clock_.TimeInMilliseconds(), | 860 sequence_number++, clock_.TimeInMilliseconds(), |
861 kPacketSize, false); | 861 kPacketSize, false); |
862 } | 862 } |
863 | 863 |
864 int64_t start = clock_.TimeInMilliseconds(); | 864 int64_t start = clock_.TimeInMilliseconds(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 .WillRepeatedly(Return(0)); | 1070 .WillRepeatedly(Return(0)); |
1071 send_bucket_->Process(); | 1071 send_bucket_->Process(); |
1072 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); | 1072 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); |
1073 clock_.AdvanceTimeMilliseconds(1); | 1073 clock_.AdvanceTimeMilliseconds(1); |
1074 send_bucket_->Process(); | 1074 send_bucket_->Process(); |
1075 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 1075 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
1076 } | 1076 } |
1077 | 1077 |
1078 } // namespace test | 1078 } // namespace test |
1079 } // namespace webrtc | 1079 } // namespace webrtc |
OLD | NEW |