OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 bool SenderWithFEC::SetFEC(bool enable_fec) { | 98 bool SenderWithFEC::SetFEC(bool enable_fec) { |
99 if (_acm->SetCodecFEC(enable_fec) == 0) { | 99 if (_acm->SetCodecFEC(enable_fec) == 0) { |
100 return true; | 100 return true; |
101 } | 101 } |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 bool SenderWithFEC::SetPacketLossRate(int expected_loss_rate) { | 105 bool SenderWithFEC::SetPacketLossRate(int expected_loss_rate) { |
106 if (_acm->SetPacketLossRate(expected_loss_rate) == 0) { | 106 bool success = false; |
107 expected_loss_rate_ = expected_loss_rate; | 107 _acm->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
108 return true; | 108 if (*encoder) { |
109 } | 109 (*encoder)->SetProjectedPacketLossRate(expected_loss_rate / 100.0f); |
110 return false; | 110 success = true; |
| 111 } |
| 112 }); |
| 113 return success; |
111 } | 114 } |
112 | 115 |
113 PacketLossTest::PacketLossTest(int channels, int expected_loss_rate, | 116 PacketLossTest::PacketLossTest(int channels, int expected_loss_rate, |
114 int actual_loss_rate, int burst_length) | 117 int actual_loss_rate, int burst_length) |
115 : channels_(channels), | 118 : channels_(channels), |
116 in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" : | 119 in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" : |
117 "audio_coding/teststereo32kHz"), | 120 "audio_coding/teststereo32kHz"), |
118 sample_rate_hz_(32000), | 121 sample_rate_hz_(32000), |
119 sender_(new SenderWithFEC), | 122 sender_(new SenderWithFEC), |
120 receiver_(new ReceiverWithPacketLoss), | 123 receiver_(new ReceiverWithPacketLoss), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 162 |
160 receiver_->Setup(acm.get(), &rtpFile, "packetLoss_out", channels_, | 163 receiver_->Setup(acm.get(), &rtpFile, "packetLoss_out", channels_, |
161 actual_loss_rate_, burst_length_); | 164 actual_loss_rate_, burst_length_); |
162 receiver_->Run(); | 165 receiver_->Run(); |
163 receiver_->Teardown(); | 166 receiver_->Teardown(); |
164 rtpFile.Close(); | 167 rtpFile.Close(); |
165 #endif | 168 #endif |
166 } | 169 } |
167 | 170 |
168 } // namespace webrtc | 171 } // namespace webrtc |
OLD | NEW |