Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

70 Zeilen
1.5KB

  1. #ifndef _vod_file_source_h_
  2. #define _vod_file_source_h_
  3. #include "avpacket-queue.h"
  4. #include "cpm/shared_ptr.h"
  5. #include "sys/thread.h"
  6. #include "sys/sync.hpp"
  7. class VodFileSource
  8. {
  9. public:
  10. struct IListener
  11. {
  12. virtual ~IListener() {}
  13. virtual int OnPacket(struct avpacket_t* pkt) = 0;
  14. };
  15. struct IFileReader
  16. {
  17. virtual ~IFileReader() {}
  18. virtual int Read(struct avpacket_t** pkt) = 0;
  19. /// @param[inout] pos input-seek position, output-location position
  20. /// @param[in] strategy
  21. /// @return 0-ok, other-error
  22. virtual int Seek(uint64_t* pos, int strategy) = 0;
  23. virtual uint64_t GetPosotion() = 0;
  24. virtual uint64_t GetDuration() = 0;
  25. };
  26. public:
  27. VodFileSource(std::shared_ptr<IFileReader> reader, std::shared_ptr<IListener> listener);
  28. ~VodFileSource();
  29. public:
  30. int Play();
  31. int Pause();
  32. /// @param[inout] pos input-seek position, output-location position
  33. /// @param[in] strategy
  34. /// @return 0-ok, other-error
  35. int Seek(uint64_t* pos, int strategy);
  36. int GetSpeed() const;
  37. int SetSpeed(int speed);
  38. uint64_t GetPosition() const;
  39. uint64_t GetDuration() const;
  40. private:
  41. int Worker();
  42. static int STDCALL Worker(void* param);
  43. private:
  44. enum { STOP, PLAY, PAUSE };
  45. volatile int m_status;
  46. volatile bool m_running;
  47. int m_speed;
  48. uint64_t m_clock; // wall-clock
  49. uint64_t m_timestamp; // av packet pts/dts
  50. pthread_t m_thread;
  51. ThreadEvent m_event;
  52. ThreadLocker m_locker;
  53. std::shared_ptr<IFileReader> m_reader;
  54. std::shared_ptr<IListener> m_listener;
  55. };
  56. #endif /* _vod_file_source_h_ */