2014-09-23 12:05:34 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
|
2014-09-23 12:05:34 +00:00
|
|
|
|
2017-12-21 16:25:19 +01:00
|
|
|
#include <stddef.h> // for size_t
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2016-02-15 02:27:22 -08:00
|
|
|
#include <memory>
|
2015-12-09 06:20:58 -08:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "system_wrappers/include/clock.h"
|
2014-09-23 12:05:34 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
class AudioCodingModule;
|
2015-08-24 05:27:22 -07:00
|
|
|
class AudioDecoder;
|
2014-09-23 12:05:34 +00:00
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
class AudioSink;
|
|
|
|
|
class PacketSource;
|
|
|
|
|
|
|
|
|
|
class AcmReceiveTestOldApi {
|
|
|
|
|
public:
|
2017-12-21 16:25:19 +01:00
|
|
|
enum NumOutputChannels : size_t {
|
2014-09-23 12:05:34 +00:00
|
|
|
kArbitraryChannels = 0,
|
|
|
|
|
kMonoOutput = 1,
|
2019-02-22 10:13:44 +01:00
|
|
|
kStereoOutput = 2,
|
|
|
|
|
kQuadOutput = 4
|
2014-09-23 12:05:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AcmReceiveTestOldApi(PacketSource* packet_source,
|
|
|
|
|
AudioSink* audio_sink,
|
|
|
|
|
int output_freq_hz,
|
2016-10-04 09:33:27 -07:00
|
|
|
NumOutputChannels exptected_output_channels,
|
|
|
|
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
|
2016-08-29 06:37:33 -07:00
|
|
|
virtual ~AcmReceiveTestOldApi();
|
2014-09-23 12:05:34 +00:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
AcmReceiveTestOldApi(const AcmReceiveTestOldApi&) = delete;
|
|
|
|
|
AcmReceiveTestOldApi& operator=(const AcmReceiveTestOldApi&) = delete;
|
|
|
|
|
|
2014-09-23 12:05:34 +00:00
|
|
|
// Registers the codecs with default parameters from ACM.
|
|
|
|
|
void RegisterDefaultCodecs();
|
|
|
|
|
|
|
|
|
|
// Registers codecs with payload types matching the pre-encoded NetEq test
|
|
|
|
|
// files.
|
|
|
|
|
void RegisterNetEqTestCodecs();
|
|
|
|
|
|
|
|
|
|
// Runs the test and returns true if successful.
|
|
|
|
|
void Run();
|
|
|
|
|
|
2016-10-04 09:33:27 -07:00
|
|
|
AudioCodingModule* get_acm() { return acm_.get(); }
|
|
|
|
|
|
2014-10-14 10:49:58 +00:00
|
|
|
protected:
|
|
|
|
|
// Method is called after each block of output audio is received from ACM.
|
|
|
|
|
virtual void AfterGetAudio() {}
|
|
|
|
|
|
2014-09-23 12:05:34 +00:00
|
|
|
SimulatedClock clock_;
|
2016-02-15 02:27:22 -08:00
|
|
|
std::unique_ptr<AudioCodingModule> acm_;
|
2014-09-23 12:05:34 +00:00
|
|
|
PacketSource* packet_source_;
|
|
|
|
|
AudioSink* audio_sink_;
|
2014-10-14 10:49:58 +00:00
|
|
|
int output_freq_hz_;
|
2014-09-23 12:05:34 +00:00
|
|
|
NumOutputChannels exptected_output_channels_;
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// This test toggles the output frequency every `toggle_period_ms`. The test
|
|
|
|
|
// starts with `output_freq_hz_1`. Except for the toggling, it does the same
|
2014-10-14 10:49:58 +00:00
|
|
|
// thing as AcmReceiveTestOldApi.
|
|
|
|
|
class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi {
|
|
|
|
|
public:
|
|
|
|
|
AcmReceiveTestToggleOutputFreqOldApi(
|
|
|
|
|
PacketSource* packet_source,
|
|
|
|
|
AudioSink* audio_sink,
|
|
|
|
|
int output_freq_hz_1,
|
|
|
|
|
int output_freq_hz_2,
|
|
|
|
|
int toggle_period_ms,
|
|
|
|
|
NumOutputChannels exptected_output_channels);
|
|
|
|
|
|
|
|
|
|
protected:
|
2015-03-04 12:58:35 +00:00
|
|
|
void AfterGetAudio() override;
|
2014-10-14 10:49:58 +00:00
|
|
|
|
|
|
|
|
const int output_freq_hz_1_;
|
|
|
|
|
const int output_freq_hz_2_;
|
|
|
|
|
const int toggle_period_ms_;
|
|
|
|
|
int64_t last_toggle_time_ms_;
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-23 12:05:34 +00:00
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
|