fileparser.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * libdatachannel streamer example
  3. * Copyright (c) 2020 Filip Klembara (in2core)
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  8. */
  9. #ifndef fileparser_hpp
  10. #define fileparser_hpp
  11. #include <string>
  12. #include <vector>
  13. #include "stream.hpp"
  14. class FileParser: public StreamSource {
  15. std::string directory;
  16. std::string extension;
  17. uint64_t sampleDuration_us;
  18. uint64_t sampleTime_us = 0;
  19. uint32_t counter = -1;
  20. bool loop;
  21. uint64_t loopTimestampOffset = 0;
  22. protected:
  23. rtc::binary sample = {};
  24. public:
  25. FileParser(std::string directory, std::string extension, uint32_t samplesPerSecond, bool loop);
  26. virtual ~FileParser();
  27. virtual void start() override;
  28. virtual void stop() override;
  29. virtual void loadNextSample() override;
  30. rtc::binary getSample() override;
  31. uint64_t getSampleTime_us() override;
  32. uint64_t getSampleDuration_us() override;
  33. };
  34. #endif /* fileparser_hpp */