remuxer_ffmpeg.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef REMUXER_FFMPEG
  2. #define REMUXER_FFMPEG
  3. #include <atomic>
  4. #include <functional>
  5. #include <map>
  6. #include <string>
  7. #include <thread>
  8. namespace am {
  9. typedef void (*cb_remux_progress)(const char *, int, int);
  10. typedef void (*cb_remux_state)(const char *, int, int);
  11. typedef struct _REMUXER_PARAM
  12. {
  13. char src[260];
  14. char dst[260];
  15. int64_t src_size;
  16. std::atomic_bool running;
  17. cb_remux_progress cb_progress;
  18. cb_remux_state cb_state;
  19. } REMUXER_PARAM;
  20. typedef std::function<void(REMUXER_PARAM *)> thread_remuxing;
  21. typedef struct _REMUXER_HANDLE
  22. {
  23. REMUXER_PARAM param;
  24. std::thread fn;
  25. } REMUXER_HANDLE;
  26. class remuxer_ffmpeg
  27. {
  28. private:
  29. remuxer_ffmpeg() {}
  30. ~remuxer_ffmpeg() { destroy_remux(); }
  31. public:
  32. static remuxer_ffmpeg *instance();
  33. static void release();
  34. int create_remux(const REMUXER_PARAM &param);
  35. void remove_remux(std::string src);
  36. void destroy_remux();
  37. private:
  38. std::map<std::string, REMUXER_HANDLE *> _handlers;
  39. };
  40. } // namespace am
  41. #endif // !REMUXER_FFMPEG