| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 rtp_gen.set_drift_factor(drift_factor); | 61 rtp_gen.set_drift_factor(drift_factor); |
| 62 bool drift_flipped = false; | 62 bool drift_flipped = false; |
| 63 int32_t packet_input_time_ms = | 63 int32_t packet_input_time_ms = |
| 64 rtp_gen.GetRtpHeader(kPayloadType, kInputBlockSizeSamples, &rtp_header); | 64 rtp_gen.GetRtpHeader(kPayloadType, kInputBlockSizeSamples, &rtp_header); |
| 65 auto input_samples = audio_loop.GetNextBlock(); | 65 auto input_samples = audio_loop.GetNextBlock(); |
| 66 if (input_samples.empty()) | 66 if (input_samples.empty()) |
| 67 exit(1); | 67 exit(1); |
| 68 uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)]; | 68 uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)]; |
| 69 size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(), | 69 size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(), |
| 70 input_samples.size(), input_payload); | 70 input_samples.size(), input_payload); |
| 71 assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t)); | 71 RTC_CHECK_EQ(sizeof(input_payload), payload_len); |
| 72 | 72 |
| 73 // Main loop. | 73 // Main loop. |
| 74 webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock(); | 74 webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock(); |
| 75 int64_t start_time_ms = clock->TimeInMilliseconds(); | 75 int64_t start_time_ms = clock->TimeInMilliseconds(); |
| 76 while (time_now_ms < runtime_ms) { | 76 while (time_now_ms < runtime_ms) { |
| 77 while (packet_input_time_ms <= time_now_ms) { | 77 while (packet_input_time_ms <= time_now_ms) { |
| 78 // Drop every N packets, where N = FLAGS_lossrate. | 78 // Drop every N packets, where N = FLAGS_lossrate. |
| 79 bool lost = false; | 79 bool lost = false; |
| 80 if (lossrate > 0) { | 80 if (lossrate > 0) { |
| 81 lost = ((rtp_header.header.sequenceNumber - 1) % lossrate) == 0; | 81 lost = ((rtp_header.header.sequenceNumber - 1) % lossrate) == 0; |
| 82 } | 82 } |
| 83 if (!lost) { | 83 if (!lost) { |
| 84 // Insert packet. | 84 // Insert packet. |
| 85 int error = neteq->InsertPacket( | 85 int error = |
| 86 rtp_header, input_payload, payload_len, | 86 neteq->InsertPacket(rtp_header, input_payload, |
| 87 packet_input_time_ms * kSampRateHz / 1000); | 87 packet_input_time_ms * kSampRateHz / 1000); |
| 88 if (error != NetEq::kOK) | 88 if (error != NetEq::kOK) |
| 89 return -1; | 89 return -1; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Get next packet. | 92 // Get next packet. |
| 93 packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType, | 93 packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType, |
| 94 kInputBlockSizeSamples, | 94 kInputBlockSizeSamples, |
| 95 &rtp_header); | 95 &rtp_header); |
| 96 input_samples = audio_loop.GetNextBlock(); | 96 input_samples = audio_loop.GetNextBlock(); |
| 97 if (input_samples.empty()) | 97 if (input_samples.empty()) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 drift_flipped = true; | 124 drift_flipped = true; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 int64_t end_time_ms = clock->TimeInMilliseconds(); | 127 int64_t end_time_ms = clock->TimeInMilliseconds(); |
| 128 delete neteq; | 128 delete neteq; |
| 129 return end_time_ms - start_time_ms; | 129 return end_time_ms - start_time_ms; |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace test | 132 } // namespace test |
| 133 } // namespace webrtc | 133 } // namespace webrtc |
| OLD | NEW |