mpegts.hh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2018-2020 Stefan Westerfeld
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef AUDIOWMARK_MPEGTS_HH
  18. #define AUDIOWMARK_MPEGTS_HH
  19. class TSReader
  20. {
  21. public:
  22. struct Entry
  23. {
  24. std::string filename;
  25. std::vector<unsigned char> data;
  26. };
  27. private:
  28. struct Header
  29. {
  30. std::string filename;
  31. size_t data_size = 0;
  32. };
  33. std::vector<Entry> m_entries;
  34. bool parse_header (Header& header, std::vector<unsigned char>& data);
  35. public:
  36. Error load (const std::string& inname);
  37. const std::vector<Entry>& entries();
  38. const Entry *find (const std::string& filename) const;
  39. std::map<std::string, std::string> parse_vars (const std::string& name);
  40. };
  41. class TSWriter
  42. {
  43. struct Entry
  44. {
  45. std::string name;
  46. std::vector<unsigned char> data;
  47. };
  48. std::vector<Entry> entries;
  49. public:
  50. Error append_file (const std::string& name, const std::string& filename);
  51. void append_vars (const std::string& name, const std::map<std::string, std::string>& vars);
  52. Error process (const std::string& in_name, const std::string& out_name);
  53. };
  54. int pcr (const std::string& filename, const std::string& outname, double time_offset_ms);
  55. #endif /* AUDIOWMARK_MPEGTS_HH */