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