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.

71 lines
2.2 KiB

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