You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __LA_SERVA_MEDIA_ENCODER_HEADER__
  2. #define __LA_SERVA_MEDIA_ENCODER_HEADER__
  3. #include "../common/serverMySQL_dataBinder.h"
  4. #include "../../components/base/basicThread.h"
  5. #include "../../components/base/basicMutex.h"
  6. #include "../../components/base/basicLIBAV.h"
  7. #include "../../components/base/basicLogCollection.h"
  8. #include <vector>
  9. typedef struct S_LIBAV_VS{
  10. int m_iVideoStreamID;
  11. AVStream *m_pVideoStr;
  12. AVFormatContext *m_pFormatCtx;
  13. AVDictionary *m_pFormatOpts;
  14. AVCodecContext *m_pCodecCtx;
  15. AVCodec *m_pVideoCodec;
  16. SwsContext *m_pSwsCtx;
  17. char m_pFileName[MAX_PATH_LEN];
  18. MediaStateStatus m_bStatus;
  19. } LIBAV_VS;
  20. class servaKernel;
  21. class servaMediaEncoder: public basicThread{
  22. private:
  23. basicLogCollection * m_pLog;
  24. DBC_SERVA_MEDIA_ENCODER_SETTINGS m_sEncoderSettings;
  25. uint64_t m_nInFileSize;
  26. uint64_t m_nReadSize;
  27. uint64_t m_nOutFileSize;
  28. uint64_t m_nRefID;
  29. servaKernel * m_pMaster;
  30. basicMutex m_mFlagProtector;
  31. bool m_bFrameIsEncoded;
  32. //basicMutex m_mFrameProtector;
  33. AVFrame * m_pFrame;
  34. LIBAV_VS m_sEncoderVS;
  35. LIBAV_VS m_sDecoderVS;
  36. uint8_t m_bStatus;
  37. protected:
  38. virtual void m_fThreadProc( void );
  39. //virtual void m_fThreadBProc( void );
  40. public:
  41. explicit servaMediaEncoder( uint64_t Ref = 0 );
  42. ~servaMediaEncoder();
  43. bool create( CSTR src, CSTR dst, uint8_t fps = 15, int width = -1, int height = -1, CSTR custom = NULL );
  44. uint8_t getStatus();
  45. uint64_t getDBID(){ return m_nRefID;};
  46. CSTR getDstFormat();
  47. };
  48. typedef std::vector<servaMediaEncoder*> V_MEDIA_ENCODERS;
  49. #endif