Restructure neteq_rtpplay into a library with small executable wrapper.

Most of the code in neteq_rtpplay is moved into a factory class for
NetEqTest. The factory method takes the same argc and argv arguments as
neteq_rtpplay.
This CL also adds a small public API for neteq_test to allow easy
integration into external software.

Bug: webrtc:9667
Change-Id: I5241c1f51736cb6fbe47b0ad25f4bc83dabd727d
Reviewed-on: https://webrtc-review.googlesource.com/96100
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24531}
This commit is contained in:
Ivo Creusen
2018-09-03 11:49:27 +02:00
committed by Commit Bot
parent 88c1a9ecbc
commit 55de08e7ef
16 changed files with 987 additions and 554 deletions

View File

@ -16,6 +16,8 @@
#include <string>
#include <utility>
#include "absl/types/optional.h"
#include "api/test/neteq_simulator.h"
#include "modules/audio_coding/neteq/include/neteq.h"
#include "modules/audio_coding/neteq/tools/audio_sink.h"
#include "modules/audio_coding/neteq/tools/neteq_input.h"
@ -52,10 +54,16 @@ class NetEqGetAudioCallback {
NetEq* neteq) = 0;
};
class NetEqSimulationEndedCallback {
public:
virtual ~NetEqSimulationEndedCallback() = default;
virtual void SimulationEnded(int64_t simulation_time_ms) = 0;
};
// Class that provides an input--output test for NetEq. The input (both packets
// and output events) is provided by a NetEqInput object, while the output is
// directed to an AudioSink object.
class NetEqTest {
class NetEqTest : public NetEqSimulator {
public:
using DecoderMap = std::map<int, std::pair<NetEqDecoder, std::string> >;
@ -71,6 +79,7 @@ class NetEqTest {
NetEqTestErrorCallback* error_callback = nullptr;
NetEqPostInsertPacket* post_insert_packet = nullptr;
NetEqGetAudioCallback* get_audio_callback = nullptr;
NetEqSimulationEndedCallback* simulation_ended_callback = nullptr;
};
// Sets up the test with given configuration, codec mappings, input, ouput,
@ -82,10 +91,17 @@ class NetEqTest {
std::unique_ptr<AudioSink> output,
Callbacks callbacks);
~NetEqTest();
~NetEqTest() override;
// Runs the test. Returns the duration of the produced audio in ms.
int64_t Run();
// Runs the simulation until we hit the next GetAudio event. If the simulation
// is finished, is_simulation_finished will be set to true in the returned
// SimulationStepResult.
SimulationStepResult RunToNextGetAudio() override;
void SetNextAction(Action next_operation) override;
NetEqState GetNetEqState() override;
// Returns the statistics from NetEq.
NetEqNetworkStatistics SimulationStats();
@ -96,7 +112,7 @@ class NetEqTest {
private:
void RegisterDecoders(const DecoderMap& codecs);
void RegisterExternalDecoders(const ExtDecoderMap& codecs);
absl::optional<Action> next_action_;
std::unique_ptr<NetEq> neteq_;
std::unique_ptr<NetEqInput> input_;
std::unique_ptr<AudioSink> output_;