fileparser.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * libdatachannel streamer example
  3. * Copyright (c) 2020 Filip Klembara (in2core)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef fileparser_hpp
  19. #define fileparser_hpp
  20. #include <string>
  21. #include <vector>
  22. #include "stream.hpp"
  23. class FileParser: public StreamSource {
  24. std::string directory;
  25. std::string extension;
  26. uint64_t sampleDuration_us;
  27. uint64_t sampleTime_us = 0;
  28. uint32_t counter = -1;
  29. bool loop;
  30. uint64_t loopTimestampOffset = 0;
  31. protected:
  32. rtc::binary sample = {};
  33. public:
  34. FileParser(std::string directory, std::string extension, uint32_t samplesPerSecond, bool loop);
  35. virtual ~FileParser();
  36. virtual void start() override;
  37. virtual void stop() override;
  38. virtual void loadNextSample() override;
  39. rtc::binary getSample() override;
  40. uint64_t getSampleTime_us() override;
  41. uint64_t getSampleDuration_us() override;
  42. };
  43. #endif /* fileparser_hpp */