mpegts.hh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include <map>
  20. class TSReader
  21. {
  22. public:
  23. struct Entry
  24. {
  25. std::string filename;
  26. std::vector<unsigned char> data;
  27. };
  28. private:
  29. struct Header
  30. {
  31. std::string filename;
  32. size_t data_size = 0;
  33. };
  34. std::vector<Entry> m_entries;
  35. bool parse_header (Header& header, std::vector<unsigned char>& data);
  36. Error load (FILE *infile);
  37. public:
  38. Error load (const std::string& inname);
  39. const std::vector<Entry>& entries();
  40. const Entry *find (const std::string& filename) const;
  41. std::map<std::string, std::string> parse_vars (const std::string& name);
  42. };
  43. class TSWriter
  44. {
  45. struct Entry
  46. {
  47. std::string name;
  48. std::vector<unsigned char> data;
  49. };
  50. std::vector<Entry> entries;
  51. public:
  52. Error append_file (const std::string& name, const std::string& filename);
  53. void append_vars (const std::string& name, const std::map<std::string, std::string>& vars);
  54. void append_data (const std::string& name, const std::vector<unsigned char>& data);
  55. Error process (const std::string& in_name, const std::string& out_name);
  56. };
  57. int pcr (const std::string& filename, const std::string& outname, double time_offset_ms);
  58. #endif /* AUDIOWMARK_MPEGTS_HH */