henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/audio_coding/neteq/tools/neteq_test.h" |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 12 | |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 13 | #include <iomanip> |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 14 | #include <iostream> |
| 15 | |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 16 | #include "api/neteq/custom_neteq_factory.h" |
| 17 | #include "api/neteq/default_neteq_controller_factory.h" |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 18 | #include "modules/rtp_rtcp/source/byte_io.h" |
Alessio Bazzica | 8f319a3 | 2019-07-24 16:47:02 +0000 | [diff] [blame] | 19 | #include "system_wrappers/include/clock.h" |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | namespace test { |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 23 | namespace { |
| 24 | |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 25 | absl::optional<NetEq::Operation> ActionToOperations( |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 26 | absl::optional<NetEqSimulator::Action> a) { |
| 27 | if (!a) { |
| 28 | return absl::nullopt; |
| 29 | } |
| 30 | switch (*a) { |
| 31 | case NetEqSimulator::Action::kAccelerate: |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 32 | return absl::make_optional(NetEq::Operation::kAccelerate); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 33 | case NetEqSimulator::Action::kExpand: |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 34 | return absl::make_optional(NetEq::Operation::kExpand); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 35 | case NetEqSimulator::Action::kNormal: |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 36 | return absl::make_optional(NetEq::Operation::kNormal); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 37 | case NetEqSimulator::Action::kPreemptiveExpand: |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 38 | return absl::make_optional(NetEq::Operation::kPreemptiveExpand); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 42 | std::unique_ptr<NetEq> CreateNetEq( |
| 43 | const NetEq::Config& config, |
| 44 | Clock* clock, |
| 45 | const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { |
| 46 | CustomNetEqFactory neteq_factory( |
| 47 | decoder_factory, std::make_unique<DefaultNetEqControllerFactory>()); |
| 48 | return neteq_factory.CreateNetEq(config, clock); |
| 49 | } |
| 50 | |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 51 | } // namespace |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 52 | |
| 53 | void DefaultNetEqTestErrorCallback::OnInsertPacketError( |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 54 | const NetEqInput::PacketData& packet) { |
Henrik Lundin | c417d9e | 2017-06-14 12:29:03 +0200 | [diff] [blame] | 55 | std::cerr << "InsertPacket returned an error." << std::endl; |
henrik.lundin | 7a38fd2 | 2017-04-28 01:35:53 -0700 | [diff] [blame] | 56 | std::cerr << "Packet data: " << packet.ToString() << std::endl; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 57 | FATAL(); |
| 58 | } |
| 59 | |
Henrik Lundin | c417d9e | 2017-06-14 12:29:03 +0200 | [diff] [blame] | 60 | void DefaultNetEqTestErrorCallback::OnGetAudioError() { |
| 61 | std::cerr << "GetAudio returned an error." << std::endl; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 62 | FATAL(); |
| 63 | } |
| 64 | |
| 65 | NetEqTest::NetEqTest(const NetEq::Config& config, |
Niels Möller | 3f651d8 | 2018-12-19 15:06:17 +0100 | [diff] [blame] | 66 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 67 | const DecoderMap& codecs, |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 68 | std::unique_ptr<std::ofstream> text_log, |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 69 | std::unique_ptr<NetEqInput> input, |
| 70 | std::unique_ptr<AudioSink> output, |
henrik.lundin | 02739d9 | 2017-05-04 06:09:06 -0700 | [diff] [blame] | 71 | Callbacks callbacks) |
Alessio Bazzica | 8f319a3 | 2019-07-24 16:47:02 +0000 | [diff] [blame] | 72 | : clock_(0), |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 73 | neteq_(CreateNetEq(config, &clock_, decoder_factory)), |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 74 | input_(std::move(input)), |
| 75 | output_(std::move(output)), |
henrik.lundin | 02739d9 | 2017-05-04 06:09:06 -0700 | [diff] [blame] | 76 | callbacks_(callbacks), |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 77 | sample_rate_hz_(config.sample_rate_hz), |
| 78 | text_log_(std::move(text_log)) { |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 79 | RTC_CHECK(!config.enable_muted_state) |
| 80 | << "The code does not handle enable_muted_state"; |
| 81 | RegisterDecoders(codecs); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Mirko Bonadei | 682aac5 | 2018-07-20 13:59:20 +0200 | [diff] [blame] | 84 | NetEqTest::~NetEqTest() = default; |
| 85 | |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 86 | int64_t NetEqTest::Run() { |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 87 | int64_t simulation_time = 0; |
| 88 | SimulationStepResult step_result; |
| 89 | do { |
| 90 | step_result = RunToNextGetAudio(); |
| 91 | simulation_time += step_result.simulation_step_ms; |
| 92 | } while (!step_result.is_simulation_finished); |
| 93 | if (callbacks_.simulation_ended_callback) { |
| 94 | callbacks_.simulation_ended_callback->SimulationEnded(simulation_time); |
| 95 | } |
| 96 | return simulation_time; |
| 97 | } |
| 98 | |
| 99 | NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { |
| 100 | SimulationStepResult result; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 101 | const int64_t start_time_ms = *input_->NextEventTime(); |
| 102 | int64_t time_now_ms = start_time_ms; |
Ivo Creusen | 4384f53 | 2018-09-07 17:19:56 +0200 | [diff] [blame] | 103 | current_state_.packet_iat_ms.clear(); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 104 | |
| 105 | while (!input_->ended()) { |
| 106 | // Advance time to next event. |
| 107 | RTC_DCHECK(input_->NextEventTime()); |
Alessio Bazzica | 8f319a3 | 2019-07-24 16:47:02 +0000 | [diff] [blame] | 108 | clock_.AdvanceTimeMilliseconds(*input_->NextEventTime() - time_now_ms); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 109 | time_now_ms = *input_->NextEventTime(); |
| 110 | // Check if it is time to insert packet. |
| 111 | if (input_->NextPacketTime() && time_now_ms >= *input_->NextPacketTime()) { |
| 112 | std::unique_ptr<NetEqInput::PacketData> packet_data = input_->PopPacket(); |
| 113 | RTC_CHECK(packet_data); |
Minyue Li | 1a80018 | 2018-09-12 12:52:48 +0200 | [diff] [blame] | 114 | const size_t payload_data_length = |
| 115 | packet_data->payload.size() - packet_data->header.paddingLength; |
| 116 | if (payload_data_length != 0) { |
| 117 | int error = neteq_->InsertPacket( |
| 118 | packet_data->header, |
Karl Wiberg | 45eb135 | 2019-10-10 14:23:00 +0200 | [diff] [blame] | 119 | rtc::ArrayView<const uint8_t>(packet_data->payload)); |
Minyue Li | 1a80018 | 2018-09-12 12:52:48 +0200 | [diff] [blame] | 120 | if (error != NetEq::kOK && callbacks_.error_callback) { |
| 121 | callbacks_.error_callback->OnInsertPacketError(*packet_data); |
| 122 | } |
| 123 | if (callbacks_.post_insert_packet) { |
| 124 | callbacks_.post_insert_packet->AfterInsertPacket(*packet_data, |
| 125 | neteq_.get()); |
| 126 | } |
| 127 | } else { |
| 128 | neteq_->InsertEmptyPacket(packet_data->header); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 129 | } |
Ivo Creusen | 4384f53 | 2018-09-07 17:19:56 +0200 | [diff] [blame] | 130 | if (last_packet_time_ms_) { |
| 131 | current_state_.packet_iat_ms.push_back(time_now_ms - |
| 132 | *last_packet_time_ms_); |
| 133 | } |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 134 | if (text_log_) { |
| 135 | const auto ops_state = neteq_->GetOperationsAndState(); |
| 136 | const auto delta_wallclock = |
| 137 | last_packet_time_ms_ ? (time_now_ms - *last_packet_time_ms_) : -1; |
| 138 | const auto delta_timestamp = |
| 139 | last_packet_timestamp_ |
| 140 | ? (static_cast<int64_t>(packet_data->header.timestamp) - |
| 141 | *last_packet_timestamp_) * |
| 142 | 1000 / sample_rate_hz_ |
| 143 | : -1; |
| 144 | const auto packet_size_bytes = |
| 145 | packet_data->payload.size() == 12 |
| 146 | ? ByteReader<uint32_t>::ReadLittleEndian( |
| 147 | &packet_data->payload[8]) |
| 148 | : -1; |
| 149 | *text_log_ << "Packet - wallclock: " << std::setw(5) << time_now_ms |
| 150 | << ", delta wc: " << std::setw(4) << delta_wallclock |
Jakob Ivarsson | e98954c | 2019-02-06 15:37:50 +0100 | [diff] [blame] | 151 | << ", seq_no: " << packet_data->header.sequenceNumber |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 152 | << ", timestamp: " << std::setw(10) |
| 153 | << packet_data->header.timestamp |
| 154 | << ", delta ts: " << std::setw(4) << delta_timestamp |
| 155 | << ", size: " << std::setw(5) << packet_size_bytes |
| 156 | << ", frame size: " << std::setw(3) |
| 157 | << ops_state.current_frame_size_ms |
| 158 | << ", buffer size: " << std::setw(4) |
| 159 | << ops_state.current_buffer_size_ms << std::endl; |
| 160 | } |
Ivo Creusen | 4384f53 | 2018-09-07 17:19:56 +0200 | [diff] [blame] | 161 | last_packet_time_ms_ = absl::make_optional<int>(time_now_ms); |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 162 | last_packet_timestamp_ = |
| 163 | absl::make_optional<uint32_t>(packet_data->header.timestamp); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | // Check if it is time to get output audio. |
| 167 | if (input_->NextOutputEventTime() && |
| 168 | time_now_ms >= *input_->NextOutputEventTime()) { |
henrik.lundin | 02739d9 | 2017-05-04 06:09:06 -0700 | [diff] [blame] | 169 | if (callbacks_.get_audio_callback) { |
| 170 | callbacks_.get_audio_callback->BeforeGetAudio(neteq_.get()); |
| 171 | } |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 172 | AudioFrame out_frame; |
| 173 | bool muted; |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 174 | int error = neteq_->GetAudio(&out_frame, &muted, |
| 175 | ActionToOperations(next_action_)); |
| 176 | next_action_ = absl::nullopt; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 177 | RTC_CHECK(!muted) << "The code does not handle enable_muted_state"; |
| 178 | if (error != NetEq::kOK) { |
henrik.lundin | 02739d9 | 2017-05-04 06:09:06 -0700 | [diff] [blame] | 179 | if (callbacks_.error_callback) { |
Henrik Lundin | c417d9e | 2017-06-14 12:29:03 +0200 | [diff] [blame] | 180 | callbacks_.error_callback->OnGetAudioError(); |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 181 | } |
| 182 | } else { |
| 183 | sample_rate_hz_ = out_frame.sample_rate_hz_; |
| 184 | } |
henrik.lundin | 02739d9 | 2017-05-04 06:09:06 -0700 | [diff] [blame] | 185 | if (callbacks_.get_audio_callback) { |
| 186 | callbacks_.get_audio_callback->AfterGetAudio(time_now_ms, out_frame, |
| 187 | muted, neteq_.get()); |
| 188 | } |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 189 | |
| 190 | if (output_) { |
| 191 | RTC_CHECK(output_->WriteArray( |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 192 | out_frame.data(), |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 193 | out_frame.samples_per_channel_ * out_frame.num_channels_)); |
| 194 | } |
| 195 | |
| 196 | input_->AdvanceOutputEvent(); |
Henrik Lundin | 9be7745 | 2018-09-10 12:53:27 +0200 | [diff] [blame] | 197 | result.simulation_step_ms = |
| 198 | input_->NextEventTime().value_or(time_now_ms) - start_time_ms; |
Ivo Creusen | d1c2f78 | 2018-09-13 14:39:55 +0200 | [diff] [blame] | 199 | const auto operations_state = neteq_->GetOperationsAndState(); |
| 200 | current_state_.current_delay_ms = operations_state.current_buffer_size_ms; |
Ivo Creusen | dc6d553 | 2018-09-27 11:43:42 +0200 | [diff] [blame] | 201 | current_state_.packet_size_ms = operations_state.current_frame_size_ms; |
| 202 | current_state_.next_packet_available = |
| 203 | operations_state.next_packet_available; |
| 204 | current_state_.packet_buffer_flushed = |
| 205 | operations_state.packet_buffer_flushes > |
| 206 | prev_ops_state_.packet_buffer_flushes; |
Ivo Creusen | d1c2f78 | 2018-09-13 14:39:55 +0200 | [diff] [blame] | 207 | // TODO(ivoc): Add more accurate reporting by tracking the origin of |
| 208 | // samples in the sync buffer. |
| 209 | result.action_times_ms[Action::kExpand] = 0; |
| 210 | result.action_times_ms[Action::kAccelerate] = 0; |
| 211 | result.action_times_ms[Action::kPreemptiveExpand] = 0; |
| 212 | result.action_times_ms[Action::kNormal] = 0; |
| 213 | |
| 214 | if (out_frame.speech_type_ == AudioFrame::SpeechType::kPLC || |
| 215 | out_frame.speech_type_ == AudioFrame::SpeechType::kPLCCNG) { |
| 216 | // Consider the whole frame to be the result of expansion. |
| 217 | result.action_times_ms[Action::kExpand] = 10; |
| 218 | } else if (operations_state.accelerate_samples - |
| 219 | prev_ops_state_.accelerate_samples > |
| 220 | 0) { |
| 221 | // Consider the whole frame to be the result of acceleration. |
| 222 | result.action_times_ms[Action::kAccelerate] = 10; |
| 223 | } else if (operations_state.preemptive_samples - |
| 224 | prev_ops_state_.preemptive_samples > |
| 225 | 0) { |
| 226 | // Consider the whole frame to be the result of preemptive expansion. |
| 227 | result.action_times_ms[Action::kPreemptiveExpand] = 10; |
| 228 | } else { |
| 229 | // Consider the whole frame to be the result of normal playout. |
| 230 | result.action_times_ms[Action::kNormal] = 10; |
| 231 | } |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 232 | auto lifetime_stats = LifetimeStats(); |
| 233 | if (text_log_) { |
| 234 | const bool plc = |
| 235 | (out_frame.speech_type_ == AudioFrame::SpeechType::kPLC) || |
| 236 | (out_frame.speech_type_ == AudioFrame::SpeechType::kPLCCNG); |
| 237 | const bool cng = out_frame.speech_type_ == AudioFrame::SpeechType::kCNG; |
| 238 | const bool voice_concealed = |
Ivo Creusen | bf4a221 | 2019-04-24 14:06:24 +0200 | [diff] [blame] | 239 | (lifetime_stats.concealed_samples - |
| 240 | lifetime_stats.silent_concealed_samples) > |
| 241 | (prev_lifetime_stats_.concealed_samples - |
| 242 | prev_lifetime_stats_.silent_concealed_samples); |
Ivo Creusen | 2db46b0 | 2018-12-14 16:49:12 +0100 | [diff] [blame] | 243 | *text_log_ << "GetAudio - wallclock: " << std::setw(5) << time_now_ms |
| 244 | << ", delta wc: " << std::setw(4) |
| 245 | << (input_->NextEventTime().value_or(time_now_ms) - |
| 246 | start_time_ms) |
| 247 | << ", CNG: " << cng << ", PLC: " << plc |
| 248 | << ", voice concealed: " << voice_concealed |
| 249 | << ", buffer size: " << std::setw(4) |
| 250 | << current_state_.current_delay_ms << std::endl; |
| 251 | if (operations_state.discarded_primary_packets > |
| 252 | prev_ops_state_.discarded_primary_packets) { |
| 253 | *text_log_ << "Discarded " |
| 254 | << (operations_state.discarded_primary_packets - |
| 255 | prev_ops_state_.discarded_primary_packets) |
| 256 | << " primary packets." << std::endl; |
| 257 | } |
| 258 | if (operations_state.packet_buffer_flushes > |
| 259 | prev_ops_state_.packet_buffer_flushes) { |
| 260 | *text_log_ << "Flushed packet buffer " |
| 261 | << (operations_state.packet_buffer_flushes - |
| 262 | prev_ops_state_.packet_buffer_flushes) |
| 263 | << " times." << std::endl; |
| 264 | } |
| 265 | } |
| 266 | prev_lifetime_stats_ = lifetime_stats; |
Jakob Ivarsson | 9ce451a | 2019-05-22 16:41:22 +0200 | [diff] [blame] | 267 | const bool no_more_packets_to_decode = |
| 268 | !input_->NextPacketTime() && !operations_state.next_packet_available; |
| 269 | result.is_simulation_finished = |
| 270 | no_more_packets_to_decode || input_->ended(); |
Ivo Creusen | d1c2f78 | 2018-09-13 14:39:55 +0200 | [diff] [blame] | 271 | prev_ops_state_ = operations_state; |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 272 | return result; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 273 | } |
| 274 | } |
Henrik Lundin | 9be7745 | 2018-09-10 12:53:27 +0200 | [diff] [blame] | 275 | result.simulation_step_ms = |
| 276 | input_->NextEventTime().value_or(time_now_ms) - start_time_ms; |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 277 | result.is_simulation_finished = true; |
| 278 | return result; |
| 279 | } |
| 280 | |
| 281 | void NetEqTest::SetNextAction(NetEqTest::Action next_operation) { |
| 282 | next_action_ = absl::optional<Action>(next_operation); |
| 283 | } |
| 284 | |
| 285 | NetEqTest::NetEqState NetEqTest::GetNetEqState() { |
Ivo Creusen | 4384f53 | 2018-09-07 17:19:56 +0200 | [diff] [blame] | 286 | return current_state_; |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | NetEqNetworkStatistics NetEqTest::SimulationStats() { |
| 290 | NetEqNetworkStatistics stats; |
| 291 | RTC_CHECK_EQ(neteq_->NetworkStatistics(&stats), 0); |
| 292 | return stats; |
| 293 | } |
| 294 | |
Alex Narest | 7ff6ca5 | 2018-02-07 18:46:33 +0100 | [diff] [blame] | 295 | NetEqLifetimeStatistics NetEqTest::LifetimeStats() const { |
| 296 | return neteq_->GetLifetimeStatistics(); |
| 297 | } |
| 298 | |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 299 | NetEqTest::DecoderMap NetEqTest::StandardDecoderMap() { |
| 300 | DecoderMap codecs = { |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 301 | {0, SdpAudioFormat("pcmu", 8000, 1)}, |
| 302 | {8, SdpAudioFormat("pcma", 8000, 1)}, |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 303 | #ifdef WEBRTC_CODEC_ILBC |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 304 | {102, SdpAudioFormat("ilbc", 8000, 1)}, |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 305 | #endif |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 306 | {103, SdpAudioFormat("isac", 16000, 1)}, |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 307 | #if !defined(WEBRTC_ANDROID) |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 308 | {104, SdpAudioFormat("isac", 32000, 1)}, |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 309 | #endif |
| 310 | #ifdef WEBRTC_CODEC_OPUS |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 311 | {111, SdpAudioFormat("opus", 48000, 2)}, |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 312 | #endif |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 313 | {93, SdpAudioFormat("l16", 8000, 1)}, |
| 314 | {94, SdpAudioFormat("l16", 16000, 1)}, |
| 315 | {95, SdpAudioFormat("l16", 32000, 1)}, |
| 316 | {96, SdpAudioFormat("l16", 48000, 1)}, |
| 317 | {9, SdpAudioFormat("g722", 8000, 1)}, |
| 318 | {106, SdpAudioFormat("telephone-event", 8000, 1)}, |
| 319 | {114, SdpAudioFormat("telephone-event", 16000, 1)}, |
| 320 | {115, SdpAudioFormat("telephone-event", 32000, 1)}, |
| 321 | {116, SdpAudioFormat("telephone-event", 48000, 1)}, |
| 322 | {117, SdpAudioFormat("red", 8000, 1)}, |
| 323 | {13, SdpAudioFormat("cn", 8000, 1)}, |
| 324 | {98, SdpAudioFormat("cn", 16000, 1)}, |
| 325 | {99, SdpAudioFormat("cn", 32000, 1)}, |
| 326 | {100, SdpAudioFormat("cn", 48000, 1)} |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 327 | }; |
| 328 | return codecs; |
| 329 | } |
| 330 | |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 331 | void NetEqTest::RegisterDecoders(const DecoderMap& codecs) { |
| 332 | for (const auto& c : codecs) { |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 333 | RTC_CHECK(neteq_->RegisterPayloadType(c.first, c.second)) |
| 334 | << "Cannot register " << c.second.name << " to payload type " |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 335 | << c.first; |
| 336 | } |
| 337 | } |
| 338 | |
henrik.lundin | e8a77e3 | 2016-06-22 06:34:03 -0700 | [diff] [blame] | 339 | } // namespace test |
| 340 | } // namespace webrtc |