| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 <string> | 10 #include <string> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const size_t kOpusRateKhz = 48; | 29 const size_t kOpusRateKhz = 48; |
| 30 // Number of samples-per-channel in a 20 ms frame, sampled at 48 kHz. | 30 // Number of samples-per-channel in a 20 ms frame, sampled at 48 kHz. |
| 31 const size_t kOpus20msFrameSamples = kOpusRateKhz * 20; | 31 const size_t kOpus20msFrameSamples = kOpusRateKhz * 20; |
| 32 // Number of samples-per-channel in a 10 ms frame, sampled at 48 kHz. | 32 // Number of samples-per-channel in a 10 ms frame, sampled at 48 kHz. |
| 33 const size_t kOpus10msFrameSamples = kOpusRateKhz * 10; | 33 const size_t kOpus10msFrameSamples = kOpusRateKhz * 10; |
| 34 | 34 |
| 35 class OpusTest : public TestWithParam<::testing::tuple<int, int>> { | 35 class OpusTest : public TestWithParam<::testing::tuple<int, int>> { |
| 36 protected: | 36 protected: |
| 37 OpusTest(); | 37 OpusTest(); |
| 38 | 38 |
| 39 void TestDtxEffect(bool dtx); | 39 void TestDtxEffect(bool dtx, int block_length_ms); |
| 40 | 40 |
| 41 // Prepare |speech_data_| for encoding, read from a hard-coded file. | 41 // Prepare |speech_data_| for encoding, read from a hard-coded file. |
| 42 // After preparation, |speech_data_.GetNextBlock()| returns a pointer to a | 42 // After preparation, |speech_data_.GetNextBlock()| returns a pointer to a |
| 43 // block of |block_length_ms| milliseconds. The data is looped every | 43 // block of |block_length_ms| milliseconds. The data is looped every |
| 44 // |loop_length_ms| milliseconds. | 44 // |loop_length_ms| milliseconds. |
| 45 void PrepareSpeechData(int channel, int block_length_ms, int loop_length_ms); | 45 void PrepareSpeechData(int channel, int block_length_ms, int loop_length_ms); |
| 46 | 46 |
| 47 int EncodeDecode(WebRtcOpusEncInst* encoder, | 47 int EncodeDecode(WebRtcOpusEncInst* encoder, |
| 48 rtc::ArrayView<const int16_t> input_audio, | 48 rtc::ArrayView<const int16_t> input_audio, |
| 49 WebRtcOpusDecInst* decoder, | 49 WebRtcOpusDecInst* decoder, |
| 50 int16_t* output_audio, | 50 int16_t* output_audio, |
| 51 int16_t* audio_type); | 51 int16_t* audio_type); |
| 52 | 52 |
| 53 void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, | 53 void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, |
| 54 opus_int32 expect, int32_t set); | 54 opus_int32 expect, int32_t set); |
| 55 | 55 |
| 56 void CheckAudioBounded(const int16_t* audio, size_t samples, int channels, |
| 57 uint16_t bound) const; |
| 58 |
| 56 WebRtcOpusEncInst* opus_encoder_; | 59 WebRtcOpusEncInst* opus_encoder_; |
| 57 WebRtcOpusDecInst* opus_decoder_; | 60 WebRtcOpusDecInst* opus_decoder_; |
| 58 | 61 |
| 59 AudioLoop speech_data_; | 62 AudioLoop speech_data_; |
| 60 uint8_t bitstream_[kMaxBytes]; | 63 uint8_t bitstream_[kMaxBytes]; |
| 61 size_t encoded_bytes_; | 64 size_t encoded_bytes_; |
| 62 int channels_; | 65 int channels_; |
| 63 int application_; | 66 int application_; |
| 64 }; | 67 }; |
| 65 | 68 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 void OpusTest::SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, | 91 void OpusTest::SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, |
| 89 opus_int32 expect, | 92 opus_int32 expect, |
| 90 int32_t set) { | 93 int32_t set) { |
| 91 opus_int32 bandwidth; | 94 opus_int32 bandwidth; |
| 92 EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set)); | 95 EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set)); |
| 93 opus_encoder_ctl(opus_encoder_->encoder, | 96 opus_encoder_ctl(opus_encoder_->encoder, |
| 94 OPUS_GET_MAX_BANDWIDTH(&bandwidth)); | 97 OPUS_GET_MAX_BANDWIDTH(&bandwidth)); |
| 95 EXPECT_EQ(expect, bandwidth); | 98 EXPECT_EQ(expect, bandwidth); |
| 96 } | 99 } |
| 97 | 100 |
| 101 void OpusTest::CheckAudioBounded(const int16_t* audio, size_t samples, |
| 102 int channels, uint16_t bound) const { |
| 103 for (size_t i = 0; i < samples; ++i) { |
| 104 for (int c = 0; c < channels; ++c) { |
| 105 ASSERT_GE(audio[i * channels + c], -bound); |
| 106 ASSERT_LE(audio[i * channels + c], bound); |
| 107 } |
| 108 } |
| 109 } |
| 110 |
| 98 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, | 111 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, |
| 99 rtc::ArrayView<const int16_t> input_audio, | 112 rtc::ArrayView<const int16_t> input_audio, |
| 100 WebRtcOpusDecInst* decoder, | 113 WebRtcOpusDecInst* decoder, |
| 101 int16_t* output_audio, | 114 int16_t* output_audio, |
| 102 int16_t* audio_type) { | 115 int16_t* audio_type) { |
| 103 int encoded_bytes_int = WebRtcOpus_Encode( | 116 int encoded_bytes_int = WebRtcOpus_Encode( |
| 104 encoder, input_audio.data(), | 117 encoder, input_audio.data(), |
| 105 rtc::CheckedDivExact(input_audio.size(), static_cast<size_t>(channels_)), | 118 rtc::CheckedDivExact(input_audio.size(), static_cast<size_t>(channels_)), |
| 106 kMaxBytes, bitstream_); | 119 kMaxBytes, bitstream_); |
| 107 EXPECT_GE(encoded_bytes_int, 0); | 120 EXPECT_GE(encoded_bytes_int, 0); |
| 108 encoded_bytes_ = static_cast<size_t>(encoded_bytes_int); | 121 encoded_bytes_ = static_cast<size_t>(encoded_bytes_int); |
| 109 int est_len = WebRtcOpus_DurationEst(decoder, bitstream_, encoded_bytes_); | 122 int est_len = WebRtcOpus_DurationEst(decoder, bitstream_, encoded_bytes_); |
| 110 int act_len = WebRtcOpus_Decode(decoder, bitstream_, | 123 int act_len = WebRtcOpus_Decode(decoder, bitstream_, |
| 111 encoded_bytes_, output_audio, | 124 encoded_bytes_, output_audio, |
| 112 audio_type); | 125 audio_type); |
| 113 EXPECT_EQ(est_len, act_len); | 126 EXPECT_EQ(est_len, act_len); |
| 114 return act_len; | 127 return act_len; |
| 115 } | 128 } |
| 116 | 129 |
| 117 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when | 130 // Test if encoder/decoder can enter DTX mode properly and do not enter DTX when |
| 118 // they should not. This test is signal dependent. | 131 // they should not. This test is signal dependent. |
| 119 void OpusTest::TestDtxEffect(bool dtx) { | 132 void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { |
| 120 PrepareSpeechData(channels_, 20, 2000); | 133 PrepareSpeechData(channels_, block_length_ms, 2000); |
| 134 const size_t samples = kOpusRateKhz * block_length_ms; |
| 121 | 135 |
| 122 // Create encoder memory. | 136 // Create encoder memory. |
| 123 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 137 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 124 channels_, | 138 channels_, |
| 125 application_)); | 139 application_)); |
| 126 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 140 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
| 127 | 141 |
| 128 // Set bitrate. | 142 // Set bitrate. |
| 129 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, | 143 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, |
| 130 channels_ == 1 ? 32000 : 64000)); | 144 channels_ == 1 ? 32000 : 64000)); |
| 131 | 145 |
| 132 // Set input audio as silence. | 146 // Set input audio as silence. |
| 133 std::vector<int16_t> silence(kOpus20msFrameSamples * channels_, 0); | 147 std::vector<int16_t> silence(samples * channels_, 0); |
| 134 | 148 |
| 135 // Setting DTX. | 149 // Setting DTX. |
| 136 EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_) : | 150 EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_) : |
| 137 WebRtcOpus_DisableDtx(opus_encoder_)); | 151 WebRtcOpus_DisableDtx(opus_encoder_)); |
| 138 | 152 |
| 139 int16_t audio_type; | 153 int16_t audio_type; |
| 140 int16_t* output_data_decode = new int16_t[kOpus20msFrameSamples * channels_]; | 154 int16_t* output_data_decode = new int16_t[samples * channels_]; |
| 141 | 155 |
| 142 for (int i = 0; i < 100; ++i) { | 156 for (int i = 0; i < 100; ++i) { |
| 143 EXPECT_EQ(kOpus20msFrameSamples, | 157 EXPECT_EQ(samples, |
| 144 static_cast<size_t>(EncodeDecode( | 158 static_cast<size_t>(EncodeDecode( |
| 145 opus_encoder_, speech_data_.GetNextBlock(), opus_decoder_, | 159 opus_encoder_, speech_data_.GetNextBlock(), opus_decoder_, |
| 146 output_data_decode, &audio_type))); | 160 output_data_decode, &audio_type))); |
| 147 // If not DTX, it should never enter DTX mode. If DTX, we do not care since | 161 // If not DTX, it should never enter DTX mode. If DTX, we do not care since |
| 148 // whether it enters DTX depends on the signal type. | 162 // whether it enters DTX depends on the signal type. |
| 149 if (!dtx) { | 163 if (!dtx) { |
| 150 EXPECT_GT(encoded_bytes_, 1U); | 164 EXPECT_GT(encoded_bytes_, 1U); |
| 151 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 165 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 152 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 166 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 153 EXPECT_EQ(0, audio_type); // Speech. | 167 EXPECT_EQ(0, audio_type); // Speech. |
| 154 } | 168 } |
| 155 } | 169 } |
| 156 | 170 |
| 157 // We input some silent segments. In DTX mode, the encoder will stop sending. | 171 // We input some silent segments. In DTX mode, the encoder will stop sending. |
| 158 // However, DTX may happen after a while. | 172 // However, DTX may happen after a while. |
| 159 for (int i = 0; i < 30; ++i) { | 173 for (int i = 0; i < 30; ++i) { |
| 160 EXPECT_EQ(kOpus20msFrameSamples, static_cast<size_t>(EncodeDecode( | 174 EXPECT_EQ(samples, |
| 161 opus_encoder_, silence, opus_decoder_, | 175 static_cast<size_t>(EncodeDecode( |
| 162 output_data_decode, &audio_type))); | 176 opus_encoder_, silence, opus_decoder_, output_data_decode, |
| 177 &audio_type))); |
| 163 if (!dtx) { | 178 if (!dtx) { |
| 164 EXPECT_GT(encoded_bytes_, 1U); | 179 EXPECT_GT(encoded_bytes_, 1U); |
| 165 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 180 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 166 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 181 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 167 EXPECT_EQ(0, audio_type); // Speech. | 182 EXPECT_EQ(0, audio_type); // Speech. |
| 168 } else if (encoded_bytes_ == 1) { | 183 } else if (encoded_bytes_ == 1) { |
| 169 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); | 184 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); |
| 170 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); | 185 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); |
| 171 EXPECT_EQ(2, audio_type); // Comfort noise. | 186 EXPECT_EQ(2, audio_type); // Comfort noise. |
| 172 break; | 187 break; |
| 173 } | 188 } |
| 174 } | 189 } |
| 175 | 190 |
| 176 // When Opus is in DTX, it wakes up in a regular basis. It sends two packets, | 191 // When Opus is in DTX, it wakes up in a regular basis. It sends two packets, |
| 177 // one with an arbitrary size and the other of 1-byte, then stops sending for | 192 // one with an arbitrary size and the other of 1-byte, then stops sending for |
| 178 // 19 frames. | 193 // a certain number of frames. |
| 179 const int cycles = 5; | 194 |
| 180 for (int j = 0; j < cycles; ++j) { | 195 // |max_dtx_frames| is the maximum number of frames Opus can stay in DTX. |
| 181 // DTX mode is maintained 19 frames. | 196 const int max_dtx_frames = 400 / block_length_ms + 1; |
| 182 for (int i = 0; i < 19; ++i) { | 197 |
| 183 EXPECT_EQ(kOpus20msFrameSamples, | 198 // We run |kRunTimeMs| milliseconds of pure silence. |
| 184 static_cast<size_t>( | 199 const int kRunTimeMs = 2000; |
| 185 EncodeDecode(opus_encoder_, silence, opus_decoder_, | 200 |
| 186 output_data_decode, &audio_type))); | 201 // We check that, after a |kCheckTimeMs| milliseconds (given that the CNG in |
| 202 // Opus needs time to adapt), the absolute values of DTX decoded signal are |
| 203 // bounded by |kOutputValueBound|. |
| 204 const int kCheckTimeMs = 1500; |
| 205 |
| 206 #if defined(OPUS_FIXED_POINT) |
| 207 const uint16_t kOutputValueBound = 20; |
| 208 #else |
| 209 const uint16_t kOutputValueBound = 2; |
| 210 #endif |
| 211 |
| 212 int time = 0; |
| 213 while (time < kRunTimeMs) { |
| 214 // DTX mode is maintained for maximum |max_dtx_frames| frames. |
| 215 int i = 0; |
| 216 for (; i < max_dtx_frames; ++i) { |
| 217 time += block_length_ms; |
| 218 EXPECT_EQ(samples, |
| 219 static_cast<size_t>(EncodeDecode( |
| 220 opus_encoder_, silence, opus_decoder_, output_data_decode, |
| 221 &audio_type))); |
| 187 if (dtx) { | 222 if (dtx) { |
| 223 if (encoded_bytes_ > 1) |
| 224 break; |
| 188 EXPECT_EQ(0U, encoded_bytes_) // Send 0 byte. | 225 EXPECT_EQ(0U, encoded_bytes_) // Send 0 byte. |
| 189 << "Opus should have entered DTX mode."; | 226 << "Opus should have entered DTX mode."; |
| 190 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); | 227 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); |
| 191 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); | 228 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); |
| 192 EXPECT_EQ(2, audio_type); // Comfort noise. | 229 EXPECT_EQ(2, audio_type); // Comfort noise. |
| 230 if (time >= kCheckTimeMs) { |
| 231 CheckAudioBounded(output_data_decode, samples, channels_, |
| 232 kOutputValueBound); |
| 233 } |
| 193 } else { | 234 } else { |
| 194 EXPECT_GT(encoded_bytes_, 1U); | 235 EXPECT_GT(encoded_bytes_, 1U); |
| 195 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 236 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 196 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 237 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 197 EXPECT_EQ(0, audio_type); // Speech. | 238 EXPECT_EQ(0, audio_type); // Speech. |
| 198 } | 239 } |
| 199 } | 240 } |
| 200 | 241 |
| 201 // Quit DTX after 19 frames. | 242 if (dtx) { |
| 202 EXPECT_EQ(kOpus20msFrameSamples, static_cast<size_t>(EncodeDecode( | 243 // With DTX, Opus must stop transmission for some time. |
| 203 opus_encoder_, silence, opus_decoder_, | 244 EXPECT_GT(i, 1); |
| 204 output_data_decode, &audio_type))); | 245 } |
| 205 | 246 |
| 206 EXPECT_GT(encoded_bytes_, 1U); | 247 // We expect a normal payload. |
| 207 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 248 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 208 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 249 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 209 EXPECT_EQ(0, audio_type); // Speech. | 250 EXPECT_EQ(0, audio_type); // Speech. |
| 210 | 251 |
| 211 // Enters DTX again immediately. | 252 // Enters DTX again immediately. |
| 212 EXPECT_EQ(kOpus20msFrameSamples, static_cast<size_t>(EncodeDecode( | 253 time += block_length_ms; |
| 213 opus_encoder_, silence, opus_decoder_, | 254 EXPECT_EQ(samples, |
| 214 output_data_decode, &audio_type))); | 255 static_cast<size_t>(EncodeDecode( |
| 256 opus_encoder_, silence, opus_decoder_, output_data_decode, |
| 257 &audio_type))); |
| 215 if (dtx) { | 258 if (dtx) { |
| 216 EXPECT_EQ(1U, encoded_bytes_); // Send 1 byte. | 259 EXPECT_EQ(1U, encoded_bytes_); // Send 1 byte. |
| 217 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); | 260 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); |
| 218 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); | 261 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); |
| 219 EXPECT_EQ(2, audio_type); // Comfort noise. | 262 EXPECT_EQ(2, audio_type); // Comfort noise. |
| 263 if (time >= kCheckTimeMs) { |
| 264 CheckAudioBounded(output_data_decode, samples, channels_, |
| 265 kOutputValueBound); |
| 266 } |
| 220 } else { | 267 } else { |
| 221 EXPECT_GT(encoded_bytes_, 1U); | 268 EXPECT_GT(encoded_bytes_, 1U); |
| 222 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 269 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 223 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 270 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 224 EXPECT_EQ(0, audio_type); // Speech. | 271 EXPECT_EQ(0, audio_type); // Speech. |
| 225 } | 272 } |
| 226 } | 273 } |
| 227 | 274 |
| 228 silence[0] = 10000; | 275 silence[0] = 10000; |
| 229 if (dtx) { | 276 if (dtx) { |
| 230 // Verify that encoder/decoder can jump out from DTX mode. | 277 // Verify that encoder/decoder can jump out from DTX mode. |
| 231 EXPECT_EQ(kOpus20msFrameSamples, static_cast<size_t>(EncodeDecode( | 278 EXPECT_EQ(samples, |
| 232 opus_encoder_, silence, opus_decoder_, | 279 static_cast<size_t>(EncodeDecode( |
| 233 output_data_decode, &audio_type))); | 280 opus_encoder_, silence, opus_decoder_, output_data_decode, |
| 281 &audio_type))); |
| 234 EXPECT_GT(encoded_bytes_, 1U); | 282 EXPECT_GT(encoded_bytes_, 1U); |
| 235 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); | 283 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); |
| 236 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); | 284 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); |
| 237 EXPECT_EQ(0, audio_type); // Speech. | 285 EXPECT_EQ(0, audio_type); // Speech. |
| 238 } | 286 } |
| 239 | 287 |
| 240 // Free memory. | 288 // Free memory. |
| 241 delete[] output_data_decode; | 289 delete[] output_data_decode; |
| 242 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 290 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 243 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 291 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 opus_encoder_ctl(opus_encoder_->encoder, | 477 opus_encoder_ctl(opus_encoder_->encoder, |
| 430 OPUS_GET_DTX(&dtx)); | 478 OPUS_GET_DTX(&dtx)); |
| 431 EXPECT_EQ(0, dtx); | 479 EXPECT_EQ(0, dtx); |
| 432 | 480 |
| 433 | 481 |
| 434 // Free memory. | 482 // Free memory. |
| 435 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 483 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 436 } | 484 } |
| 437 | 485 |
| 438 TEST_P(OpusTest, OpusDtxOff) { | 486 TEST_P(OpusTest, OpusDtxOff) { |
| 439 TestDtxEffect(false); | 487 TestDtxEffect(false, 10); |
| 488 TestDtxEffect(false, 20); |
| 489 TestDtxEffect(false, 40); |
| 440 } | 490 } |
| 441 | 491 |
| 442 TEST_P(OpusTest, OpusDtxOn) { | 492 TEST_P(OpusTest, OpusDtxOn) { |
| 443 TestDtxEffect(true); | 493 TestDtxEffect(true, 10); |
| 494 TestDtxEffect(true, 20); |
| 495 TestDtxEffect(true, 40); |
| 444 } | 496 } |
| 445 | 497 |
| 446 TEST_P(OpusTest, OpusSetPacketLossRate) { | 498 TEST_P(OpusTest, OpusSetPacketLossRate) { |
| 447 // Test without creating encoder memory. | 499 // Test without creating encoder memory. |
| 448 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); | 500 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); |
| 449 | 501 |
| 450 // Create encoder memory. | 502 // Create encoder memory. |
| 451 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 503 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 452 channels_, | 504 channels_, |
| 453 application_)); | 505 application_)); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 665 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 614 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 666 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 615 } | 667 } |
| 616 | 668 |
| 617 INSTANTIATE_TEST_CASE_P(VariousMode, | 669 INSTANTIATE_TEST_CASE_P(VariousMode, |
| 618 OpusTest, | 670 OpusTest, |
| 619 Combine(Values(1, 2), Values(0, 1))); | 671 Combine(Values(1, 2), Values(0, 1))); |
| 620 | 672 |
| 621 | 673 |
| 622 } // namespace webrtc | 674 } // namespace webrtc |
| OLD | NEW |