stream.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef STREAM_H
  2. #define STREAM_H
  3. #include "thread.h"
  4. //#include "videodecode.h"
  5. //#include "BufferQueue.h"
  6. #include "server.h"
  7. #include "controller.h"
  8. #include <functional>
  9. typedef std::function<void (bool, int, int)> FUNCVIDEOSTART;
  10. typedef std::function<void (int, int, unsigned char*, int)> FUNCVIDEOINFO;
  11. //class Decoder;
  12. class Stream : public Thread
  13. {
  14. public:
  15. typedef struct FrameMeta {
  16. unsigned long long pts;
  17. struct FrameMeta* next;
  18. } FrameMeta;
  19. typedef struct ReceiverState {
  20. // meta (in order) for frames not consumed yet
  21. FrameMeta* frameMetaQueue;
  22. int remaining; // remaining bytes to receive for the current frame
  23. } ReceiverState;
  24. Stream();
  25. virtual ~Stream();
  26. public:
  27. // void setDecoder(VideoDecode* decoder);
  28. void setVideoSocket(socket_t deviceSocket);
  29. void setController(Controller *pControl);
  30. bool startDecode();
  31. void stopDecode();
  32. // VideoDecode *getDecoder() const {return m_decoder;}
  33. void SetVideoStartCallback(FUNCVIDEOSTART funcVideoStart);
  34. void SetVideoInfoCallback(FUNCVIDEOINFO funcVideoInfo);
  35. ReceiverState* getReceiverState();
  36. protected:
  37. void run();
  38. public:
  39. socket_t m_videoSocket;
  40. Controller* mController;
  41. bool m_quit;
  42. FUNCVIDEOSTART mFuncVideoStart;
  43. FUNCVIDEOINFO mFuncVideoInfo;
  44. // for recorder
  45. ReceiverState m_receiverState;
  46. //VideoDecode* m_decoder = NULL;
  47. private:
  48. };
  49. #endif // STREAM_H