MJPEGVideoSource.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // live header
  2. #include "JPEGVideoSource.hh"
  3. #include "sdc_def_ext.h"
  4. #include "JpegQueue.h"
  5. #include "Encoder.h"
  6. using namespace HWYolov3App;
  7. /*!*****************************************************************************
  8. * \brief MJPEG Video Source (RFC 2345)
  9. *************************************************************************************/
  10. class MJPEGVideoSource : public JPEGVideoSource
  11. {
  12. public:
  13. static MJPEGVideoSource* createNew (UsageEnvironment& env, FramedSource* source, JpegQueue* JpegQueue, Encoder* encoder)
  14. {
  15. return new MJPEGVideoSource(env, source, JpegQueue, encoder);
  16. }
  17. public:
  18. virtual void doGetNextFrame();
  19. static void afterGettingFrameSub(void* clientData, unsigned frameSize,unsigned numTruncatedBytes,struct timeval presentationTime,unsigned durationInMicroseconds)
  20. {
  21. MJPEGVideoSource* source = (MJPEGVideoSource*)clientData;
  22. source->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds);
  23. }
  24. void afterGettingFrame(unsigned frameSize,unsigned numTruncatedBytes,struct timeval presentationTime,unsigned durationInMicroseconds);
  25. virtual u_int8_t type() { return 1; };
  26. virtual u_int8_t qFactor() { return 128; };
  27. virtual u_int8_t width() { return m_width; };
  28. virtual u_int8_t height() { return m_height; };
  29. u_int8_t const* quantizationTables( u_int8_t& precision, u_int16_t& length );
  30. protected:
  31. MJPEGVideoSource(UsageEnvironment& env, FramedSource* source, JpegQueue* JpegQueue, Encoder* encoder);
  32. virtual ~MJPEGVideoSource();
  33. protected:
  34. FramedSource* m_inputSource;
  35. u_int8_t m_width;
  36. u_int8_t m_height;
  37. u_int8_t m_qTable[128];
  38. bool m_qTable0Init;
  39. bool m_qTable1Init;
  40. JpegQueue* m_JpegQueue = NULL;
  41. Encoder* m_Encoder = NULL;
  42. };