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.

70 lines
2.1 KiB

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