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 | 10 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 &audio[written_samples])); | 263 &audio[written_samples])); |
264 written_samples += 480 * channels; | 264 written_samples += 480 * channels; |
265 | 265 |
266 // Sometimes we need to loop over the audio vector to produce the right | 266 // Sometimes we need to loop over the audio vector to produce the right |
267 // number of packets. | 267 // number of packets. |
268 int loop_encode = (written_samples - read_samples) / | 268 int loop_encode = (written_samples - read_samples) / |
269 (channels * frame_length); | 269 (channels * frame_length); |
270 | 270 |
271 if (loop_encode > 0) { | 271 if (loop_encode > 0) { |
272 const int kMaxBytes = 1000; // Maximum number of bytes for one packet. | 272 const int kMaxBytes = 1000; // Maximum number of bytes for one packet. |
273 int16_t bitstream_len_byte; | 273 size_t bitstream_len_byte; |
274 uint8_t bitstream[kMaxBytes]; | 274 uint8_t bitstream[kMaxBytes]; |
275 for (int i = 0; i < loop_encode; i++) { | 275 for (int i = 0; i < loop_encode; i++) { |
276 int bitstream_len_byte_int = WebRtcOpus_Encode( | 276 int bitstream_len_byte_int = WebRtcOpus_Encode( |
277 (channels == 1) ? opus_mono_encoder_ : opus_stereo_encoder_, | 277 (channels == 1) ? opus_mono_encoder_ : opus_stereo_encoder_, |
278 &audio[read_samples], frame_length, kMaxBytes, bitstream); | 278 &audio[read_samples], frame_length, kMaxBytes, bitstream); |
279 ASSERT_GE(bitstream_len_byte_int, 0); | 279 ASSERT_GE(bitstream_len_byte_int, 0); |
280 bitstream_len_byte = static_cast<int16_t>(bitstream_len_byte_int); | 280 bitstream_len_byte = static_cast<size_t>(bitstream_len_byte_int); |
281 | 281 |
282 // Simulate packet loss by setting |packet_loss_| to "true" in | 282 // Simulate packet loss by setting |packet_loss_| to "true" in |
283 // |percent_loss| percent of the loops. | 283 // |percent_loss| percent of the loops. |
284 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo. | 284 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo. |
285 if (percent_loss > 0) { | 285 if (percent_loss > 0) { |
286 if (counter_ == floor((100 / percent_loss) + 0.5)) { | 286 if (counter_ == floor((100 / percent_loss) + 0.5)) { |
287 counter_ = 0; | 287 counter_ = 0; |
288 lost_packet = true; | 288 lost_packet = true; |
289 channel->set_lost_packet(true); | 289 channel->set_lost_packet(true); |
290 } else { | 290 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 // Run received side of ACM. | 335 // Run received side of ACM. |
336 ASSERT_EQ(0, acm_receiver_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); | 336 ASSERT_EQ(0, acm_receiver_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); |
337 | 337 |
338 // Write output speech to file. | 338 // Write output speech to file. |
339 out_file_.Write10MsData( | 339 out_file_.Write10MsData( |
340 audio_frame.data_, | 340 audio_frame.data_, |
341 audio_frame.samples_per_channel_ * audio_frame.num_channels_); | 341 audio_frame.samples_per_channel_ * audio_frame.num_channels_); |
342 | 342 |
343 // Write stand-alone speech to file. | 343 // Write stand-alone speech to file. |
344 out_file_standalone_.Write10MsData(out_audio, decoded_samples * channels); | 344 out_file_standalone_.Write10MsData( |
| 345 out_audio, static_cast<size_t>(decoded_samples) * channels); |
345 | 346 |
346 if (audio_frame.timestamp_ > start_time_stamp) { | 347 if (audio_frame.timestamp_ > start_time_stamp) { |
347 // Number of channels should be the same for both stand-alone and | 348 // Number of channels should be the same for both stand-alone and |
348 // ACM-decoding. | 349 // ACM-decoding. |
349 EXPECT_EQ(audio_frame.num_channels_, channels); | 350 EXPECT_EQ(audio_frame.num_channels_, channels); |
350 } | 351 } |
351 | 352 |
352 decoded_samples = 0; | 353 decoded_samples = 0; |
353 } | 354 } |
354 | 355 |
(...skipping 16 matching lines...) Expand all Loading... |
371 out_file_.Open(file_name, 48000, "wb"); | 372 out_file_.Open(file_name, 48000, "wb"); |
372 file_stream.str(""); | 373 file_stream.str(""); |
373 file_name = file_stream.str(); | 374 file_name = file_stream.str(); |
374 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" | 375 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" |
375 << test_number << ".pcm"; | 376 << test_number << ".pcm"; |
376 file_name = file_stream.str(); | 377 file_name = file_stream.str(); |
377 out_file_standalone_.Open(file_name, 48000, "wb"); | 378 out_file_standalone_.Open(file_name, 48000, "wb"); |
378 } | 379 } |
379 | 380 |
380 } // namespace webrtc | 381 } // namespace webrtc |
OLD | NEW |