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