cameraplayer.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef CAMERAPLAYER_H
  2. #define CAMERAPLAYER_H
  3. #include <QObject>
  4. #include <QTimer>
  5. #include "PlayM4.h"
  6. #include "HCNetSDK.h"
  7. #include "RingQueue.hpp"
  8. #include "PlayerGlobalInfo.h"
  9. #include "PlayerGLWidget.h"
  10. /**
  11. * @brief 登录设备返回的设备信息
  12. *
  13. */
  14. struct CameraInfo
  15. {
  16. quint32 AChannelNum; /* 模拟通道个数,貌似就是最大模拟通道个数 */
  17. quint32 AChannelStart; /* 模拟起始通道号 */
  18. quint32 DChannelNum; /* 数字通道个数,貌似就是最大模拟通道个数 */
  19. quint32 DChannelStart; /* 数字起始通道号 */
  20. };
  21. class CameraPlayer : public QObject
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit CameraPlayer(QObject *parent = nullptr);
  26. ~CameraPlayer();
  27. /* 设置摄像机信息 */
  28. bool initCamera(QString cameraIP, int cameraPort, QString cameraUser, QString cameraPwd);
  29. /* 设置实时预览 */
  30. bool realPlay(int channel);
  31. /* 关闭预览 */
  32. void stopRealPlay();
  33. /* 开始播放预览 */
  34. void startPlay();
  35. /* 设置播放窗口父指针 */
  36. void setPlayerParent(QWidget* playWnd);
  37. /* 设置播放窗口大小 */
  38. void setPlayWndSize(int width, int height);
  39. /* 获取播放窗口指针 */
  40. QWidget* getPlayWnd() { return m_player; }
  41. private slots:
  42. /* 更新一帧数据 */
  43. void do_updateFrame();
  44. private:
  45. /* 异常回调函数 */
  46. static void exceptionCallBack(unsigned int type, int userID,int handle,void* user);
  47. /* 实时预览回调函数 */
  48. static void realDataCallBack(LONG realHandle, DWORD dataType, BYTE *pBuffer,DWORD bufSize,void* user);
  49. /* 标准数据流的预览回调函数 */
  50. static void realDataCallBackStandard(LONG realHandle, DWORD dataType, BYTE *pBuffer,DWORD bufSize,DWORD user);
  51. /* 解码回调函数 */
  52. static void DecCallBack(int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nUser,int nReserved2);
  53. /* YV12转RGB888 */
  54. static void YV12ToRGB888(unsigned char *pYV12Data, unsigned char *pRGB24Data, int width, int height);
  55. /* YV12转YUV */
  56. static void YV12ToYUV420(unsigned char *pYV12Data, Image_YUV420& yuvData, int width, int height);
  57. private:
  58. int m_sdkVersion = 3; /* SDK版本,这个版本自己定义的,为了区分不同的接口函数 */
  59. LONG m_loginID; /* 登陆返回的用户ID,后续对摄像头的操作都需要这个ID */
  60. CameraInfo m_camInfo; /* 登陆上的设备信息 */
  61. LONG m_realPlayHandle = -1; /* 实时预览句柄 */
  62. LONG m_playPort = -1; /* 全局的播放库port号 */
  63. int m_frameRate = 0; /* 帧率 */
  64. RingQueue<Image_YUV420*>* m_yuvQueue = nullptr; /* 环形队列,存放YUV数据 */
  65. QTimer m_frameTimer; /* 定时器,用于更新一帧数据 */
  66. PlayerGLWidget* m_player = nullptr; /* 播放窗口 */
  67. };
  68. #endif // CAMERAPLAYER_H