OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h" | 11 #include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h" |
12 | 12 |
13 #include <iostream> | 13 #include <iostream> |
14 | 14 |
15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 namespace test { | 18 namespace test { |
19 | 19 |
20 void DefaultNetEqTestErrorCallback::OnInsertPacketError( | 20 void DefaultNetEqTestErrorCallback::OnInsertPacketError( |
21 int error_code, | 21 int error_code, |
22 const NetEqInput::PacketData& packet) { | 22 const NetEqInput::PacketData& packet) { |
23 if (error_code == NetEq::kUnknownRtpPayloadType) { | 23 if (error_code == NetEq::kUnknownRtpPayloadType) { |
24 std::cerr << "RTP Payload type " | 24 std::cerr << "RTP Payload type " |
25 << static_cast<int>(packet.header.header.payloadType) | 25 << static_cast<int>(packet.header.payloadType) << " is unknown." |
26 << " is unknown." << std::endl; | 26 << std::endl; |
27 } else { | 27 } else { |
28 std::cerr << "InsertPacket returned error code " << error_code << std::endl; | 28 std::cerr << "InsertPacket returned error code " << error_code << std::endl; |
29 std::cerr << "Header data:" << std::endl; | 29 std::cerr << "Header data:" << std::endl; |
30 std::cerr << " PT = " << static_cast<int>(packet.header.header.payloadType) | 30 std::cerr << " PT = " << static_cast<int>(packet.header.payloadType) |
31 << std::endl; | 31 << std::endl; |
32 std::cerr << " SN = " << packet.header.header.sequenceNumber << std::endl; | 32 std::cerr << " SN = " << packet.header.sequenceNumber << std::endl; |
33 std::cerr << " TS = " << packet.header.header.timestamp << std::endl; | 33 std::cerr << " TS = " << packet.header.timestamp << std::endl; |
34 } | 34 } |
35 FATAL(); | 35 FATAL(); |
36 } | 36 } |
37 | 37 |
38 void DefaultNetEqTestErrorCallback::OnGetAudioError(int error_code) { | 38 void DefaultNetEqTestErrorCallback::OnGetAudioError(int error_code) { |
39 std::cerr << "GetAudio returned error code " << error_code << std::endl; | 39 std::cerr << "GetAudio returned error code " << error_code << std::endl; |
40 FATAL(); | 40 FATAL(); |
41 } | 41 } |
42 | 42 |
43 NetEqTest::NetEqTest(const NetEq::Config& config, | 43 NetEqTest::NetEqTest(const NetEq::Config& config, |
(...skipping 19 matching lines...) Expand all Loading... |
63 | 63 |
64 while (!input_->ended()) { | 64 while (!input_->ended()) { |
65 // Advance time to next event. | 65 // Advance time to next event. |
66 RTC_DCHECK(input_->NextEventTime()); | 66 RTC_DCHECK(input_->NextEventTime()); |
67 time_now_ms = *input_->NextEventTime(); | 67 time_now_ms = *input_->NextEventTime(); |
68 // Check if it is time to insert packet. | 68 // Check if it is time to insert packet. |
69 if (input_->NextPacketTime() && time_now_ms >= *input_->NextPacketTime()) { | 69 if (input_->NextPacketTime() && time_now_ms >= *input_->NextPacketTime()) { |
70 std::unique_ptr<NetEqInput::PacketData> packet_data = input_->PopPacket(); | 70 std::unique_ptr<NetEqInput::PacketData> packet_data = input_->PopPacket(); |
71 RTC_CHECK(packet_data); | 71 RTC_CHECK(packet_data); |
72 int error = neteq_->InsertPacket( | 72 int error = neteq_->InsertPacket( |
73 packet_data->header.header, | 73 packet_data->header, |
74 rtc::ArrayView<const uint8_t>(packet_data->payload), | 74 rtc::ArrayView<const uint8_t>(packet_data->payload), |
75 static_cast<uint32_t>(packet_data->time_ms * sample_rate_hz_ / 1000)); | 75 static_cast<uint32_t>(packet_data->time_ms * sample_rate_hz_ / 1000)); |
76 if (error != NetEq::kOK && error_callback_) { | 76 if (error != NetEq::kOK && error_callback_) { |
77 error_callback_->OnInsertPacketError(neteq_->LastError(), *packet_data); | 77 error_callback_->OnInsertPacketError(neteq_->LastError(), *packet_data); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 // Check if it is time to get output audio. | 81 // Check if it is time to get output audio. |
82 if (input_->NextOutputEventTime() && | 82 if (input_->NextOutputEventTime() && |
83 time_now_ms >= *input_->NextOutputEventTime()) { | 83 time_now_ms >= *input_->NextOutputEventTime()) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 neteq_->RegisterExternalDecoder(c.second.decoder, c.second.codec, | 127 neteq_->RegisterExternalDecoder(c.second.decoder, c.second.codec, |
128 c.second.codec_name, c.first), | 128 c.second.codec_name, c.first), |
129 NetEq::kOK) | 129 NetEq::kOK) |
130 << "Cannot register " << c.second.codec_name << " to payload type " | 130 << "Cannot register " << c.second.codec_name << " to payload type " |
131 << c.first; | 131 << c.first; |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 } // namespace test | 135 } // namespace test |
136 } // namespace webrtc | 136 } // namespace webrtc |
OLD | NEW |