niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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/test/EncodeDecodeTest.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 13 | #include <stdio.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | #include <stdlib.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 15 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 16 | #include <memory> |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 17 | |
Ali Tofigh | 714e3cb | 2022-07-20 12:53:07 +0200 | [diff] [blame] | 18 | #include "absl/strings/string_view.h" |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 19 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
Karl Wiberg | 658a552 | 2018-08-15 15:20:49 +0200 | [diff] [blame] | 20 | #include "api/audio_codecs/builtin_audio_encoder_factory.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "modules/audio_coding/include/audio_coding_module.h" |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 22 | #include "rtc_base/strings/string_builder.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "test/gtest.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 24 | #include "test/testsupport/file_utils.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 26 | namespace webrtc { |
| 27 | |
Per Åhgren | d82a02c | 2020-03-12 11:53:30 +0100 | [diff] [blame] | 28 | namespace { |
| 29 | // Buffer size for stereo 48 kHz audio. |
| 30 | constexpr size_t kWebRtc10MsPcmAudio = 960; |
| 31 | |
| 32 | } // namespace |
| 33 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 34 | TestPacketization::TestPacketization(RTPStream* rtpStream, uint16_t frequency) |
| 35 | : _rtpStream(rtpStream), _frequency(frequency), _seqNo(0) {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 37 | TestPacketization::~TestPacketization() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
Niels Möller | c35b6e6 | 2019-04-25 16:31:18 +0200 | [diff] [blame] | 39 | int32_t TestPacketization::SendData(const AudioFrameType /* frameType */, |
| 40 | const uint8_t payloadType, |
| 41 | const uint32_t timeStamp, |
| 42 | const uint8_t* payloadData, |
Minyue Li | ff0e4db | 2020-01-23 13:45:50 +0100 | [diff] [blame] | 43 | const size_t payloadSize, |
| 44 | int64_t absolute_capture_timestamp_ms) { |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 45 | _rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize, |
| 46 | _frequency); |
| 47 | return 1; |
| 48 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 50 | Sender::Sender() |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 51 | : _acm(NULL), _pcmFile(), _audioFrame(), _packetization(NULL) {} |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 52 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 53 | void Sender::Setup(AudioCodingModule* acm, |
| 54 | RTPStream* rtpStream, |
Ali Tofigh | 714e3cb | 2022-07-20 12:53:07 +0200 | [diff] [blame] | 55 | absl::string_view in_file_name, |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 56 | int in_sample_rate, |
| 57 | int payload_type, |
| 58 | SdpAudioFormat format) { |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 59 | // Open input file |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 60 | const std::string file_name = webrtc::test::ResourcePath(in_file_name, "pcm"); |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 61 | _pcmFile.Open(file_name, in_sample_rate, "rb"); |
| 62 | if (format.num_channels == 2) { |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 63 | _pcmFile.ReadStereo(true); |
| 64 | } |
Henrik Lundin | 4d68208 | 2015-12-10 16:24:39 +0100 | [diff] [blame] | 65 | // Set test length to 500 ms (50 blocks of 10 ms each). |
| 66 | _pcmFile.SetNum10MsBlocksToRead(50); |
| 67 | // Fast-forward 1 second (100 blocks) since the file starts with silence. |
| 68 | _pcmFile.FastForward(100); |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 69 | |
Karl Wiberg | 658a552 | 2018-08-15 15:20:49 +0200 | [diff] [blame] | 70 | acm->SetEncoder(CreateBuiltinAudioEncoderFactory()->MakeAudioEncoder( |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 71 | payload_type, format, absl::nullopt)); |
| 72 | _packetization = new TestPacketization(rtpStream, format.clockrate_hz); |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 73 | EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization)); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 74 | |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 75 | _acm = acm; |
| 76 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 77 | |
| 78 | void Sender::Teardown() { |
| 79 | _pcmFile.Close(); |
| 80 | delete _packetization; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | } |
| 82 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 83 | bool Sender::Add10MsData() { |
| 84 | if (!_pcmFile.EndOfFile()) { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 85 | EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 86 | int32_t ok = _acm->Add10MsData(_audioFrame); |
henrik.lundin@webrtc.org | f56c162 | 2015-03-02 12:29:30 +0000 | [diff] [blame] | 87 | EXPECT_GE(ok, 0); |
| 88 | return ok >= 0 ? true : false; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 89 | } |
| 90 | return false; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | } |
| 92 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 93 | void Sender::Run() { |
| 94 | while (true) { |
| 95 | if (!Add10MsData()) { |
| 96 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
| 101 | Receiver::Receiver() |
Per Åhgren | d82a02c | 2020-03-12 11:53:30 +0100 | [diff] [blame] | 102 | : _playoutLengthSmpls(kWebRtc10MsPcmAudio), |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 103 | _payloadSizeBytes(MAX_INCOMING_PAYLOAD) {} |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 104 | |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 105 | void Receiver::Setup(acm2::AcmReceiver* acm_receiver, |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 106 | RTPStream* rtpStream, |
Ali Tofigh | 714e3cb | 2022-07-20 12:53:07 +0200 | [diff] [blame] | 107 | absl::string_view out_file_name, |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 108 | size_t channels, |
| 109 | int file_num) { |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 110 | if (channels == 1) { |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 111 | acm_receiver->SetCodecs({{107, {"L16", 8000, 1}}, |
| 112 | {108, {"L16", 16000, 1}}, |
| 113 | {109, {"L16", 32000, 1}}, |
| 114 | {0, {"PCMU", 8000, 1}}, |
| 115 | {8, {"PCMA", 8000, 1}}, |
| 116 | {102, {"ILBC", 8000, 1}}, |
| 117 | {9, {"G722", 8000, 1}}, |
| 118 | {120, {"OPUS", 48000, 2}}, |
| 119 | {13, {"CN", 8000, 1}}, |
| 120 | {98, {"CN", 16000, 1}}, |
| 121 | {99, {"CN", 32000, 1}}}); |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 122 | } else { |
| 123 | ASSERT_EQ(channels, 2u); |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 124 | acm_receiver->SetCodecs({{111, {"L16", 8000, 2}}, |
| 125 | {112, {"L16", 16000, 2}}, |
| 126 | {113, {"L16", 32000, 2}}, |
| 127 | {110, {"PCMU", 8000, 2}}, |
| 128 | {118, {"PCMA", 8000, 2}}, |
| 129 | {119, {"G722", 8000, 2}}, |
| 130 | {120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}}); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 131 | } |
phoglund@webrtc.org | d1a860b | 2012-01-26 14:49:28 +0000 | [diff] [blame] | 132 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 133 | int playSampFreq; |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 134 | std::string file_name; |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 135 | rtc::StringBuilder file_stream; |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 136 | file_stream << webrtc::test::OutputPath() << out_file_name << file_num |
| 137 | << ".pcm"; |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 138 | file_name = file_stream.str(); |
| 139 | _rtpStream = rtpStream; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 140 | |
Karl Wiberg | 88aee28 | 2018-06-14 13:12:05 +0200 | [diff] [blame] | 141 | playSampFreq = 32000; |
| 142 | _pcmFile.Open(file_name, 32000, "wb+"); |
phoglund@webrtc.org | d1a860b | 2012-01-26 14:49:28 +0000 | [diff] [blame] | 143 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 144 | _realPayloadSizeBytes = 0; |
Per Åhgren | d82a02c | 2020-03-12 11:53:30 +0100 | [diff] [blame] | 145 | _playoutBuffer = new int16_t[kWebRtc10MsPcmAudio]; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 146 | _frequency = playSampFreq; |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 147 | _acm_receiver = acm_receiver; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 148 | _firstTime = true; |
| 149 | } |
| 150 | |
| 151 | void Receiver::Teardown() { |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 152 | delete[] _playoutBuffer; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 153 | _pcmFile.Close(); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | bool Receiver::IncomingPacket() { |
| 157 | if (!_rtpStream->EndOfFile()) { |
| 158 | if (_firstTime) { |
| 159 | _firstTime = false; |
Niels Möller | bf47495 | 2019-02-18 12:00:06 +0100 | [diff] [blame] | 160 | _realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload, |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 161 | _payloadSizeBytes, &_nextTime); |
andrew@webrtc.org | 975e4a3 | 2012-01-17 19:27:33 +0000 | [diff] [blame] | 162 | if (_realPayloadSizeBytes == 0) { |
| 163 | if (_rtpStream->EndOfFile()) { |
| 164 | _firstTime = true; |
| 165 | return true; |
| 166 | } else { |
andrew@webrtc.org | 975e4a3 | 2012-01-17 19:27:33 +0000 | [diff] [blame] | 167 | return false; |
| 168 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 169 | } |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 170 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 171 | |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 172 | EXPECT_EQ(0, _acm_receiver->InsertPacket( |
| 173 | _rtpHeader, rtc::ArrayView<const uint8_t>( |
| 174 | _incomingPayload, _realPayloadSizeBytes))); |
Niels Möller | bf47495 | 2019-02-18 12:00:06 +0100 | [diff] [blame] | 175 | _realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 176 | _payloadSizeBytes, &_nextTime); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 177 | if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) { |
| 178 | _firstTime = true; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 179 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 180 | } |
| 181 | return true; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | } |
| 183 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 184 | bool Receiver::PlayoutData() { |
| 185 | AudioFrame audioFrame; |
henrik.lundin | d4ccb00 | 2016-05-17 12:21:55 -0700 | [diff] [blame] | 186 | bool muted; |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 187 | int32_t ok = _acm_receiver->GetAudio(_frequency, &audioFrame, &muted); |
henrik.lundin | d4ccb00 | 2016-05-17 12:21:55 -0700 | [diff] [blame] | 188 | if (muted) { |
| 189 | ADD_FAILURE(); |
| 190 | return false; |
| 191 | } |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 192 | EXPECT_EQ(0, ok); |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 193 | if (ok < 0) { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 194 | return false; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 195 | } |
| 196 | if (_playoutLengthSmpls == 0) { |
| 197 | return false; |
| 198 | } |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 199 | _pcmFile.Write10MsData(audioFrame.data(), audioFrame.samples_per_channel_ * |
| 200 | audioFrame.num_channels_); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 201 | return true; |
| 202 | } |
| 203 | |
| 204 | void Receiver::Run() { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 205 | uint8_t counter500Ms = 50; |
| 206 | uint32_t clock = 0; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 207 | |
| 208 | while (counter500Ms > 0) { |
| 209 | if (clock == 0 || clock >= _nextTime) { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 210 | EXPECT_TRUE(IncomingPacket()); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 211 | if (clock == 0) { |
| 212 | clock = _nextTime; |
| 213 | } |
| 214 | } |
| 215 | if ((clock % 10) == 0) { |
| 216 | if (!PlayoutData()) { |
| 217 | clock++; |
| 218 | continue; |
| 219 | } |
| 220 | } |
| 221 | if (_rtpStream->EndOfFile()) { |
| 222 | counter500Ms--; |
| 223 | } |
| 224 | clock++; |
| 225 | } |
| 226 | } |
| 227 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 228 | EncodeDecodeTest::EncodeDecodeTest() = default; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 229 | |
| 230 | void EncodeDecodeTest::Perform() { |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 231 | const std::map<int, SdpAudioFormat> send_codecs = { |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 232 | {107, {"L16", 8000, 1}}, {108, {"L16", 16000, 1}}, |
| 233 | {109, {"L16", 32000, 1}}, {0, {"PCMU", 8000, 1}}, |
| 234 | {8, {"PCMA", 8000, 1}}, |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 235 | #ifdef WEBRTC_CODEC_ILBC |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 236 | {102, {"ILBC", 8000, 1}}, |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 237 | #endif |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 238 | {9, {"G722", 8000, 1}}}; |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 239 | int file_num = 0; |
| 240 | for (const auto& send_codec : send_codecs) { |
| 241 | RTPFile rtpFile; |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 242 | std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create()); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 243 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 244 | std::string fileName = webrtc::test::TempFilename( |
| 245 | webrtc::test::OutputPath(), "encode_decode_rtp"); |
| 246 | rtpFile.Open(fileName.c_str(), "wb+"); |
| 247 | rtpFile.WriteHeader(); |
| 248 | Sender sender; |
| 249 | sender.Setup(acm.get(), &rtpFile, "audio_coding/testfile32kHz", 32000, |
| 250 | send_codec.first, send_codec.second); |
| 251 | sender.Run(); |
| 252 | sender.Teardown(); |
| 253 | rtpFile.Close(); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 254 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 255 | rtpFile.Open(fileName.c_str(), "rb"); |
| 256 | rtpFile.ReadHeader(); |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 257 | std::unique_ptr<acm2::AcmReceiver> acm_receiver( |
| 258 | std::make_unique<acm2::AcmReceiver>( |
| 259 | acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()))); |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 260 | Receiver receiver; |
Henrik Lundin | 84f7569 | 2023-02-01 12:07:10 +0000 | [diff] [blame] | 261 | receiver.Setup(acm_receiver.get(), &rtpFile, "encodeDecode_out", 1, |
| 262 | file_num); |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 263 | receiver.Run(); |
| 264 | receiver.Teardown(); |
| 265 | rtpFile.Close(); |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 266 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 267 | file_num++; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 268 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 269 | } |
| 270 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 271 | } // namespace webrtc |