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 // There is no existing encoder. |
110 return false; | 110 return; |
111 } | |
112 (*encoder)->SetProjectedPacketLossRate(expected_loss_rate / 100.0f); | |
113 success = true; | |
114 }); | |
115 return success; | |
kwiberg-webrtc
2016/10/06 09:46:13
Excellent.
minyue-webrtc
2016/10/11 17:04:34
Hi Karl,
I know that you liked this change, me to
| |
111 } | 116 } |
112 | 117 |
113 PacketLossTest::PacketLossTest(int channels, int expected_loss_rate, | 118 PacketLossTest::PacketLossTest(int channels, int expected_loss_rate, |
114 int actual_loss_rate, int burst_length) | 119 int actual_loss_rate, int burst_length) |
115 : channels_(channels), | 120 : channels_(channels), |
116 in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" : | 121 in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" : |
117 "audio_coding/teststereo32kHz"), | 122 "audio_coding/teststereo32kHz"), |
118 sample_rate_hz_(32000), | 123 sample_rate_hz_(32000), |
119 sender_(new SenderWithFEC), | 124 sender_(new SenderWithFEC), |
120 receiver_(new ReceiverWithPacketLoss), | 125 receiver_(new ReceiverWithPacketLoss), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 | 164 |
160 receiver_->Setup(acm.get(), &rtpFile, "packetLoss_out", channels_, | 165 receiver_->Setup(acm.get(), &rtpFile, "packetLoss_out", channels_, |
161 actual_loss_rate_, burst_length_); | 166 actual_loss_rate_, burst_length_); |
162 receiver_->Run(); | 167 receiver_->Run(); |
163 receiver_->Teardown(); | 168 receiver_->Teardown(); |
164 rtpFile.Close(); | 169 rtpFile.Close(); |
165 #endif | 170 #endif |
166 } | 171 } |
167 | 172 |
168 } // namespace webrtc | 173 } // namespace webrtc |
OLD | NEW |