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.

72 lines
2.2 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 enum E_ENCODER_STAGES{
  10. ENCODER_NONE = 0,
  11. DECODER_INIT = 1,
  12. ENCODER_INIT,
  13. THREAD_INIT,
  14. ENCODER_ENCODING,
  15. ENCODER_FINISHED
  16. }ENCODER_STAGES;
  17. typedef enum E_MEDIA_STATUS{
  18. MEDIA_TRANSFERING = 0,
  19. MEDIA_STORED = 1,
  20. MEDIA_ENCODE_PROGRESS = 2,
  21. MEDIA_READY
  22. }MEDIA_STATUS;
  23. typedef struct S_LIBAV_VS{
  24. int m_iVideoStreamID;
  25. AVStream *m_pVideoStr;
  26. AVFormatContext *m_pFormatCtx;
  27. AVDictionary *m_pFormatOpts;
  28. AVCodecContext *m_pCodecCtx;
  29. AVCodec *m_pVideoCodec;
  30. SwsContext *m_pSwsCtx;
  31. char m_pFileName[MAX_PATH_LEN];
  32. MediaStateStatus m_bStatus;
  33. } LIBAV_VS;
  34. class servaKernel;
  35. class servaMediaEncoder: public basicThread{
  36. private:
  37. basicLogCollection * m_pLog;
  38. DBC_SERVA_MEDIA_ENCODER_SETTINGS m_sEncoderSettings;
  39. uint64_t m_nInFileSize;
  40. uint64_t m_nReadSize;
  41. uint64_t m_nOutFileSize;
  42. uint64_t m_nRefID;
  43. servaKernel * m_pMaster;
  44. basicMutex m_mFlagProtector;
  45. bool m_bFrameIsEncoded;
  46. //basicMutex m_mFrameProtector;
  47. AVFrame * m_pFrame;
  48. LIBAV_VS m_sEncoderVS;
  49. LIBAV_VS m_sDecoderVS;
  50. uint8_t m_bStatus;
  51. protected:
  52. virtual void m_fThreadProc( void );
  53. //virtual void m_fThreadBProc( void );
  54. public:
  55. explicit servaMediaEncoder( uint64_t Ref = 0 );
  56. ~servaMediaEncoder();
  57. bool create( CSTR src, CSTR dst, uint8_t fps = 15, int width = -1, int height = -1, CSTR custom = NULL );
  58. uint8_t getStatus();
  59. uint64_t getDBID(){ return m_nRefID;};
  60. CSTR getDstFormat();
  61. };
  62. typedef std::vector<servaMediaEncoder*> V_MEDIA_ENCODERS;
  63. #endif