getvideothread.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Ò¶º£»Ô
  3. * QQȺ121376426
  4. * http://blog.yundiantech.com/
  5. */
  6. #ifndef GetVideoThread_H
  7. #define GetVideoThread_H
  8. #include <QThread>
  9. extern "C"
  10. {
  11. #include "libavcodec/avcodec.h"
  12. #include "libavformat/avformat.h"
  13. #include "libswscale/swscale.h"
  14. #include "libavdevice/avdevice.h"
  15. }
  16. #include "savevideofile.h"
  17. enum ErroCode
  18. {
  19. AudioOpenFailed = 0,
  20. VideoOpenFailed,
  21. AudioDecoderOpenFailed,
  22. VideoDecoderOpenFailed,
  23. SUCCEED
  24. };
  25. class GetVideoThread : public QThread
  26. {
  27. Q_OBJECT
  28. public:
  29. explicit GetVideoThread();
  30. ~GetVideoThread();
  31. ErroCode init(QString videoDevName,bool useVideo,QString audioDevName,bool useAudio);
  32. void deInit();
  33. void startRecord();
  34. void pauseRecord();
  35. void restoreRecord();
  36. void stopRecord();
  37. void setPicRange(int x,int y,int w,int h);
  38. void setSaveVideoFileThread(SaveVideoFileThread * p);
  39. protected:
  40. void run();
  41. private:
  42. AVFormatContext *pFormatCtx;
  43. int i, videoindex ,audioindex;
  44. AVCodecContext *pCodecCtx,*aCodecCtx;
  45. AVFrame *pFrame,*aFrame,*pFrameYUV;
  46. uint8_t *out_buffer;
  47. int pic_x;
  48. int pic_y;
  49. int pic_w;
  50. int pic_h;
  51. bool m_isRun;
  52. bool m_pause;
  53. SaveVideoFileThread * m_saveVideoFileThread;
  54. };
  55. #endif // GetVideoThread_H