浏览代码

Z991240-991 #comment bugfix:解决协助通道连线找不到acmstr库问题

胡琛80272472 4 年之前
父节点
当前提交
4bd937ff52

+ 6 - 0
Module/mod_assistantchannel/mod_assistantchannel.cpp

@@ -106,6 +106,9 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
 		}
 		ListEntry_InitHead(&m_stateList);
 		ListEntry_InitHead(&m_rxpktList);
+
+
+		//Connect("99.1.100.215", 2323, "9990", NORMAL_CALLTYPE);
 		return Error_Succeed;
 	}
 
@@ -152,6 +155,7 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
 			cb.on_connect = &__on_connect;
 			cb.on_destroy = &__on_destroy;
 			cb.on_recv_pkt = &__on_recv_pkt;
+			cb.dbg = &__dbg;
 			int rc = bizchan_create(&config, &cb, &m_pChan);
 			if (rc == 0) 
 			{
@@ -166,6 +170,8 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
 		{
 			Error = Error_InvalidState;
 		}
+
+		//Dbg("Connect: %d", Error);
 		return Error;
 	}
 

+ 5 - 0
Module/mod_assistantchannel/mod_assistantchannel.h

@@ -115,6 +115,11 @@ private:
 	static void __on_destroy(bizchan_t* chan, void* user_data)
 	{
 	}
+	static void __dbg(bizchan_t* chan, int level, char *msg, void* user_data)
+	{
+		CBizChannelEntity* pThis = static_cast<CBizChannelEntity*>(user_data);
+		Dbg(msg);
+	}
 
 private:
 	DeviceTypeEnum m_eDeviceType;

+ 9 - 0
Other/acmstrdec/acmstrdec.h

@@ -20,4 +20,13 @@
 #define ACMSTRDEC_API
 #endif //_WIN32
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 ACMSTRDEC_API int decodestring(unsigned char *  out ,int outLen,const unsigned char * in,int  inLen);
+
+#ifdef __cplusplus
+} // extern "C" {
+#endif

+ 7 - 0
Other/acmstrenc/acmstrenc.h

@@ -20,5 +20,12 @@
 #define ACMSTRENC_API
 #endif //_WIN32
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 ACMSTRENC_API  int encodestring(unsigned char *  out ,int outLen,const unsigned char * in,int  inLen);
 
+#ifdef __cplusplus
+} // extern "C" {
+#endif

+ 2 - 2
Other/libbizchan/CMakeLists.txt

@@ -46,9 +46,9 @@ target_compile_definitions(${MODULE_NAME} PUBLIC "LIBBIZCHAN_EXPORTS")
 # 添加需要依赖的其他共享库(包括系统库)
 target_link_directories(${MODULE_NAME} PRIVATE ${CONAN_LIB_DIRS_OPENJPEG} ${CONAN_LIB_DIRS_ZLIB})
 if(WIN32)
-target_link_libraries(${MODULE_NAME} PRIVATE libscreencodec ${CONAN_PKG_LIBS_OPENJPEG} ${CONAN_PKG_LIBS_ZLIB} CONAN_PKG::OpenSSL ws2_32)
+target_link_libraries(${MODULE_NAME} PRIVATE acmstrdec acmstrenc libscreencodec ${CONAN_PKG_LIBS_OPENJPEG} ${CONAN_PKG_LIBS_ZLIB} CONAN_PKG::OpenSSL ws2_32)
 else()
-target_link_libraries(${MODULE_NAME} PRIVATE libscreencodec ${CONAN_PKG_LIBS_OPENJPEG} ${CONAN_PKG_LIBS_ZLIB} CONAN_PKG::OpenSSL)
+target_link_libraries(${MODULE_NAME} PRIVATE acmstrdec acmstrenc libscreencodec ${CONAN_PKG_LIBS_OPENJPEG} ${CONAN_PKG_LIBS_ZLIB} CONAN_PKG::OpenSSL)
 endif(WIN32)
 
 if(MSVC)

+ 51 - 25
Other/libbizchan/bizchan.c

@@ -783,7 +783,7 @@ static unsigned int __stdcall work_proc(void *arg)
 }
 
 #ifdef RVC_OS_WIN
-static int init_decode_func()
+static int init_decode_func(const bizchan_config_t* config, const bizchan_callback_t* cb)
 {
 	int ret = -1;
 	if (!encodestring) {
@@ -827,19 +827,25 @@ static int init_decode_func()
 }
 
 #else
-static int init_decode_func()
+static int init_decode_func(const bizchan_config_t* config, const bizchan_callback_t* cb)
 {
 	int ret = -1;
 	if (!encodestring) {
-		HMODULE hInst = LoadLibraryA("acmstrenc.so");
+		HMODULE hInst = LoadLibraryA("libacmstrenc.so");
 		if (hInst) {
 			encodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
 		}
-		if (!encodestring)
+		else {
+			cb->dbg(NULL, 2, "libacmstrenc LoadLibraryA failed", cb->user_data);
+		}
+		if (!encodestring) {
+			cb->dbg(NULL, 2, "libacmstrenc GetProcAddress failed", cb->user_data);
 			return ret;
+		}
+
 	}
 	if (!decodestring) {
-		HMODULE hInst = LoadLibraryA("acmstrdec.so");
+		HMODULE hInst = LoadLibraryA("libacmstrdec.so");
 		if (hInst) {
 			decodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
 		}
@@ -847,26 +853,29 @@ static int init_decode_func()
 			return ret;
 	}
 
-	if (!encodestring_mobile) {
-		HMODULE hInst = LoadLibraryA("acmstrenc_mobile.so");
-		if (hInst) {
-			encodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
+	if (1 == config->crypt_type) {
+		if (!encodestring_mobile) {
+			HMODULE hInst = LoadLibraryA("libacmstrenc_mobile.so");
+			if (hInst) {
+				encodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
+			}
+			if (!encodestring_mobile)
+				return ret;
 		}
-		if (!encodestring_mobile)
-			return ret;
-	}
-	if (!decodestring_mobile) {
-		HMODULE hInst = LoadLibraryA("acmstrdec_mobile.so");
-		if (hInst) {
-			decodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
+		if (!decodestring_mobile) {
+			HMODULE hInst = LoadLibraryA("libacmstrdec_mobile.so");
+			if (hInst) {
+				decodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
+			}
+			if (!decodestring_mobile)
+				return ret;
 		}
-		if (!decodestring_mobile)
-			return ret;
 	}
 
-	if (encodestring && decodestring && encodestring_mobile && decodestring_mobile) {
+	if (encodestring && decodestring) {
 		ret = 0;
 	}
+
 	return ret;
 }
 #endif
@@ -875,16 +884,25 @@ BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_ca
 {
 	bizchan_t *chan = NULL;
 
-	if (-1 == init_decode_func()){
+	if (-1 == init_decode_func(config, cb)){
+		cb->dbg(chan, 2, "init_decode_func failed", cb->user_data);
 		return -1;
 	}
 
-	if (!config || !p_chan)
+	if (!config || !p_chan) {
+		cb->dbg(chan, 2, "config or chan is null, failed", cb->user_data);
 		return -1;
-	if (config_check(config) != 0)
+	}
+
+	if (config_check(config) != 0) {
+		cb->dbg(chan, 2, "config_check failed", cb->user_data);
 		return -1;
-	if (callback_check(cb) != 0)
+	}
+
+	if (callback_check(cb) != 0) {
+		cb->dbg(chan, 2, "callback_check failed", cb->user_data);
 		return -1;
+	}
 
 	chan = (bizchan_t*)malloc(sizeof(bizchan_t));
 	if (!chan)
@@ -905,10 +923,12 @@ BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_ca
 		goto on_error;
 
 	*p_chan = chan;
+	cb->dbg(chan, 0, "bizchan_create success", cb->user_data);
 
 	return 0;
 
 on_error:
+	cb->dbg(chan, 2, "bizchan_create on_error", cb->user_data);
 	bizchan_destroy(chan);
 	return -1;
 }
@@ -961,10 +981,15 @@ BIZCHAN_API(void*) bizchan_get_tag(bizchan_t *chan)
 
 BIZCHAN_API(int) bizchan_start_connect(bizchan_t *chan)
 {
-	if (!chan)
+	if (!chan) {
+		chan->cb.dbg(chan, 2, "chan is null", chan->cb.user_data);
 		return -1;
-	if (chan->work_thread)
+	}
+
+	if (chan->work_thread) {
+		chan->cb.dbg(chan, 2, "work_thread exsit!!!", chan->cb.user_data);
 		return -1;
+	}
 
 	WSAResetEvent(chan->evt);
 
@@ -976,6 +1001,7 @@ BIZCHAN_API(int) bizchan_start_connect(bizchan_t *chan)
 	}
 
 	// we now return, when connected, on_connect will invoked in work_proc thread
+	chan->cb.dbg(chan, 0, "bizchan_start_connect success", chan->cb.user_data);
 
 	return 0;
 }

+ 1 - 0
Other/libbizchan/bizchan.h

@@ -45,6 +45,7 @@ typedef struct bizchan_callback_t  {
 	void (*on_connect)(bizchan_t *chan, int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc, const char *remote_client_id, void *user_data);
 	void (*on_close)(bizchan_t *chan, void *user_data);
 	void (*on_destroy)(bizchan_t *chan, void *user_data);
+	void (*dbg)(bizchan_t* chan, int level, char *msg, void* user_data);
 	void *user_data;
 }bizchan_callback_t;