Explorar o código

V0.7.1
1、兼容了Linux版本

Apple hai 1 mes
pai
achega
d57244a748

+ 38 - 12
CPlayer/HKSDKAPI/hksdkapi.cpp

@@ -2,7 +2,6 @@
 
 #include "LHQLogAPI.h"
 
-#include <QString>
 #include <QLibrary>
 
 
@@ -23,6 +22,8 @@ using pNET_DVR_GetLastError = DWORD(*)();
 using pNET_DVR_RealPlay_V40 = LONG(*)(LONG lUserID, LPNET_DVR_PREVIEWINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30, void* pUser);
 using pNET_DVR_StopRealPlay = bool(*)(LONG lRealHandle);
 
+using pNET_DVR_SetExceptionCallBack_V30 =  BOOL(*)(UINT reserved1, void* reserved2, void (CALLBACK* fExceptionCallBack)(DWORD dwType, LONG lUserID, LONG lHandle, void *pUser), void *pUser);
+
 
 /* 播放相关的函数指针 */
 using pPlayM4_GetPort = BOOL(*)(LONG* nPort);
@@ -30,12 +31,18 @@ using pPlayM4_FreePort = BOOL(*)(LONG nPort);
 using pPlayM4_Stop = BOOL(*)(LONG nPort);
 using pPlayM4_OpenStream = BOOL(*)(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);
 using pPlayM4_CloseStream = BOOL(*)(LONG nPort);
-using pPlayM4_SetDecCallBackMend = BOOL(*)(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char * pBuf, long nSize, FRAME_INFO * pFrameInfo, void* nUser,void* nReserved2), void* nUser);
+
 using pPlayM4_Play = BOOL(*)(LONG nPort, HWND hWnd);
 using pPlayM4_PlaySound = BOOL(*)(LONG nPort);
 using pPlayM4_InputData = BOOL(*)(LONG nPort,PBYTE pBuf,DWORD nSize);
 using pPlayM4_GetLastError = DWORD(*)(LONG nPort);
 
+#if defined (Q_OS_WIN)
+using pPlayM4_SetDecCallBackMend = BOOL(*)(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char * pBuf, long nSize, FRAME_INFO * pFrameInfo, void* nUser,void* nReserved2), void* nUser);
+#elif defined (Q_OS_LINUX)
+using pPlayM4_SetDecCallBackMend = int(*)(int nPort,void (CALLBACK* DecCBFun)(int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nUser,int nReserved2), void* nUser);
+#endif
+
 
 /* 网络登录相关的函数指针 */
 pNet_DEV_Init g_NET_DVR_Init = nullptr;
@@ -49,6 +56,8 @@ pNET_DVR_GetLastError g_NET_DVR_GetLastError = nullptr;
 pNET_DVR_RealPlay_V40 g_NET_DVR_RealPlay_V40 = nullptr;
 pNET_DVR_StopRealPlay g_NET_DVR_StopRealPlay = nullptr;
 
+pNET_DVR_SetExceptionCallBack_V30 g_NET_DVR_SetExceptionCallBack_V30 = nullptr;
+
 /* 播放相关的函数指针 */
 pPlayM4_GetPort g_PlayM4_GetPort = nullptr;
 pPlayM4_FreePort g_PlayM4_FreePort = nullptr;
@@ -96,10 +105,12 @@ bool load_HKSDK_Library(QString libPath)
     g_NET_DVR_GetLastError = (pNET_DVR_GetLastError)libNet.resolve("NET_DVR_GetLastError");
     g_NET_DVR_RealPlay_V40 = (pNET_DVR_RealPlay_V40)libNet.resolve("NET_DVR_RealPlay_V40");
     g_NET_DVR_StopRealPlay = (pNET_DVR_StopRealPlay)libNet.resolve("NET_DVR_StopRealPlay");
+    g_NET_DVR_SetExceptionCallBack_V30 = (pNET_DVR_SetExceptionCallBack_V30)libNet.resolve("NET_DVR_SetExceptionCallBack_V30");
 
     if(g_NET_DVR_Init == nullptr || g_NET_DVR_Cleanup == nullptr || g_NET_DVR_SetConnectTime == nullptr || 
         g_NET_DVR_SetReconnect == nullptr || g_NET_DVR_Login_V40 == nullptr || g_NET_DVR_Logout == nullptr ||
-        g_NET_DVR_GetLastError == nullptr || g_NET_DVR_RealPlay_V40 == nullptr || g_NET_DVR_StopRealPlay == nullptr)
+        g_NET_DVR_GetLastError == nullptr || g_NET_DVR_RealPlay_V40 == nullptr || g_NET_DVR_StopRealPlay == nullptr ||
+        g_NET_DVR_SetExceptionCallBack_V30 == nullptr)
     {
         LH_WRITE_ERROR("load HCNetSDK library failed, resolve function failed!");
         return false;
@@ -226,6 +237,16 @@ bool NET_DVR_StopRealPlay(LONG lRealHandle)
     return g_NET_DVR_StopRealPlay(lRealHandle);
 }
 
+bool NET_DVR_SetExceptionCallBack_V30(UINT reserved1, void* reserved2, void (CALLBACK* fExceptionCallBack)(DWORD dwType, LONG lUserID, LONG lHandle, void* pUser), void* pUser)
+{
+    if(g_NET_DVR_SetExceptionCallBack_V30 == nullptr)
+    {
+        LH_WRITE_ERROR("NET_DVR_SetExceptionCallBack_V30 is nullptr");
+        return false;
+    }
+    return g_NET_DVR_SetExceptionCallBack_V30(reserved1, reserved2, fExceptionCallBack, pUser);
+}
+
 bool PlayM4_GetPort(LONG* nPort)
 {
     if(g_PlayM4_GetPort == nullptr)
@@ -276,15 +297,6 @@ bool PlayM4_CloseStream(LONG nPort)
     return g_PlayM4_CloseStream(nPort);
 }
 
-bool PlayM4_SetDecCallBackMend(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char * pBuf, long nSize, FRAME_INFO * pFrameInfo, void* nUser,void* nReserved2), void* nUser)
-{
-    if(g_PlayM4_SetDecCallBackMend == nullptr)
-    {
-        LH_WRITE_ERROR("PlayM4_SetDecCallBackMend is nullptr");
-        return false;
-    }
-    return g_PlayM4_SetDecCallBackMend(nPort, DecCBFun, nUser);
-}
 
 bool PlayM4_Play(LONG nPort, HWND hWnd)
 {
@@ -325,3 +337,17 @@ DWORD PlayM4_GetLastError(LONG nPort)
     }
     return g_PlayM4_GetLastError(nPort);
 }
+
+#if defined (Q_OS_WIN)
+bool PlayM4_SetDecCallBackMend(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char * pBuf, long nSize, FRAME_INFO * pFrameInfo, void* nUser,void* nReserved2), void* nUser)
+#elif defined (Q_OS_LINUX)
+bool PlayM4_SetDecCallBackMend(int nPort, void (CALLBACK* DecCBFun)(int nPort, char * pBuf, int nSize, FRAME_INFO * pFrameInfo, void* nUser, int nReserved2), void* nUser)
+#endif
+{
+    if(g_PlayM4_SetDecCallBackMend == nullptr)
+    {
+        LH_WRITE_ERROR("PlayM4_SetDecCallBackMend is nullptr");
+        return false;
+    }
+    return g_PlayM4_SetDecCallBackMend(nPort, DecCBFun, nUser);
+}

+ 10 - 2
CPlayer/HKSDKAPI/hksdkapi.h

@@ -3,7 +3,7 @@
 
 #include "hksdkdefine.h"
 
-class QString;
+#include <QString>
 
 
 /* ========================================================================
@@ -27,6 +27,8 @@ DWORD NET_DVR_GetLastError();
 LONG NET_DVR_RealPlay_V40(LONG lUserID, LPNET_DVR_PREVIEWINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30, void* pUser);
 bool NET_DVR_StopRealPlay(LONG lRealHandle);
 
+bool NET_DVR_SetExceptionCallBack_V30(UINT reserved1, void* reserved2, void (CALLBACK* fExceptionCallBack)(DWORD dwType, LONG lUserID, LONG lHandle, void* pUser), void* pUser);
+
 
 /* 播放器 PlayM4 API */
 bool PlayM4_GetPort(LONG* nPort);
@@ -34,11 +36,17 @@ bool PlayM4_FreePort(LONG nPort);
 bool PlayM4_Stop(LONG nPort);
 bool PlayM4_OpenStream(LONG nPort, PBYTE pFileHeadBuf, DWORD nSize, DWORD nBufPoolSize);
 bool PlayM4_CloseStream(LONG nPort);
-bool PlayM4_SetDecCallBackMend(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char* pBuf, long nSize, FRAME_INFO* pFrameInfo, void* nUser, void* nReserved2), void* nUser);
 bool PlayM4_Play(LONG nPort, HWND hWnd);
 bool PlayM4_PlaySound(LONG nPort);
 bool PlayM4_InputData(LONG nPort, PBYTE pBuf, DWORD nSize);
 DWORD PlayM4_GetLastError(LONG nPort);
 
+#if defined (Q_OS_WIN)
+bool PlayM4_SetDecCallBackMend(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char* pBuf, long nSize, FRAME_INFO* pFrameInfo, void* nUser, void* nReserved2), void* nUser);
+#elif defined (Q_OS_LINUX)
+bool PlayM4_SetDecCallBackMend(int nPort, void (CALLBACK* DecCBFun)(int nPort, char* pBuf, int nSize, FRAME_INFO* pFrameInfo, void* nUser, int nReserved2), void* nUser);
+#endif
+
+
 
 #endif /* HKSDKAPI_H */

+ 1 - 0
CPlayer/HKSDKAPI/hksdkdefine.h

@@ -16,6 +16,7 @@
     typedef  short              SHORT;
     typedef  int                LONG;
     typedef  unsigned char      BYTE;
+    typedef unsigned char*      PBYTE;
     typedef  unsigned int       UINT;
     typedef  void*              LPVOID;
     typedef  void*              HANDLE;

+ 1 - 1
CPlayer/cameraplayer.cpp

@@ -452,7 +452,7 @@ void CameraPlayer::DecCallBack(int nPort, char * pBuf, int nSize,FRAME_INFO * pF
         // LH_WRITE_LOG("音频数据");
     } else
     {
-        LH_WRITE_LOG("其他数据");
+        LH_WRITE_LOG_DEBUG(QString("其他数据: %1").arg(pFrameInfo->nType));
     }
 
     /* 计算解码时间 */

+ 7 - 7
show1/CMakeLists.txt

@@ -73,13 +73,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
 
 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
     target_link_libraries(${execName} PRIVATE
-        HCCore
-        hcnetsdk
-        libssl.so.1.1
-        libcrypto.so.1.1
-        AudioRender
-        PlayCtrl
-        SuperRender
+        # HCCore
+        # hcnetsdk
+        # libssl.so.1.1
+        # libcrypto.so.1.1
+        # AudioRender
+        # PlayCtrl
+        # SuperRender
     )
     target_link_libraries(${execName} PRIVATE
         GL