OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" | 10 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 // Generates a new frame for this stream. If called too soon after the | 46 // Generates a new frame for this stream. If called too soon after the |
47 // previous frame, no frame will be generated. The frame is split into | 47 // previous frame, no frame will be generated. The frame is split into |
48 // packets. | 48 // packets. |
49 int64_t RtpStream::GenerateFrame(int64_t time_now_us, | 49 int64_t RtpStream::GenerateFrame(int64_t time_now_us, |
50 std::vector<PacketInfo>* packets) { | 50 std::vector<PacketInfo>* packets) { |
51 if (time_now_us < next_rtp_time_) { | 51 if (time_now_us < next_rtp_time_) { |
52 return next_rtp_time_; | 52 return next_rtp_time_; |
53 } | 53 } |
54 RTC_CHECK(packets != NULL); | 54 RTC_CHECK(packets != nullptr); |
55 size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; | 55 size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; |
56 size_t n_packets = | 56 size_t n_packets = |
57 std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); | 57 std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); |
58 size_t payload_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets); | 58 size_t payload_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets); |
59 for (size_t i = 0; i < n_packets; ++i) { | 59 for (size_t i = 0; i < n_packets; ++i) { |
60 PacketInfo packet(-1, sequence_number_++); | 60 PacketInfo packet(-1, sequence_number_++); |
61 packet.send_time_ms = (time_now_us + kSendSideOffsetUs) / 1000; | 61 packet.send_time_ms = (time_now_us + kSendSideOffsetUs) / 1000; |
62 packet.payload_size = payload_size; | 62 packet.payload_size = payload_size; |
63 packet.probe_cluster_id = PacketInfo::kNotAProbe; | 63 packet.probe_cluster_id = PacketInfo::kNotAProbe; |
64 packets->push_back(packet); | 64 packets->push_back(packet); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 total_bitrate_after += stream->bitrate_bps(); | 119 total_bitrate_after += stream->bitrate_bps(); |
120 } | 120 } |
121 ASSERT_EQ(bitrate_before, total_bitrate_before); | 121 ASSERT_EQ(bitrate_before, total_bitrate_before); |
122 EXPECT_EQ(total_bitrate_after, bitrate_bps); | 122 EXPECT_EQ(total_bitrate_after, bitrate_bps); |
123 } | 123 } |
124 | 124 |
125 // TODO(holmer): Break out the channel simulation part from this class to make | 125 // TODO(holmer): Break out the channel simulation part from this class to make |
126 // it possible to simulate different types of channels. | 126 // it possible to simulate different types of channels. |
127 int64_t StreamGenerator::GenerateFrame(std::vector<PacketInfo>* packets, | 127 int64_t StreamGenerator::GenerateFrame(std::vector<PacketInfo>* packets, |
128 int64_t time_now_us) { | 128 int64_t time_now_us) { |
129 RTC_CHECK(packets != NULL); | 129 RTC_CHECK(packets != nullptr); |
130 RTC_CHECK(packets->empty()); | 130 RTC_CHECK(packets->empty()); |
131 RTC_CHECK_GT(capacity_, 0); | 131 RTC_CHECK_GT(capacity_, 0); |
132 auto it = | 132 auto it = |
133 std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); | 133 std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); |
134 (*it)->GenerateFrame(time_now_us, packets); | 134 (*it)->GenerateFrame(time_now_us, packets); |
135 int i = 0; | 135 int i = 0; |
136 for (PacketInfo& packet : *packets) { | 136 for (PacketInfo& packet : *packets) { |
137 int capacity_bpus = capacity_ / 1000; | 137 int capacity_bpus = capacity_ / 1000; |
138 int64_t required_network_time_us = | 138 int64_t required_network_time_us = |
139 (8 * 1000 * packet.payload_size + capacity_bpus / 2) / capacity_bpus; | 139 (8 * 1000 * packet.payload_size + capacity_bpus / 2) / capacity_bpus; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, | 493 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, |
494 sequence_number++, 1000); | 494 sequence_number++, 1000); |
495 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); | 495 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); |
496 send_time_ms += kFrameIntervalMs; | 496 send_time_ms += kFrameIntervalMs; |
497 } | 497 } |
498 uint32_t bitrate_after = 0; | 498 uint32_t bitrate_after = 0; |
499 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); | 499 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); |
500 EXPECT_LT(bitrate_after, bitrate_before); | 500 EXPECT_LT(bitrate_after, bitrate_before); |
501 } | 501 } |
502 } // namespace webrtc | 502 } // namespace webrtc |
OLD | NEW |