neteq_simulator_factory.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2018 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. #ifndef API_TEST_NETEQ_SIMULATOR_FACTORY_H_
  11. #define API_TEST_NETEQ_SIMULATOR_FACTORY_H_
  12. #include <memory>
  13. #include <string>
  14. #include "absl/strings/string_view.h"
  15. #include "absl/types/optional.h"
  16. #include "api/neteq/neteq_factory.h"
  17. #include "api/test/neteq_simulator.h"
  18. namespace webrtc {
  19. namespace test {
  20. class NetEqTestFactory;
  21. class NetEqSimulatorFactory {
  22. public:
  23. NetEqSimulatorFactory();
  24. ~NetEqSimulatorFactory();
  25. struct Config {
  26. // The maximum allowed number of packets in the jitter buffer.
  27. int max_nr_packets_in_buffer = 0;
  28. // The number of audio packets to insert at the start of the simulation.
  29. // Since the simulation is done with a replacement audio file, these
  30. // artificial packets will take a small piece of that replacement audio.
  31. int initial_dummy_packets = 0;
  32. // The number of simulation steps to skip at the start of the simulation.
  33. // This removes incoming packets and GetAudio events from the start of the
  34. // simulation, until the requested number of GetAudio events has been
  35. // removed.
  36. int skip_get_audio_events = 0;
  37. // A WebRTC field trial string to be used during the simulation.
  38. std::string field_trial_string;
  39. // A filename for the generated output audio file.
  40. absl::optional<std::string> output_audio_filename;
  41. // A custom NetEqFactory can be used.
  42. NetEqFactory* neteq_factory = nullptr;
  43. };
  44. std::unique_ptr<NetEqSimulator> CreateSimulatorFromFile(
  45. absl::string_view event_log_filename,
  46. absl::string_view replacement_audio_filename,
  47. Config simulation_config);
  48. // The same as above, but pass the file contents as a string.
  49. std::unique_ptr<NetEqSimulator> CreateSimulatorFromString(
  50. absl::string_view event_log_file_contents,
  51. absl::string_view replacement_audio_file,
  52. Config simulation_config);
  53. private:
  54. std::unique_ptr<NetEqTestFactory> factory_;
  55. };
  56. } // namespace test
  57. } // namespace webrtc
  58. #endif // API_TEST_NETEQ_SIMULATOR_FACTORY_H_