| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 int16_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 if (channels == 1) { | 276 int bitstream_len_byte_int = WebRtcOpus_Encode( |
| 277 bitstream_len_byte = WebRtcOpus_Encode( | 277 (channels == 1) ? opus_mono_encoder_ : opus_stereo_encoder_, |
| 278 opus_mono_encoder_, &audio[read_samples], | 278 &audio[read_samples], frame_length, kMaxBytes, bitstream); |
| 279 frame_length, kMaxBytes, bitstream); | 279 ASSERT_GE(bitstream_len_byte_int, 0); |
| 280 ASSERT_GE(bitstream_len_byte, 0); | 280 bitstream_len_byte = static_cast<int16_t>(bitstream_len_byte_int); |
| 281 } else { | |
| 282 bitstream_len_byte = WebRtcOpus_Encode( | |
| 283 opus_stereo_encoder_, &audio[read_samples], | |
| 284 frame_length, kMaxBytes, bitstream); | |
| 285 ASSERT_GE(bitstream_len_byte, 0); | |
| 286 } | |
| 287 | 281 |
| 288 // Simulate packet loss by setting |packet_loss_| to "true" in | 282 // Simulate packet loss by setting |packet_loss_| to "true" in |
| 289 // |percent_loss| percent of the loops. | 283 // |percent_loss| percent of the loops. |
| 290 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo. | 284 // TODO(tlegrand): Move handling of loss simulation to TestPackStereo. |
| 291 if (percent_loss > 0) { | 285 if (percent_loss > 0) { |
| 292 if (counter_ == floor((100 / percent_loss) + 0.5)) { | 286 if (counter_ == floor((100 / percent_loss) + 0.5)) { |
| 293 counter_ = 0; | 287 counter_ = 0; |
| 294 lost_packet = true; | 288 lost_packet = true; |
| 295 channel->set_lost_packet(true); | 289 channel->set_lost_packet(true); |
| 296 } else { | 290 } else { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 out_file_.Open(file_name, 48000, "wb"); | 371 out_file_.Open(file_name, 48000, "wb"); |
| 378 file_stream.str(""); | 372 file_stream.str(""); |
| 379 file_name = file_stream.str(); | 373 file_name = file_stream.str(); |
| 380 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" | 374 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" |
| 381 << test_number << ".pcm"; | 375 << test_number << ".pcm"; |
| 382 file_name = file_stream.str(); | 376 file_name = file_stream.str(); |
| 383 out_file_standalone_.Open(file_name, 48000, "wb"); | 377 out_file_standalone_.Open(file_name, 48000, "wb"); |
| 384 } | 378 } |
| 385 | 379 |
| 386 } // namespace webrtc | 380 } // namespace webrtc |
| OLD | NEW |