Procházet zdrojové kódy

Z991239-5559 #comment 优化跨平台实现方式

80274480 před 1 rokem
rodič
revize
b38d9a0480
29 změnil soubory, kde provedl 605 přidání a 494 odebrání
  1. 1 1
      Module/mod_SalesRecorder/CMakeLists.txt
  2. 1 1
      Module/mod_assistantchannel/CMakeLists.txt
  3. 1 1
      Module/mod_facetracking/CMakeLists.txt
  4. 2 2
      Module/mod_livenessdetection/CMakeLists.txt
  5. 2 2
      Module/mod_localmediaplay/CMakeLists.txt
  6. 2 2
      Module/mod_mediacontroller/CMakeLists.txt
  7. 1 1
      Module/mod_recorder/CMakeLists.txt
  8. 2 2
      Module/mod_screenshot/CMakeLists.txt
  9. 1 1
      Module/mod_sipphone/CMakeLists.txt
  10. 6 10
      Module/mod_sipphone/endpoint.h
  11. 0 86
      Module/mod_sipphone/media_config_const.h
  12. 12 18
      Module/mod_sipphone/mod_sipphone.h
  13. 179 10
      Module/mod_sipphone/unix/endpoint.cpp
  14. 203 84
      Module/mod_sipphone/unix/mod_sipphone.cpp
  15. 42 47
      Module/mod_sipphone/unix/video_session.cpp
  16. 9 0
      Module/mod_sipphone/video_render.h
  17. 0 9
      Module/mod_sipphone/win/audio_session.cpp
  18. 88 24
      Module/mod_sipphone/win/endpoint.cpp
  19. 42 55
      Module/mod_sipphone/win/mod_sipphone.cpp
  20. 6 14
      Module/mod_sipphone/win/video_session.cpp
  21. 1 1
      Module/mod_snapshot/CMakeLists.txt
  22. 0 0
      Other/rvcmediacommon/common_video/videocommon.h
  23. 0 0
      Other/rvcmediacommon/rvc_media_common.h
  24. 1 1
      Other/unix/libvideocapture/CMakeLists.txt
  25. 1 1
      Other/unix/libvideoframework/videortp.c
  26. 1 1
      Other/win/libaudiorender/libaudiorender.cpp
  27. 1 1
      Other/win/libvideoframework/videortp.c
  28. 0 21
      Other/win/rvcmediacommon/common_video/videocommon.h
  29. 0 98
      Other/win/rvcmediacommon/rvc_media_common.h

+ 1 - 1
Module/mod_SalesRecorder/CMakeLists.txt

@@ -17,7 +17,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${MODULE_BASE_DIR}/mod_healthmanager
 	${OTHER_LIB_BASE_DIR}
 	${OTHER_LIB_PLATFORM_BASE_DIR}
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${CMAKE_CURRENT_SOURCE_DIR}
 	${OTHER_LIB_BASE_DIR}/libfilecryption
 )

+ 1 - 1
Module/mod_assistantchannel/CMakeLists.txt

@@ -13,7 +13,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${RVC_FRAMEWORK_INCLUDES_DIR}
     ${MODULE_BASE_DIR}
     ${OTHER_LIB_PLATFORM_BASE_DIR}/libbizchan
-    ${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+    ${OTHER_LIB_BASE_DIR}/rvcmediacommon
     )
 
 

+ 1 - 1
Module/mod_facetracking/CMakeLists.txt

@@ -11,7 +11,7 @@ add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME} ${MOD_VERSION_STRING})
 
 
 target_include_directories(${MODULE_NAME} PRIVATE
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libbizchan
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libfacecapture

+ 2 - 2
Module/mod_livenessdetection/CMakeLists.txt

@@ -33,7 +33,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${RVC_TOOLKIT_INCLUDE_DIR}
 	${CONAN_INCLUDE_DIRS_FFMPEG}
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 	${MODULE_BASE_DIR}
 	${MODULE_BASE_DIR}/include
@@ -49,7 +49,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${RVC_TOOLKIT_INCLUDE_DIR}
 	${CONAN_INCLUDE_DIRS_FFMPEG}
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 	${MODULE_BASE_DIR}
 	${MODULE_BASE_DIR}/include

+ 2 - 2
Module/mod_localmediaplay/CMakeLists.txt

@@ -29,7 +29,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libimgplayer
 	${OTHER_LIB_BASE_DIR}/libpictureplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 )
 set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} ShLwApi Shell32 imgplayer wmpplayer mediaplayer audioqueue pictureplayer)
 else(WIN32)
@@ -37,7 +37,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${OTHER_LIB_BASE_DIR}/libmediaplayer
 	${OTHER_LIB_BASE_DIR}/libpictureplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 )
 set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} audioqueue mediaplayer pictureplayer)
 endif(WIN32)

+ 2 - 2
Module/mod_mediacontroller/CMakeLists.txt

@@ -32,7 +32,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideocapture
 	#todo
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideohorflip
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libmediadeviceinfo
@@ -45,7 +45,7 @@ else()
 		${CMAKE_CURRENT_SOURCE_DIR}
 		${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
 		${OTHER_LIB_PLATFORM_BASE_DIR}/libvideohorflip
-		${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+		${OTHER_LIB_BASE_DIR}/rvcmediacommon
 		${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
 		${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 		${OTHER_LIB_PLATFORM_BASE_DIR}/libaudiorender

+ 1 - 1
Module/mod_recorder/CMakeLists.txt

@@ -16,7 +16,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
     ${CONAN_INCLUDE_DIRS_FFMPEG}
     ${MODULE_BASE_DIR}
     ${OTHER_LIB_PLATFORM_BASE_DIR}/libvideorecord
-    ${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+    ${OTHER_LIB_BASE_DIR}/rvcmediacommon
     ${OTHER_LIB_BASE_DIR}/libfilecryption
     ${CONAN_INCLUDE_DIRS_JSONCPP}
     )

+ 2 - 2
Module/mod_screenshot/CMakeLists.txt

@@ -20,7 +20,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
     ${MODULE_BASE_DIR}
 	${MODULE_BASE_DIR}/include
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_BASE_DIR}/libscreencodec
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libbizchan
 	${CONAN_INCLUDE_DIRS_OPENCV}
@@ -39,7 +39,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
     ${MODULE_BASE_DIR}
 	${MODULE_BASE_DIR}/include
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_BASE_DIR}/libscreencodec
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libbizchan
 	${CONAN_INCLUDE_DIRS_OPENCV}

+ 1 - 1
Module/mod_sipphone/CMakeLists.txt

@@ -56,7 +56,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${CMAKE_CURRENT_SOURCE_DIR}
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideorender

+ 6 - 10
Module/mod_sipphone/endpoint.h

@@ -6,8 +6,6 @@
 #include "mod_counterconnector/CallType.h"
 
 #ifdef _WIN32
-#include <process.h>
-#include <objbase.h>
 #else
 #include "video_render.h"
 #endif
@@ -56,11 +54,11 @@ typedef struct endpoint_conf_t {
 	char audio_pickup_in_dev[MAX_PATH];
 	char audio_pickup_out_dev[MAX_PATH];
 	endpoint_audiodsp_config_t audio_dsp;
-#if defined(RVC_OS_WIN)
+#ifdef _WIN32
 	int irendertype;
 	int istoptype;
 	int icaptype;
-#endif //RVC_OS_WIN
+#endif //_WIN32
 
 	int mtu;
 	int quant;
@@ -135,10 +133,8 @@ void endpoint_call_destroy(endpoint_call_t *call);
 int endpoint_call_start(endpoint_call_t *call);
 int endpoint_call_hangup(endpoint_call_t *call);
 
-#if defined(RVC_OS_WIN)
-/*
-	add by chenlp 20190826  新增int local_move和int remote_move参数,分别用于设置本地和远端视频窗口是否支持移动
-*/
+#ifdef _WIN32
+
 int endpoint_call_start_video(endpoint_call_t* call, unsigned long remote_ip, int remote_video_rtp,
 	unsigned long local_ip, int local_video_rtp,
 	int remote_width, int remote_height,
@@ -153,13 +149,13 @@ int local_play_start_video(endpoint_call_t* call, int local_view_x, int local_vi
 int local_play_stop_video(endpoint_call_t* call);
 int local_remote_show_video(endpoint_call_t* call, int local_view_x, int local_view_y, int local_view_cx, int local_view_cy, int remote_view_x, int remote_view_y, int remote_view_cx, int remote_view_cy, int local_move, int remote_move, video_session_callback_t* cb);
 
-void Terminatedcall(endpoint_call_t* call);
+void terminatedcall(endpoint_call_t* call);
 int translate_ipaddr_from_int(char* strdst, size_t ulen, unsigned long uip);
 #else
 int endpoint_call_start_video(endpoint_call_t* call, endpoint_call_param_t* pcallparam, rvc_video_render_callback_t* render_cb);
 int endpoint_call_stop_video(endpoint_call_t* call);
 void terminatedcall(endpoint_call_t* call);
 int translate_ipaddr_from_int(char* strdst, unsigned ulen, unsigned long uip);
-#endif //RVC_OS_WIN
+#endif //_WIN32
 
 #endif // ENDPOINT_H

+ 0 - 86
Module/mod_sipphone/media_config_const.h

@@ -1,86 +0,0 @@
-#ifndef MEDIA_CONFIG_COMMON_H
-#define MEDIA_CONFIG_COMMON_H
-
-#pragma once
-
-// video codec: h264, audio codec: G729a 
-
-// video size of single screen: 320x240(remote), 320x240(local)
-// video size of dual screen:	640x480(remote), 320x240(local) 双屏双摄像头通知周小斌,改回320x240
-
-#define MEDIA_CONFIG_AUDIO_FRAME_PTIME	100
-#define MEDIA_CONFIG_AUDIO_FRAME_PSIZE	165
-
-#define MEDIA_CONFIG_AUDIO_CLOCK	8000
-#define MEDIA_CONFIG_VIDEO_CLOCK	90000
-
-#define MEDIA_CONFIG_VIDEO_FPS_DEN	1
-#define MEDIA_CONFIG_VIDEO_FPS_NUM	10			//8
-#define MEDIA_CONFIG_VIDEO_FPS_MOBILE 8           //5   //移动版视频5帧/s
-#define MEDIA_CONFIG_VIDEO_FPS_MOBILE_AGENT 8 	//2  //移动版坐席视频2帧/s
-#define MEDIA_CONFIG_VIDEO_FPS		10.0f		//8.0f
-#define MEDIA_CONFIG_VIDEO_RAW_FPS	15.0f		//8.0f
-#define MEDIA_CONFIG_VIDEO_PADRAW_FPS	10.0f	
-
-#define MEDIA_CONFIG_VIDEO_RAW_FPS_DEN	1
-#define MEDIA_CONFIG_VIDEO_RAW_FPS_NUM	8
-#define MEDIA_CONFIG_VIDEO_SNAPSHOT_FPS	1.0f
-#define MEDIA_CONFIG_VIDEO_CAPTURE_FRAME_INTERVAL	8
-#define MEDIA_CONFIG_VIDEO_ENCODE_FRAME_INTERVAL	1
-
-#define MEDIA_CONFIG_AUDIO_PT		18	// g729
-#define MEDIA_CONFIG_VIDEO_PT		101 // H264+
-#define MEDIA_CONFIG_VIDEO_H264_PT  97  // H264
-
-#define MEDIA_CONFIG_JITTER_MIN_CACHE_MSEC	1000
-#define MEDIA_CONFIG_JITTER_MAX_CACHE_MSEC	2000
-
-#define MEDIA_CONFIG_VIDEO_RTP_ENV_WIDTH	320	
-#define MEDIA_CONFIG_VIDEO_RTP_ENV_HEIGHT	180
-#define MEDIA_CONFIG_VIDEO_RTP_OPT_WIDTH	180
-#define MEDIA_CONFIG_VIDEO_RTP_OPT_HEIGHT	320
-
-#define MEDIA_CONFIG_VIDEO_PREVIEW_WIDTH	320
-#define MEDIA_CONFIG_VIDEO_PREVIEW_HEIGHT	240
-
-#define MEDIA_CONFIG_VIDEO_RTP_WIDTH		320
-#define MEDIA_CONFIG_VIDEO_RTP_HEIGHT		320
-#define MEDIA_CONFIG_VIDEO_RTP_PADDING		70
-
-#define MEDIA_CONFIG_VIDEO_SNAPSHOT_WIDTH	640
-#define MEDIA_CONFIG_VIDEO_SNAPSHOT_HEIGHT	360
-#define MEDIA_CONFIG_VIDEO_SNAPSHOT_PREVIEW_WIDTH	480
-#define MEDIA_CONFIG_VIDEO_SNAPSHOT_PREVIEW_HEIGHT	360
-
-#define MEDIA_CONFIG_VIDEO_AGENT_RAW_WIDTH	1280
-#define MEDIA_CONFIG_VIDEO_AGENT_RAW_HEIGHT	720
-
-#define MEDIA_CONFIG_VIDEO_AGENT_PREVIEW_WIDTH	320
-#define MEDIA_CONFIG_VIDEO_AGENT_PREVIEW_HEIGHT	320
-
-#define MEDIA_CONFIG_VIDEO_SSM_AGENT_WIDTH	320	// single screen mode(ssm)
-#define MEDIA_CONFIG_VIDEO_SSM_AGENT_HEIGHT	240
-#define MEDIA_CONFIG_VIDEO_DSM_AGENT_WIDTH	640	// dual screen mode(dsm)
-#define MEDIA_CONFIG_VIDEO_DSM_AGENT_HEIGHT	480
-
-#define MEDIA_CONFIG_AUDIO_PORT_START			30004  //30002用于本地录像
-#define MEDIA_CONFIG_AUDIO_PORT_STOP			30500
-#define MEDIA_CONFIG_VIDEO_PORT					30000
-
-#define MEDIA_CONFIG_CAMERA_TYPE_ERROR -1
-#define MEDIA_CONFIG_CAMERA_TYPE_ENV	0
-#define MEDIA_CONFIG_CAMERA_TYPE_OPT	1
-#define MEDIA_CONFIG_CAMERA_TYPE_AUTO	2
-
-
-#define MEDIA_CONFIG_VIDEO_ENV_SHM_SNAPSHOT_QUEUE		"rvc.shm.snapshot.video.env.q"	// 640x360@1fps RGB24
-#define MEDIA_CONFIG_VIDEO_ENV_SHM_RTP_QUEUE			"rvc.shm.rtp.video.env.q"		// 320x180@8fps I420
-#define MEDIA_CONFIG_VIDEO_ENV_SHM_PREVIEW_QUEUE		"rvc.shm.preview.video.env.q"	// 320x240@8fps RGB24
-
-#define MEDIA_CONFIG_VIDEO_OPT_SHM_SNAPSHOT_QUEUE		"rvc.shm.snapshot.video.opt.q"	// 360x640@1fps RGB24
-#define MEDIA_CONFIG_VIDEO_OPT_SHM_RTP_QUEUE			"rvc.shm.rtp.video.opt.q"		// 180x320@8fps I420
-#define MEDIA_CONFIG_VIDEO_OPT_SHM_PREVIEW_QUEUE		"rvc.shm.preview.video.opt.q"	// 240x320@8fps RGB24
-
-#define MEDIA_CONFIG_AUDIO_SHM_QUEUE					"rvc.shm.audio.q"
-
-#endif // MEDIA_CONFIG_H

+ 12 - 18
Module/mod_sipphone/mod_sipphone.h

@@ -317,16 +317,9 @@ public:
 	CSimpleStringA MakeUri(const char *terminal_id);
 
 private:
-
 	ErrorCodeEnum LoadConfig(endpoint_conf_t *conf);
 #if defined(RVC_OS_WIN)
 	eVideoRenderType GetMediaConfig();
-	void HandleUSBAudioDeviceErrorEvent();
-
-	//载入运行时配置
-	ErrorCodeEnum LoadRestartRunConfig(unsigned int& utime);
-	//保存运行时
-	ErrorCodeEnum SaveRestartRunConfig(unsigned int utime);
 #else
 	void InitFreshTimeConfig();
 	void HideLocalVideo();
@@ -334,6 +327,12 @@ private:
 	void HideBothVideo();
 	void ShowBothVideo();
 #endif //RVC_OS_WIN
+
+	void HandleUSBAudioDeviceErrorEvent();
+	//载入运行时配置
+	ErrorCodeEnum LoadRestartRunConfig(unsigned int& utime);
+	//保存运行时
+	ErrorCodeEnum SaveRestartRunConfig(unsigned int utime);
 	ErrorCodeEnum AudioDspFlagsUseCentersetting(endpoint_conf_t* conf);
 	//载入运行时配置
 	ErrorCodeEnum LoadAudioRunConfig(int&nHandfreeout,int&nPickupout,int&nHandfreein,int&nPickupin);
@@ -359,23 +358,18 @@ public:
 	void* m_pKeeperOut[2];
 	eVideoRenderType m_eVideoRenderType;
 	bool m_bAudioMgrInited;
-	CSimpleStringA m_strHandfreeIn;
-	CSimpleStringA m_strHandfreeOut;
-	CSimpleStringA m_strPickUpIn;
-	CSimpleStringA m_strPickUpOut;
+#else
+	int m_ilocalvideo_freshtime;
+	int m_iremotevideo_freshtime;
+	rvc_video_render_t* m_render;
+#endif
+
 	CSimpleStringA m_strStartTime;
 	CSimpleStringA m_strEndTime;
 	int m_itervalTime;
 	bool m_bStopAutoRestart;
 	int m_iAudioDspUseCenter;
-#else
-	int m_ilocalvideo_freshtime;
-	int m_iremotevideo_freshtime;
 
-	rvc_video_render_t* m_render;
-	int m_iAudioDspUseCenter;
-#endif
-	
 	CSystemStaticInfo staticInfo;
 	char m_localip[RVC_MAX_IP_LEN];		//本地ip
 	endpoint_conf_t conf;

+ 179 - 10
Module/mod_sipphone/unix/endpoint.cpp

@@ -1,5 +1,7 @@
+#include "SpBase.h"
 #ifdef RVC_OS_WIN
 #include "stdafx.h"
+#include <ObjBase.h>
 #else
 
 #endif
@@ -24,7 +26,7 @@
 #include "sockutil.h"
 #include "hash.h"
 
-#include "SpBase.h"
+
 
 #include "video_session.h"
 #include "audio_session.h"
@@ -303,7 +305,6 @@ static void endpoint_media_update_audio(endpoint_call_t *call, media_desc_t *aud
 		else{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("call->audio is null.");
 		}
-
 		if (call->video) { // close video also 
 			video_session_stop(call->video);
 			video_session_destroy(call->video);
@@ -583,8 +584,9 @@ static int negotiate_audio(endpoint_call_t *call, media_desc_t *audio_desc, cons
 	local_ip = lm->m_connections ? lm->m_connections->c_address : lm->m_session->sdp_connection->c_address;
 	remote_ip = rm->m_connections ? rm->m_connections->c_address : rm->m_session->sdp_connection->c_address;
 
-	audio_desc->local_ip = local_ip ? inet_addr(local_ip) : 0;
-	audio_desc->local_port = lm->m_port;
+	audio_desc->local_ip = strlen(call->local_ip) ? inet_addr(call->local_ip) : 0;
+	audio_desc->local_port = call->local_media_port;
+
 	audio_desc->remote_ip = remote_ip ? inet_addr(remote_ip) : 0;
 	audio_desc->remote_port = rm->m_port;
 	audio_desc->local_telephone_event_pt = 97;
@@ -616,8 +618,10 @@ static int negotiate_video(endpoint_call_t *call, media_desc_t *video_desc, cons
 	local_ip = lm->m_connections ? lm->m_connections->c_address : lm->m_session->sdp_connection->c_address;
 	remote_ip = rm->m_connections ? rm->m_connections->c_address : rm->m_session->sdp_connection->c_address;
 
-	video_desc->local_ip = local_ip ? inet_addr(local_ip) : 0;
-	video_desc->local_port = lm->m_port;
+
+	video_desc->local_ip = strlen(call->local_ip) ? inet_addr(call->local_ip) : 0;
+	video_desc->local_port = call->local_video_port;
+
 	video_desc->remote_ip = remote_ip ? inet_addr(remote_ip) : 0;
 	video_desc->remote_port = rm->m_port;
 	video_desc->local_telephone_event_pt = 97;
@@ -986,7 +990,7 @@ void* __event_thread(void* arg)
 
 #endif // RVC_OS_WIN
 
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("enter event_thread.");
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("enter event_thread.");
 
 	ep->root = su_root_create(ep);
 
@@ -1008,7 +1012,6 @@ void* __event_thread(void* arg)
 		TAG_NULL());
 
 	su_root_run(ep->root);
-
 	nua_shutdown(ep->nua);
 	ep->nua = NULL;
 	su_root_destroy(ep->root);
@@ -1017,7 +1020,7 @@ void* __event_thread(void* arg)
 #ifdef RVC_OS_WIN
 	CoUninitialize();
 #else
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("leave event_thread.");
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("leave event_thread.");
 #endif // RVC_OS_WIN
 	return 0;
 }
@@ -1137,12 +1140,22 @@ static void __endpoint_stop(endpoint_t *ep)
 		}
 	}
 #endif
+}
 
+static void rvc_sofia_logger(void* stream, char const* fmt, va_list ap) {
+	if (!fmt)
+		return;
+	char line[255];
+	vsnprintf(line, sizeof(line), fmt, ap);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rvc_sofia_logger : %s", line);
 }
 
 int endpoint_init_lib()
 {
-	return su_init();
+	int result = su_init();
+	//su_log_set_level(NULL, 9);
+	//su_log_redirect(NULL, rvc_sofia_logger, NULL);
+	return result;
 }
 
 void endpoint_deinit_lib()
@@ -1388,6 +1401,162 @@ int endpoint_call_stop_video(endpoint_call_t *call)
 }
 
 
+#ifdef RVC_OS_WIN
+
+int endpoint_call_stop_double_record_broadcast_video()
+{
+	double_record_broadcast_video_session_stop();
+
+	return Error_Succeed;
+}
+
+
+int local_play_start_video(endpoint_call_t *call,int local_view_x, int local_view_y, int local_view_cx, int local_view_cy, int local_move, video_session_callback_t* cb)
+{
+	int rc;
+	endpoint_conf_t *ep_conf = &call->ep->conf;
+	if (call->video) 
+	{
+		video_session_destroy(call->video);
+		call->video = NULL;
+	}
+	video_session_conf_t video_conf = {0};
+	video_conf.bit_rate = 256 * 1024;
+	video_conf.local_rtp_ip = 0;
+	video_conf.local_rtp_port = 0;
+	video_conf.local_video_view_x = local_view_x;
+	video_conf.local_video_view_y = local_view_y;
+	video_conf.local_video_view_cx = local_view_cx;
+	video_conf.local_video_view_cy = local_view_cy;
+	video_conf.local_move = local_move;
+	video_conf.mtu = ep_conf->mtu;
+	video_conf.video_quant = ep_conf->quant;
+	video_conf.remote_rtp_ip = 0;
+	video_conf.remote_rtp_port = 0;
+	video_conf.remote_video_view_x = 0;
+	video_conf.remote_video_view_y = 0;
+	video_conf.remote_video_view_cx = 0;
+	video_conf.remote_video_view_cy = 0;
+	video_conf.remote_video_width = 0;
+	video_conf.remote_video_height = 0;
+	video_conf.ref_active_camera = call->ep->conf.ref_active_camera;
+	video_conf.ref_camera_switch = call->ep->conf.ref_camera_switch;
+	video_conf.ref_camera_state = call->ep->conf.ref_camera_state;
+	video_conf.ref_window_state = call->ep->conf.ref_window_state;
+	video_conf.ref_active_img = call->ep->conf.ref_active_img;
+	video_conf.ref_Is_ActiveInspect = call->ep->conf.ref_Is_ActiveInspect;
+	video_conf.ref_Is_showPersonArea = call->ep->conf.ref_Is_showPersonArea;
+	video_conf.ref_Is_showRecordArea = call->ep->conf.ref_Is_showRecordArea;
+	video_conf.camera_count = call->ep->conf.camera_count;
+	video_conf.screen_count = call->ep->conf.screen_count;
+	video_conf.eDeviceType = call->eDeviceType;
+	video_conf.video_echo_cb = cb;
+	video_conf.ilocal_wind_flags = VIDEOPLAYER_FLAG_PULL|VIDEOPLAYER_FLAG_CHECKTOP|VIDEOPLAYER_FLAG_ZOOMOUTSIZE;
+	video_conf.iremote_wind_flags = VIDEOPLAYER_FLAG_PUSH|VIDEOPLAYER_FLAG_CHECKTOP;
+	video_conf.eType = (eVideoRenderType)call->ep->conf.irendertype;
+	video_conf.ivideotype = call->ep->conf.icaptype;
+	rc = Local_video_session_create(&video_conf, &call->video);
+	if (rc != 0) 
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video session failed! rc = %d", rc);
+		return -1;
+	}
+	rc = video_session_start(call->video);
+	if (rc != 0) 
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video session failed! rc = %d", rc);
+		video_session_destroy(call->video);
+		call->video = NULL;
+		return -1;
+	}
+	return 0;
+}
+
+
+int local_remote_show_video(endpoint_call_t *call,int local_view_x, int local_view_y, int local_view_cx, int local_view_cy,int remote_view_x, int remote_view_y, int remote_view_cx, int remote_view_cy, int local_move, int remote_move, video_session_callback_t* cb)
+{
+	int rc;
+	endpoint_conf_t *ep_conf = &call->ep->conf;
+	if (call->video) 
+	{
+		video_session_destroy(call->video);
+		call->video = NULL;
+	}
+	int remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
+	int remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
+	if (eStand2sType == call->eDeviceType){
+		remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
+		remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
+	}
+
+	video_session_conf_t video_conf = {0};
+	video_conf.bit_rate = 256 * 1024;
+	video_conf.local_rtp_ip = 0;
+	video_conf.local_rtp_port = 0;
+	video_conf.local_video_view_x = local_view_x;
+	video_conf.local_video_view_y = local_view_y;
+	video_conf.local_video_view_cx = local_view_cx;
+	video_conf.local_video_view_cy = local_view_cy;
+	video_conf.local_move = local_move;
+	video_conf.mtu = ep_conf->mtu;
+	video_conf.video_quant = ep_conf->quant;
+	video_conf.remote_rtp_ip = 0;
+	video_conf.remote_rtp_port = 0;
+	video_conf.remote_video_view_x = remote_view_x;
+	video_conf.remote_video_view_y = remote_view_y;
+	video_conf.remote_video_view_cx = remote_view_cx;
+	video_conf.remote_video_view_cy = remote_view_cy;
+	video_conf.remote_move = remote_move;
+	video_conf.remote_video_width = remote_video_width;
+	video_conf.remote_video_height = remote_video_height;
+	video_conf.ref_active_camera = call->ep->conf.ref_active_camera;
+	video_conf.ref_camera_switch = call->ep->conf.ref_camera_switch;
+	video_conf.ref_camera_state = call->ep->conf.ref_camera_state;
+	video_conf.ref_window_state = call->ep->conf.ref_window_state;
+	video_conf.ref_active_img = call->ep->conf.ref_active_img;
+	video_conf.ref_Is_ActiveInspect = call->ep->conf.ref_Is_ActiveInspect;
+	video_conf.ref_Is_showPersonArea = call->ep->conf.ref_Is_showPersonArea;
+	video_conf.camera_count = call->ep->conf.camera_count;
+	video_conf.screen_count = call->ep->conf.screen_count;
+	video_conf.eDeviceType = call->eDeviceType;
+	video_conf.video_echo_cb = cb;
+	video_conf.ilocal_wind_flags = VIDEOPLAYER_FLAG_PULL|VIDEOPLAYER_FLAG_CHECKTOP;
+	video_conf.iremote_wind_flags = VIDEOPLAYER_FLAG_PUSH|VIDEOPLAYER_FLAG_CHECKTOP;
+	video_conf.eType = (eVideoRenderType)call->ep->conf.irendertype;
+	video_conf.ivideotype = call->ep->conf.icaptype;
+	rc = Local_video_session_create(&video_conf, &call->video, true);
+	if (rc != 0){
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video session failed! rc = %d", rc);
+		return -1;
+	}
+
+	rc = video_session_start(call->video);
+	if (rc != 0){
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video session failed! rc = %d", rc);
+		video_session_destroy(call->video);
+		call->video = NULL;
+		return -1;
+	}
+
+	return 0;
+}
+
+
+int local_play_stop_video(endpoint_call_t *call)
+{
+	if (call) {
+		media_desc_t video_desc = {0};
+		video_desc.media_dir = DIR_NONE;
+		endpoint_media_update_video(call, &video_desc,NULL);
+		return 0;
+	} else 
+	{
+		return Error_Param;
+	}
+}
+
+#endif
+
 static void __endpoint_call_destroy(endpoint_call_t *call)
 {
 	list_del(&call->entry);

+ 203 - 84
Module/mod_sipphone/unix/mod_sipphone.cpp

@@ -1,24 +1,22 @@
 #include "stdafx.h"
 
-#include "pthread.h"
 #include "mod_sipphone.h"
+#include "y2k_time.h"
 
 #include "../mod_agentip/sysvar.h"
 #include "../mod_facetracking/sysvar.h"
+#include "../mod_interactivecontrol/Event.h"
+#include "../mod_mediacontroller/Event.h"
 
 #include "sockutil.h"
 
 #include "rvc_media_common.h"
 
-#include "../mod_interactivecontrol/Event.h"
-#include "../mod_mediacontroller/Event.h"
+
 
 #include "audio_session.h"
 #include "video_session.h"
 
-
-//#include "volumekeeper.h"
-
 #define EVT_CONVERTER	"EventConverter"
 
 #define DEVICE_HANDFREE_OUT	0
@@ -38,7 +36,7 @@
 #define RVC_MIN_VIDEO_FRESH_TIME 1
 #endif // !RVC_MAX_VIDEO_FRESH_TIME
 
-extern BOOL g_IsExternalTerminalted;
+extern bool g_IsExternalTerminalted;
 
 static void __on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom, void *user_data)
 {
@@ -77,7 +75,7 @@ static int __hangup_call(void *user_data)
 
 static int __control_video(void *arg)
 {
-	ControlVideoCommand_t*pCmd = (ControlVideoCommand_t*)(arg);
+	ControlVideoCommand_t* pCmd = (ControlVideoCommand_t*)(arg);
 	pCmd->pSIPPhoneSession->control_video(pCmd);
 	delete pCmd;
 	return 0;
@@ -102,6 +100,23 @@ static int __release_call(void *user_data)
 }
 
 
+static void __audiomgrlog(void* user_data, const char* fmt, va_list arg)
+{
+	int n = vsnprintf(NULL, 0,fmt, arg);
+	if (n >= 512) {
+		char* buf = (char*)malloc((size_t)(n + 1));
+		vsnprintf(buf, n + 1, fmt, arg);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", buf);
+		free(buf);
+	}
+	else {
+		char strlog[512] = { 0 };
+		vsnprintf(strlog, 512, fmt, arg);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", strlog);
+	}
+}
+
+
 static void __video_render_log(render_loglevel elevel, void* user_data, const char* fmt, va_list arg)
 {
 	int n = vsnprintf(NULL, 0, fmt, arg);
@@ -153,14 +168,12 @@ static CSimpleStringA generateAudioInfoJson(const char* handfreeIn, const char*
 		handfreeIn, handfreeOut, pickupIn, pickupOut);
 }
 
-
 static CSimpleStringA generateVolumeJson(int ihandfreeIn, int ihandfreeOut, int ipickupIn, int ipickupOut)
 {
 	return CSimpleStringA::Format("{\"handfree_in_volume\":\"%d\",\"handfree_out_volume\":\"%d\",\"pickup_in_volume\":\"%d\",\"pickup_out_volume\":\"%d\"}",
 		ihandfreeIn, ihandfreeOut, ipickupIn, ipickupOut);
 }
 
-
 static CSimpleStringA generateAudioDspFlags(endpoint_audiodsp_config_t conf)
 {
 	int ipickup_in_agc = 0;
@@ -193,7 +206,16 @@ static CSimpleStringA generateAudioDspFlags(endpoint_audiodsp_config_t conf)
 		ihandfree_aec, ipickup_aec);
 }
 
+static int countnum(uint32_t unum)
+{
+	int icount = 0;
+	while (unum){
+		unum &= (unum - 1);
+		icount++;
+	}
 
+	return icount;
+}
 
 CSIPPhoneSession::CSIPPhoneSession(CSIPEntity* pEntity) : m_pEntity(pEntity), m_pCall(NULL), m_iLastState(0)
 {
@@ -217,16 +239,21 @@ CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhone
 	m_ilocalvideo_freshtime = RVC_VIDEO_FRESH_TIME;
 	m_iremotevideo_freshtime = RVC_VIDEO_FRESH_TIME;
 	m_render = NULL;
+	m_strStartTime = RVC_START_TIME;
+	m_strEndTime = RVC_END_TIME;
+	m_itervalTime = RVC_INTERVAL_TIME;
+	m_bStopAutoRestart = false;
 	m_iAudioDspUseCenter = 0;
 
 	m_nCallType = NORMAL_CALLTYPE;
 	memset(m_localip, 0, RVC_MAX_IP_LEN);
+	m_bFirstLaunched = false;
 }
 
 
 void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
-		const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, 
-		const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo)
+	const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, 
+	const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo)
 {
 	switch (dwUserCode)
 	{
@@ -236,6 +263,9 @@ void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const
 			if (m_pSipphoneChannel != NULL){
 				m_bConnectedAssist = false;
 				m_pSipphoneChannel->GetFunction()->CloseSession();
+#ifdef RVC_OS_WIN
+				m_pSipphoneChannel->SafeDelete();
+#endif
 				m_pSipphoneChannel = NULL;
 			}
 
@@ -294,7 +324,6 @@ void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const
 				// 话筒模式开始远程双录连线
 				m_iPickupPhoneState = ePickupMicrophoneState_On;
 			}
-
 			if (old_state != m_iPickupPhoneState) 
 			{
 				if (m_iPickupPhoneState == ePickupMicrophoneState_On) 
@@ -478,6 +507,16 @@ void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const ch
 			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
 		}
 	}
+	if (_stricmp(pszKey, "UIState") == 0)
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UIState %s -> %s.", pszOldValue, pszValue);
+		if (pszOldValue[0] == 'X' && pszValue[0] == 'M')
+		{
+			if (false == m_bFirstLaunched) {
+				m_bFirstLaunched = true;
+			}
+		}
+	}
 }
 
 	
@@ -497,8 +536,6 @@ void CSIPEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITr
 
 void CSIPEntity::OnStarted() 
 { 
-    LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTED, "sipphone entity started.");
-
 	ErrorCodeEnum Error = Error_Succeed;
 	m_pHMClient = new HealthManagerService_ClientBase(this);
 	Error = m_pHMClient->Connect();
@@ -522,46 +559,55 @@ void CSIPEntity::OnStarted()
 		LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
 	}
 
-	LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sip phone started successfully.");
-}
-
-static void __audiomgrlog(void* user_data, const char* fmt, va_list arg)
-{
-	int n = _vscprintf(fmt, arg);
-	if (n >= 512) {
-		char* buf = (char*)malloc((size_t)(n + 1));
-		vsnprintf(buf, n + 1, fmt, arg);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", buf);
-		free(buf);
-	}
-	else {
-		char strlog[512] = { 0 };
-		vsnprintf(strlog, 512, fmt, arg);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", strlog);
-	}
+	LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sipphone entity started successfully.");
+	LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTED, "sipphone entity started.");
 }
 
 
 ErrorCodeEnum CSIPEntity::LoadEntityConfig()
 {
 	SpIniMappingTable table;
+	int iTime = RVC_INTERVAL_TIME;
+	int iStopRestartFlag = 0;
+	CSimpleStringA strStartTime;
+	CSimpleStringA strEndTime;
 	int iAudioDspUseCenter = 0;
 
 	table.AddEntryInt("SipPhone", "AudioDspUseCenter", iAudioDspUseCenter, 0);
+	table.AddEntryInt("SipPhone", "ReStartInterVal", iTime, RVC_INTERVAL_TIME);
+	table.AddEntryInt("SipPhone", "StopAutoRestartFlag", iStopRestartFlag, 0);
+	table.AddEntryString("SipPhone", "StartTime", strStartTime, "$");
+	table.AddEntryString("SipPhone", "EndTime", strEndTime, "$");
+
 
 	CSmartPointer<IConfigInfo> spConfig;
 	ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
 	if (Error == Error_Succeed) {
 		Error = table.Load(spConfig);
-		if (Error_Succeed == Error) {
+		if (Error_Succeed == Error){
 			m_iAudioDspUseCenter = iAudioDspUseCenter;
+
+			if (iTime >= RVC_INTERVAL_TIME/3){
+				m_itervalTime = iTime;
+			}
+
+			if (1 == iStopRestartFlag){
+				m_bStopAutoRestart = true;
+			}
+
+			if (strStartTime.GetLength() > 1 && _stricmp(strStartTime.GetData(), RVC_START_TIME) >= 0) {
+				m_strStartTime = strStartTime;
+			}
+
+			if (strEndTime.GetLength() > 1 && _stricmp(strEndTime.GetData(), RVC_END_TIME) <= 0) {
+				m_strEndTime = strEndTime;
+			}
 		}
 	}
 
 	return Error;
 }
 
-
 ErrorCodeEnum CSIPEntity::ConnectAssistChannel()
 {
 	if (NULL == m_pSipphoneChannel) {
@@ -614,10 +660,77 @@ ErrorCodeEnum CSIPEntity::ConnectAssistChannel()
 }
 
 
+void CSIPEntity::HandleUSBAudioDeviceErrorEvent()
+{
+	struct tm* ptm = NULL;
+	time_t t = time(NULL);
+	ptm = localtime(&t);
+	char strNow[MAX_PATH] = { 0 };
+	char strTime[MAX_PATH] = { 0 };
+	_snprintf(strNow, MAX_PATH, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
+
+	unsigned int utime = y2k_time_now();
+	y2k_to_string(utime, strTime, MAX_PATH);
+	if (_stricmp(strNow, m_strStartTime.GetData()) < 0 || _stricmp(strNow, m_strEndTime.GetData()) >= 0) {
+		GetFunction()->SetTimer(RVC_ENTER_HOME_PAGE_TIMER, this, 1000);
+	}
+	else {
+		unsigned int ulasttime = 0;
+		LoadRestartRunConfig(ulasttime);
+		if (utime - ulasttime > m_itervalTime * 60) {
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_SIPPHONE_RETART_REQUEST, "请求重启机器");
+			if (Error_Succeed != SaveRestartRunConfig(utime)) {
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Save Run Config Restart time[%s] failed.", strTime);
+			}
+
+			LogEvent(Severity_High, EVENT_MOD_SIP_RESART, "LogEvent Restart Event!");
+		}
+	}
+}
+
+
+//载入运行时配置
+ErrorCodeEnum CSIPEntity::LoadRestartRunConfig(unsigned int& utime)
+{
+	CSmartPointer<IEntityFunction> spFunction = GetFunction();
+	CSmartPointer<IConfigInfo> spConfig;
+	ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
+	if (Error == Error_Succeed)
+	{
+		SpIniMappingTable table;
+		table.AddEntryUInt("AutoResart", "time", utime, 0);
+		Error = table.Load(spConfig);
+		if (Error != Error_Succeed){
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("failed to load run config.");
+		}
+	}
+	else{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("failed to open run config.");
+	}
+
+	return Error;
+}
+
+//保存运行时
+ErrorCodeEnum CSIPEntity::SaveRestartRunConfig(unsigned int utime)
+{
+	CSmartPointer<IEntityFunction> spFunction = GetFunction();;
+	CSmartPointer<IConfigInfo> spConfig;
+	ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
+	if (Error == Error_Succeed){
+		Error = spConfig->WriteConfigValueInt("AutoResart", "time", utime);
+	}
+	else{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("AutoResart is fail , open sipphone.ini fail!");
+	}
+
+	return Error;
+}
+
+
 ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 {
-	ErrorCodeEnum Error;
-	//MessageBoxA(0,0,0,0);
+	ErrorCodeEnum Error = Error_Succeed;
 	m_nCallType = NORMAL_CALLTYPE;
 	m_pSipphoneChannel = new ChannelSipphoneClient(this);
 
@@ -653,12 +766,31 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	Error = LoadConfig(&conf);
 	if (Error != Error_Succeed) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load config failed!");
-		return Error;
 	}
-
+	
 	if (IsPostAudioConfigInfo()) {
 		LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_INFO, generateAudioInfoJson(conf.audio_handfree_in_dev, conf.audio_handfree_out_dev, conf.audio_pickup_in_dev, conf.audio_pickup_out_dev).GetData());
 	}
+	else {
+		//有配置为空的,进关门页
+		return Error_Param;
+	}
+	
+	uint32_t uCheckRet = CheckAudioDevice();
+	if (RVC_AUDIO_NO_ERROR == uCheckRet) {
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("no audio device config error.");
+	}
+	else {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("error audio device number is %d.", countnum(uCheckRet));
+		if (countnum(uCheckRet) >= 3) {		//故障设备数大于3个或以上
+			return Error_Param;
+		}
+
+		if (uCheckRet = RVC_AUDIO_HANDFREEIN_ERROR | RVC_AUDIO_HANDFREEOUT_ERROR) {
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("can't find usb audio device.");
+			HandleUSBAudioDeviceErrorEvent();
+		}
+	}
 
 	int nhandfreeout = 0;
 	int npickupout = 0;
@@ -687,12 +819,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 #ifdef RVC_OS_LINUX
 	RvcSetSaveAudioVolume();
 #endif
-		
-	{
-		CSmartPointer<IEntityFunction> Func = GetFunction();
-		Func->GetSystemStaticInfo(staticInfo);
-	}
-	
 
 	{
 		CSmartPointer<IEntityFunction> Func = GetFunction();
@@ -819,48 +945,42 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		}
 	}
 
+	{
+		CSmartPointer<IEntityFunction> Func = GetFunction();
+		CSimpleStringA strValue("");
+		Func->RegistSysVarEvent("UIState", this);
+		Func->GetSysVar("UIState", strValue);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UIState %s.", strValue.GetData());
+	}
+
 #ifdef RVC_OS_WIN
 	if (m_kept_volume_in[DEV_HANDFREE]) {
 		m_pKeeperIn[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_in_dev, 1, m_kept_volume_in[DEV_HANDFREE]);
-		if (m_pKeeperIn[DEV_HANDFREE]) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HANDFREE in volume keeper create ok! %d", m_kept_volume_in[DEV_HANDFREE]);
-		} 
-		else {
+		if (!m_pKeeperIn[DEV_HANDFREE]) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE in volume keeper create failed!");
 		}
 	}
 
 	if (m_kept_volume_out[DEV_HANDFREE]) {
 		m_pKeeperOut[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_out_dev, 0, m_kept_volume_out[DEV_HANDFREE]);
-		if (m_pKeeperOut[DEV_HANDFREE]) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create ok! %d", m_kept_volume_out[DEV_HANDFREE]);
-		} 
-		else {
+		if (!m_pKeeperOut[DEV_HANDFREE]) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
 		}
 	}
 
 	if (m_kept_volume_in[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)){
 		m_pKeeperIn[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_in_dev, 1, m_kept_volume_in[DEV_PICKUP]);
-		if (m_pKeeperIn[DEV_PICKUP]) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("PICKUP in volume keeper create ok! %d", m_kept_volume_in[DEV_PICKUP]);
-		} 
-		else {
+		if (!m_pKeeperIn[DEV_PICKUP]) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP in volume keeper create failed!");
 		}
 	}
 
 	if (m_kept_volume_out[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)){
 		m_pKeeperOut[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_out_dev, 0, m_kept_volume_out[DEV_PICKUP]);
-		if (m_pKeeperOut[DEV_PICKUP]) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create ok! %d", m_kept_volume_out[DEV_PICKUP]);
-		} 
-		else {
+		if (!m_pKeeperOut[DEV_PICKUP]) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
 		}
 	}
-#else
-
 #endif // RVC_OS_WIN
 	return Error_Succeed;
 }
@@ -1096,6 +1216,7 @@ ErrorCodeEnum CSIPEntity::RvcGetAudioDeviceInfo()
 ErrorCodeEnum CSIPEntity::RvcSetSaveAudioVolume()
 {
 	ErrorCodeEnum Error = Error_Succeed;
+
 	if (m_pAudioMgr){
 		m_pAudioMgr->audio_set_device_volume(m_kept_volume_out[DEV_HANDFREE], conf.audio_handfree_out_dev, false);
 		m_pAudioMgr->audio_set_device_volume(m_kept_volume_in[DEV_HANDFREE], conf.audio_handfree_in_dev, true);
@@ -1502,7 +1623,8 @@ ErrorCodeEnum CSIPEntity::__OnClose(ErrorCodeEnum preOperationError)
 	Func->UnregistSysVarEvent(SYSVAR_AGENTCAMERASWITCH);
 	Func->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
 	Func->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
-		
+	Func->UnregistSysVarEvent("UIState");
+
 	for (i = 0; i < m_arrListener.GetCount(); ++i) {
 		Func->UnsubscribeLog(m_arrListener[i]);
 	}
@@ -1542,12 +1664,6 @@ void CSIPEntity::OnTimeout(DWORD dwTimerID)
 {
 	if (dwTimerID == 1)
 	{
-		//如果当前动态帧频不等于之前的帧频,发送当前帧频
-		//if (g_nDynamicFps != m_nDownDynamicFps)
-		//{
-		//	m_nDownDynamicFps = g_nDynamicFps;
-		//	SendDynamicFps(g_nDynamicFps);
-		//}
 		GetFunction()->KillTimer(1);
 		m_stVideoParam.nUpDynamicFps = -1;
 	}
@@ -1563,6 +1679,18 @@ void CSIPEntity::OnTimeout(DWORD dwTimerID)
 			GetFunction()->KillTimer(2);
 		}
 	}
+	else if (RVC_ENTER_HOME_PAGE_TIMER == dwTimerID) {
+		if (m_bFirstLaunched) {
+			Sleep(2000);
+			UIMessageBox evt;
+			evt.uboxtype = 2;
+			evt.strtitle = CSimpleStringA2W("声卡识别故障");
+			evt.strmessage = CSimpleStringA2W("识别不到USB声卡,请尝试重启机器解决,多次无效后请联系厂商处理");
+			SpSendBroadcast(GetFunction(), SP_MSG_OF(UIMessageBox), SP_MSG_SIG_OF(UIMessageBox), evt);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SpSendBroadcast UIMessageBox.");
+			GetFunction()->KillTimer(RVC_ENTER_HOME_PAGE_TIMER);
+		}
+	}
 }
 
 
@@ -2038,7 +2166,7 @@ void CSIPPhoneSession::Handle_ReleaseCall( SpReqAnsContext<PhoneService_ReleaseC
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	int rc = Error_Succeed;
-	g_IsExternalTerminalted = TRUE;
+	g_IsExternalTerminalted = true;
 	endpoint_invoke(m_pEntity->GetEndpoint(), &__release_call, this, &rc);
 	if (NULL != m_pEntity->m_pEndpoint){
 		endpoint_destroy(m_pEntity->m_pEndpoint);
@@ -2065,9 +2193,9 @@ void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_Start
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	int rc;
-	ControlVideoCommand_t *pCmd = new ControlVideoCommand_t();
+	ControlVideoCommand_t*pCmd = new ControlVideoCommand_t();
 	pCmd->pSIPPhoneSession = this;
-	pCmd->start = TRUE;
+	pCmd->start = true;
 	pCmd->local_hwd_move = 0;
 	pCmd->remote_hwd_move = 0;
 	pCmd->local_ip = inet_addr(m_pEntity->m_localip);
@@ -2098,7 +2226,7 @@ void CSIPPhoneSession::Handle_StopVideo( SpOnewayCallContext<PhoneService_StopVi
 	int rc;
 	ControlVideoCommand_t *pCmd = new ControlVideoCommand_t();
 	pCmd->pSIPPhoneSession = this;
-	pCmd->start = FALSE;
+	pCmd->start = false;
 	m_pEntity->GetFunction()->KillTimer(1);
 	if (NULL != m_pEntity->GetEndpoint()){
 		endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
@@ -2154,7 +2282,6 @@ void CSIPPhoneSession::Handle_GetHandfreeInVolume(SpReqAnsContext<PhoneService_G
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	ctx->Ans.Volume = m_pEntity->m_kept_volume_in[DEV_HANDFREE];
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get hand free in volume is %d.", ctx->Ans.Volume);
 	ctx->Answer(Error_Succeed);
 }
 
@@ -2198,7 +2325,6 @@ void CSIPPhoneSession::Handle_GetPickupInVolume(SpReqAnsContext<PhoneService_Get
 	else {
 		ctx->Ans.Volume = 0;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get pick up in volume is %d.", ctx->Ans.Volume);
 	ctx->Answer(Error_Succeed);
 }
 
@@ -2232,7 +2358,6 @@ void CSIPPhoneSession::Handle_GetHandfreeOutVolume(SpReqAnsContext<PhoneService_
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	ctx->Ans.Volume = m_pEntity->m_kept_volume_out[DEV_HANDFREE];
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get hand free out volume is %d.", ctx->Ans.Volume);
 	ctx->Answer(Error_Succeed);
 }
 
@@ -2263,7 +2388,6 @@ void CSIPPhoneSession::Handle_GetPickupOutVolume(SpReqAnsContext<PhoneService_Ge
 		ctx->Ans.Volume = 0;
 	}
 	
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get pickup out volume is %d.", ctx->Ans.Volume);
 	ctx->Answer(Error_Succeed);
 }
 
@@ -2350,14 +2474,13 @@ int CSIPPhoneSession::make_call( MakeCallCommand_t *pCmd)
 		m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), &t_callparam, &cb);
 		if (m_pCall) 
 		{
-			g_IsExternalTerminalted = FALSE;
+			g_IsExternalTerminalted = false;
 			if (endpoint_call_start(m_pCall) == 0) 
 			{
 				return Error_Succeed;
 			} 
 			else 
 			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start call failed! and endpoint destroy call.");
 				endpoint_call_destroy(m_pCall);
 				m_pCall = NULL;
 				return Error_Unexpect;
@@ -2365,8 +2488,7 @@ int CSIPPhoneSession::make_call( MakeCallCommand_t *pCmd)
 		} 
 		else 
 		{
-			g_IsExternalTerminalted = TRUE;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("g_IsExternalTerminalted = TRUE");
+			g_IsExternalTerminalted = true;
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create call endpoint failed!");
 			m_pEntity->m_SipErrorCode = Error_InvalidState;
 			m_pEntity->RealSelfCheck();			
@@ -2524,7 +2646,6 @@ int CSIPPhoneSession::on_video_box_move(int imessageType, int ivideotype, int il
 		evt.leftlowerx = ileft;
 		evt.leftlowery = ibottom;
 		iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStartMove), SP_MSG_SIG_OF(VideoBoxStartMove), evt);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("VideoBoxStartMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
 	}
 	else{
 		VideoBoxStopMove evt;
@@ -2532,7 +2653,6 @@ int CSIPPhoneSession::on_video_box_move(int imessageType, int ivideotype, int il
 		evt.leftlowerx = ileft;
 		evt.leftlowery = ibottom;
 		iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStopMove), SP_MSG_SIG_OF(VideoBoxStopMove), evt);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("VideoBoxStopMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
 	}
 
 	return iret;
@@ -2599,7 +2719,6 @@ void ChannelSipphoneClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packe
 	}
 }
 
-
 SP_BEGIN_ENTITY_MAP()
 	SP_ENTITY(CSIPEntity)
 SP_END_ENTITY_MAP()

+ 42 - 47
Module/mod_sipphone/unix/video_session.cpp

@@ -54,14 +54,9 @@ extern "C"
 #include "video_common/ffmpeg_api_cpp_adapter.h"
 
 
-BOOL g_bIsSalesRecord = FALSE;
-
 #define WNDCLS_NAME	"sipmedia_video"
 #define MAX_PATH_SIZE 256
 
-#define DEVICE_STANDARD_TYPE		0
-#define DEVICE_PAD_TYPE				1
-#define DEVICE_MOBILEPAD_TYPE		2
 
 #ifndef RVC_DBRECORD_VIDEO_BASE
 #define RVC_DBRECORD_VIDEO_BASE 1000
@@ -140,6 +135,8 @@ static bool __camera_error_event(bool bhaspost, int icameraid)
 		else{
 			LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_GET_OPT_VIDEO_FAILED, "get video from opt queue failed!");
 		}		
+		LogEvent(Severity_Middle, EVENT_MOD_SIP_GET_VIDEO_FAILED, "connected and get video failed!");
+
 		bret = true;
 	}
 	return bret;
@@ -952,9 +949,11 @@ static int start_local_video_clock(video_session_t* session)
 	else {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video clock failed!");
 	}
+
 	return rc;
 }
 
+
 static int start_video(video_session_t *session)
 {
 	int rc = -1;
@@ -966,6 +965,7 @@ static int start_video(video_session_t *session)
 			REC_COMMON_VIDEO_RTP_ENV_WIDTH, REC_COMMON_VIDEO_RTP_ENV_HEIGHT, PIX_FMT_YUV420P, 
 			SWS_POINT, NULL, NULL, NULL);
 		if (!session->local_encode_sws_ctx_env) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_env failed.");
 			goto on_error;
 		}
 	}
@@ -980,6 +980,7 @@ static int start_video(video_session_t *session)
 			REC_COMMON_VIDEO_RTP_WIDTH, REC_COMMON_VIDEO_RTP_HEIGHT, PIX_FMT_YUV420P, 
 			SWS_POINT, NULL, NULL, NULL);
 		if (!session->local_encode_sws_ctx_opt) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_opt failed.");
 			goto on_error;
 		}
 	}
@@ -1089,22 +1090,18 @@ static int start_video(video_session_t *session)
 		}
 	}
 
-	BOOL bIsActiveInspect = FALSE;
-	if (session->conf.ref_Is_ActiveInspect != NULL)
-	{
-		if (*session->conf.ref_Is_ActiveInspect == 1)
-		{
-			bIsActiveInspect = TRUE;
-		} 
-		else
-		{
+		BOOL bIsActiveInspect = FALSE;
+		if (session->conf.ref_Is_ActiveInspect != NULL){
+			if (*session->conf.ref_Is_ActiveInspect == 1){
+				bIsActiveInspect = TRUE;
+			} 
+			else{
+				bIsActiveInspect = FALSE;
+			}
+		}
+		else{
 			bIsActiveInspect = FALSE;
 		}
-	}
-	else
-	{
-		bIsActiveInspect = FALSE;
-	}
 
 	if (DOUBLERECORD_CALLTYPE != session->conf.nCallType){
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create new local video player");
@@ -1480,7 +1477,6 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 	case WM_LBUTTONDBLCLK:
 	case WM_LBUTTONDOWN:
 	case WM_LBUTTONUP:
-		OutputDebugStringA("mouse clicked!");
 		if (session) {
 			if (session->local_hwnd) {
 				//ReleaseCapture();
@@ -1498,20 +1494,21 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 		break;
 
 	case WM_ENTERSIZEMOVE:
-	{
-		HandleVideoMoveEvent(0, hWnd, session);
-	}
-	break;
+		{
+			HandleVideoMoveEvent(0, hWnd, session);
+		}
+		break;
 
 	case WM_EXITSIZEMOVE:
-	{
-		HandleVideoMoveEvent(1, hWnd, session);
-	}
-	break;
+		{
+			HandleVideoMoveEvent(1, hWnd, session);
+		}
+		break;
 
 	default:
 		return DefWindowProc(hWnd, msg, wParam, lParam);
 	}
+	return 0;
 }
 
 #endif // 
@@ -1539,7 +1536,7 @@ static unsigned int __stdcall ui_proc(void *arg)
 		//SetWindowLongPtrA(session->local_hwnd, GWLP_USERDATA, (LONG_PTR)session);
 		breuse_local_wnd = true;
 	}
-	else{		
+	else{
 		if (0 != session->conf.local_move){
 			dLocal_style -= WS_EX_NOACTIVATE;
 		}
@@ -1575,6 +1572,13 @@ static unsigned int __stdcall ui_proc(void *arg)
 				SetWindowPos(session->local_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
 			}
 			pg_local_hwnd = session->local_hwnd;
+			//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_WINDOW_CREATE_SUCCESS, "create local window success and restore local video hwnd.");
+		}
+		else{
+			char strinfo[MAX_PATH] = {0};
+			_snprintf(strinfo, MAX_PATH, "%s%d", "create local window failed and last error is ", GetLastError());
+			LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_LOCAL_WINDOW_CREATE_FAILED, strinfo);
+			//return -1;
 		}
 	}
 
@@ -1583,7 +1587,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 	{
 		if (NULL != pg_remote_hwnd){
 			session->remote_hwnd = pg_remote_hwnd;
-			//SetWindowLongPtrA(session->remote_hwnd, GWLP_USERDATA, (LONG_PTR)session);
 			breuse_remote_wnd = true;
 			if (NULL != pg_last_session){
 				record_agent_picture_show_session_destory(pg_last_session);
@@ -1600,6 +1603,13 @@ static unsigned int __stdcall ui_proc(void *arg)
 					SetWindowPos(session->remote_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
 				}
 				pg_remote_hwnd = session->remote_hwnd;
+				//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_WINDOW_CREATE_SUCCESS, "create remote window success and restore remote video hwnd.");
+			}
+			else{
+				char strinfo[MAX_PATH] = {0};
+				_snprintf(strinfo, MAX_PATH, "%s%d", "create remote window failed and last error is ", GetLastError());
+				LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_REMOTE_WINDOW_CREATE_FAILED, strinfo);
+				//return -1;
 			}
 		}
 	}
@@ -1616,9 +1626,8 @@ static unsigned int __stdcall ui_proc(void *arg)
 
 		SetEvent(session->ui_event);
 		rc = start_video(session);
-		if (rc != 0) 
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video failed!");
+		if (rc != 0) {
+			LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_START_VIDEO_FAILED, "start video failed!");
 		} 
 
 		if (!breuse_local_wnd && !breuse_remote_wnd)
@@ -1911,20 +1920,6 @@ void av_log_cb(void*ptr, int level, const char*fmt, va_list list)
 int video_lib_init()
 {
 #ifdef RVC_OS_WIN
-	CoInitialize(NULL);
-	{
-		int i, n;
-
-		n = videocap_get_device_count();
-		for (i = 0; i < n; ++i) {
-			WCHAR tmp[128];
-			char t[128];
-			videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-			WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", i, t);
-		}
-	}
-
 	videoframework_init();
 
 	av_log_set_callback(&av_log_cb);

+ 9 - 0
Module/mod_sipphone/video_render.h

@@ -1,7 +1,12 @@
 #pragma once
 
 #include "ivideorenderinterface.h"
+#ifdef _WIN32
+#else
 #include<semaphore.h>
+#endif // _WIN32
+
+
 
 #ifndef MAX_PATH
 #define MAX_PATH 260
@@ -44,10 +49,14 @@ typedef struct rvc_video_render_params_s {
 typedef struct rvc_video_render_s {
 	IVideoRender* plocal_render;
 	IVideoRender* premote_render;
+#ifdef _WIN32
+
+#else
 	pthread_t ui_threadid;
 	sem_t ui_stop_sem;
 	pthread_t remote_render_threadid;
 	sem_t remote_render_stop_sem;
+#endif
 	rvc_video_render_params_t location_param;
 	rvc_video_render_window_type_callback_t cb;
 }rvc_video_render_t;

+ 0 - 9
Module/mod_sipphone/win/audio_session.cpp

@@ -386,15 +386,6 @@ static int phonemedia_start(audio_session_t *session)
 		if (conf->remote_ptime == 0)
 			conf->remote_ptime = 20;
 		break;
-#if 0
-	case 4:
-		codec = "G723";
-		if (conf->local_ptime == 0)
-			conf->local_ptime = 30;
-		if (conf->remote_ptime == 0)
-			conf->remote_ptime = 30;
-		break;
-#endif
 	case 8: 
 		codec = "PCMA";
 		if (conf->local_ptime == 0)

+ 88 - 24
Module/mod_sipphone/win/endpoint.cpp

@@ -1,6 +1,13 @@
+#include "SpBase.h"
+#ifdef RVC_OS_WIN
 #include "stdafx.h"
-#include "endpoint.h"
 #include <ObjBase.h>
+#else
+
+#endif
+
+#include "endpoint.h"
+
 #include <sofia-sip/su.h>
 #include <sofia-sip/su_tag_class.h>
 #include <sofia-sip/nua.h>
@@ -19,7 +26,7 @@
 #include "sockutil.h"
 #include "hash.h"
 
-#include "SpBase.h"
+
 
 #include "video_session.h"
 #include "audio_session.h"
@@ -284,8 +291,6 @@ static void endpoint_media_update_video(endpoint_call_t *call, media_desc_t *vid
 		video_conf.ref_camera_state = call->ep->conf.ref_camera_state;
 		video_conf.ref_window_state = call->ep->conf.ref_window_state;
 		video_conf.ref_Is_showPersonArea = call->ep->conf.ref_Is_showPersonArea;
-		//video_conf.ref_active_img = call->ep->conf.ref_active_img;
-		//video_conf.ref_Is_ActiveInspect = call->ep->conf.ref_Is_ActiveInspect;
 		video_conf.ref_active_img = NULL;
 		video_conf.ref_Is_ActiveInspect = NULL;
 		video_conf.camera_count = call->ep->conf.camera_count;
@@ -301,9 +306,6 @@ static void endpoint_media_update_video(endpoint_call_t *call, media_desc_t *vid
 		video_conf.eType = (eVideoRenderType)call->ep->conf.irendertype;
 		video_conf.ivideotype = call->ep->conf.icaptype;
 
-		//huchen modify, now we use standard h264
-		//video_conf.local_pt = REC_COMMON_VIDEO_PT;
-		//video_conf.remote_pt = REC_COMMON_VIDEO_PT;
 		video_conf.local_pt = REC_COMMON_VIDEO_H264_PT;
 		video_conf.remote_pt = REC_COMMON_VIDEO_H264_PT;
 		
@@ -911,7 +913,7 @@ static void on_state(CONDITION_PARAMS)
 
 }
 
-void Terminatedcall(endpoint_call_t *call)
+void terminatedcall(endpoint_call_t *call)
 {
 	int st = TERMINATED;
 	g_IsExternalTerminalted = true;
@@ -1007,18 +1009,28 @@ static void endpoint_callback(nua_event_t   event,
 
 }
 
-static unsigned int __stdcall __event_thread(void *arg)
+#ifdef RVC_OS_WIN
+static unsigned int __stdcall __event_thread(void* arg)
+#else
+void* __event_thread(void* arg)
+#endif
 {
 	endpoint_t *ep = (endpoint_t *)arg;
 	ep->entity->GetFunction()->InitLogCurrentThread();
 
+#ifdef RVC_OS_WIN
 	CoInitialize(NULL);
+#else
+
+#endif // RVC_OS_WIN
+
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("enter event_thread.");
 
 	ep->root = su_root_create(ep);
-	
-	ep->nua = nua_create(ep->root, 
-		&endpoint_callback, 
-		ep, 
+
+	ep->nua = nua_create(ep->root,
+		&endpoint_callback,
+		ep,
 		NUTAG_URL(ep->conf.uri),
 		TAG_END());
 
@@ -1039,21 +1051,33 @@ static unsigned int __stdcall __event_thread(void *arg)
 	su_root_destroy(ep->root);
 	ep->root = NULL;
 
+#ifdef RVC_OS_WIN
 	CoUninitialize();
-
+#else
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("leave event_thread.");
+#endif // RVC_OS_WIN
 	return 0;
 }
 
 static int __endpoint_break(void *arg)
 {
 	endpoint_t *ep = (endpoint_t *)arg;
-
 	//.....nua_shutdown
 	su_root_break(ep->root);
 
 	return 0;
 }
 
+#ifdef RVC_OS_WIN
+#else
+unsigned long GetTickCount()
+{
+	struct timespec ts;
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
+}
+#endif
+
 static endpoint_t *__endpoint_create(CEntityBase *pEntity, const endpoint_conf_t *conf,int nDev)
 {
 	endpoint_t *ep;
@@ -1083,13 +1107,14 @@ static void __endpoint_destroy(endpoint_t *ep)
 
 static int __endpoint_start(endpoint_t *ep)
 {
+#ifdef RVC_OS_WIN
 	ep->event_thread = (HANDLE)_beginthreadex(NULL, 0, &__event_thread, ep, 0, NULL);
-	if (ep->event_thread) 
+	if (ep->event_thread)
 	{
-		while (!ep->root) 
+		while (!ep->root)
 		{
 			DWORD dwRet = WaitForSingleObject(ep->event_thread, 1);
-			if (dwRet == WAIT_OBJECT_0) 
+			if (dwRet == WAIT_OBJECT_0)
 			{
 				CloseHandle(ep->event_thread);
 				ep->event_thread = NULL;
@@ -1098,11 +1123,37 @@ static int __endpoint_start(endpoint_t *ep)
 		}
 	}
 	return ep->event_thread ? 0 : -1;
+#else
+	//pthread_attr_t attr;
+	//pthread_attr_init(&attr);
+	//pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	int err = pthread_create(&ep->ievent_threadid, NULL, __event_thread, ep);
+	//pthread_attr_destroy(&attr);
+	if (0 == err) {
+		while (!ep->root) {
+			struct timespec ts; 
+			clock_gettime(CLOCK_REALTIME, &ts);
+			long unsec = ts.tv_nsec + (1000 * 1000);
+			ts.tv_sec += (unsec / 1000000000);
+			ts.tv_nsec = (unsec % 1000000000);
+			if (0 == pthread_timedjoin_np(ep->ievent_threadid, NULL, &ts)) {
+				ep->ievent_threadid = 0;
+				break;
+			}
+		}
+	}
+	else {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create event thread failed.");
+	}
+
+	return ep->ievent_threadid > 0 ? 0 : -1;
+#endif
 }
 
 static void __endpoint_stop(endpoint_t *ep)
 {
-	if (ep->event_thread) 
+#ifdef RVC_OS_WIN
+	if (ep->event_thread)
 	{
 		int rc;
 		su_task_execute(su_root_task(ep->root), &__endpoint_break, ep, &rc);
@@ -1110,9 +1161,21 @@ static void __endpoint_stop(endpoint_t *ep)
 		CloseHandle(ep->event_thread);
 		ep->event_thread = NULL;
 	}
+#else
+	if (ep->ievent_threadid > 0)
+	{
+		int rc;
+		su_task_execute(su_root_task(ep->root), &__endpoint_break, ep, &rc);
+		if (0 == pthread_join(ep->ievent_threadid, NULL)) {
+			ep->ievent_threadid = 0;
+		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pthread join error for %s", strerror(errno));
+		}
+	}
+#endif
 }
 
-
 static void rvc_sofia_logger(void* stream, char const* fmt, va_list ap) {
 	if (!fmt)
 		return;
@@ -1134,8 +1197,6 @@ void endpoint_deinit_lib()
 	su_deinit();
 }
 
-
-
 endpoint_t *endpoint_create(CEntityBase *pEntity, const endpoint_conf_t *conf,int nDev)
 {
 	endpoint_t *endpt;
@@ -1245,7 +1306,6 @@ on_error:
 	return call;
 }
 
-
 void endpoint_call_destroy(endpoint_call_t *call)
 {
 	endpoint_call_dec_ref(call);
@@ -1390,6 +1450,8 @@ int endpoint_call_stop_video(endpoint_call_t *call)
 }
 
 
+#ifdef RVC_OS_WIN
+
 int endpoint_call_stop_double_record_broadcast_video()
 {
 	double_record_broadcast_video_session_stop();
@@ -1542,6 +1604,8 @@ int local_play_stop_video(endpoint_call_t *call)
 	}
 }
 
+#endif
+
 static void __endpoint_call_destroy(endpoint_call_t *call)
 {
 	list_del(&call->entry);
@@ -1552,7 +1616,7 @@ static void __endpoint_call_destroy(endpoint_call_t *call)
 }
 
 
-int translate_ipaddr_from_int(char* strdst, size_t ulen, unsigned long uip)
+int translate_ipaddr_from_int(char* strdst, unsigned ulen, unsigned long uip)
 {
 	int iret = -1;
 	if (NULL == strdst){

+ 42 - 55
Module/mod_sipphone/win/mod_sipphone.cpp

@@ -1,23 +1,21 @@
 #include "stdafx.h"
 
-//#include "pthread.h"
-#include "endpoint.h"
 #include "mod_sipphone.h"
 #include "y2k_time.h"
 
-#include "mod_agentip/sysvar.h"
-#include "mod_facetracking/sysvar.h"
-#include "mod_interactivecontrol/Event.h"
+#include "../mod_agentip/sysvar.h"
+#include "../mod_facetracking/sysvar.h"
+#include "../mod_interactivecontrol/Event.h"
 #include "../mod_mediacontroller/Event.h"
 
 #include "sockutil.h"
 
-#include "media_config_const.h"
+#include "rvc_media_common.h"
 
 #include "audio_session.h"
 #include "video_session.h"
 
-#include "EventCode.h"
+//#include "EventCode.h"
 
 #define EVT_CONVERTER	"EventConverter"
 
@@ -26,16 +24,17 @@
 #define DEVICE_HANDFREE_IN	2
 #define DEVICE_PICKUP_IN	3
 
-#ifndef RVC_MAX_TRY_COUNT
-#define RVC_MAX_TRY_COUNT 1
-#endif
+#ifndef RVC_VIDEO_FRESH_TIME
+#define RVC_VIDEO_FRESH_TIME 50
+#endif // !RVC_VIDEO_FRESH_TIME
+
+#ifndef RVC_MAX_VIDEO_FRESH_TIME
+#define RVC_MAX_VIDEO_FRESH_TIME 200
+#endif // !RVC_MAX_VIDEO_FRESH_TIME
 
-/////////////////////////////////////////////
-// future roadmap
-// 1. 使用session timer
-// 2. 增强稳定性
-// 3. 健康检查里面触发 主备服务器切换(switch between freeswitchs) 定时发送options ping switch server
-/////////////////////////////////////////////
+#ifndef RVC_MIN_VIDEO_FRESH_TIME
+#define RVC_MIN_VIDEO_FRESH_TIME 1
+#endif // !RVC_MAX_VIDEO_FRESH_TIME
 
 extern bool g_IsExternalTerminalted;
 
@@ -307,7 +306,7 @@ void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const
 		{
 			m_stVideoParam.bActiveInspect = 0;
 			m_stVideoParam.bShowActiveImg = 0;
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
 		}
 		break;
 
@@ -374,18 +373,6 @@ void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const
 		}
 		break;
 
-	case EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST:
-		{
-
-		}
-		break;
-
-	case EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL:
-		{
-
-		}
-		break;
-
 	default:
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown dwUserCode = 0x%08x.",dwUserCode);
@@ -401,21 +388,21 @@ void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const ch
 	{
 		if (pszValue[0] == 'E')
 		{
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
 		}
 		else if (pszValue[0] == 'O')
 		{
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
 		}
 		else if(pszValue[0] == 'B')   ///////显示贴图
 		{
 			/////////////////////////此处显示贴图//////////////////////////////////
 			//m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_ERROR;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
 		}
 		else if (pszValue[0] == 'N')
 		{
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_AUTO;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
 			//m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
 		}
 	}
@@ -423,11 +410,11 @@ void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const ch
 	{
 		if (pszValue[0] == 'E') 
 		{
-			m_stVideoParam.iActiveCamera = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
 		} 
 		else if (pszValue[0] == 'O') 
 		{
-			m_stVideoParam.iActiveCamera = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
 		} 
 		else 
 		{
@@ -438,15 +425,15 @@ void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const ch
 	{
 		if(pszValue[0] == 'E')
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
 		} 
 		else if(pszValue[0] == 'O')
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
 		}
 		else if(pszValue[0] == 'A')
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_AUTO;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
 		}
 	}
 	if (_stricmp(pszKey, "UIState") == 0)
@@ -895,11 +882,11 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		Func->GetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, strValue);
 		if (strValue[0] == 'E') 
 		{
-			m_stVideoParam.iActiveCamera = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
 		} 
 		else if (strValue[0] == 'O') 
 		{
-			m_stVideoParam.iActiveCamera = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
 		} 
 		else 
 		{
@@ -914,22 +901,22 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		Func->GetSysVar(SYSVAR_CAMERASTATE, strValue);
 		if (strValue[0] == 'E')
 		{
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
 		}
 		else if (strValue[0] == 'O')
 		{
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
 		}
 		else if(strValue[0] == 'B')   ///////显示贴图
 		{
-			/////////////////////////此处显示贴图//////////////////////////////////
-			//m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_ERROR;
+				/////////////////////////此处显示贴图//////////////////////////////////
+				//m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
+				m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
 		}
 		else if (strValue[0] == 'N')
 		{
 			//m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
-			m_stVideoParam.iCameraState = MEDIA_CONFIG_CAMERA_TYPE_AUTO;
+			m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
 		}
 	}
 
@@ -940,15 +927,15 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		Func->GetSysVar(SYSVAR_AGENTCAMERASWITCH, strValue);
 		if((strValue[0] == 'E'))
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_ENV;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
 		} 
 		else if((strValue[0] == 'O'))
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_OPT;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
 		}
 		else if ((strValue[0] == 'A'))
 		{
-			m_stVideoParam.iCameraSwitch = MEDIA_CONFIG_CAMERA_TYPE_AUTO;
+			m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
 		}
 	}
 
@@ -1568,8 +1555,8 @@ ErrorCodeEnum CSIPEntity::InitEndpoint()
 	if (strUri.GetLength() > 0) 
 	{
 		strcpy(conf.uri, strUri);
-		conf.media_start_port = MEDIA_CONFIG_AUDIO_PORT_START;
-		conf.media_stop_port = MEDIA_CONFIG_AUDIO_PORT_STOP;
+		conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
+		conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
 		m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
 		if (!m_pEndpoint) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
@@ -1944,8 +1931,8 @@ void CSIPPhoneSession::Handle_MakeCall( SpReqAnsContext<PhoneService_MakeCall_Re
 	if (strUri.GetLength() > 0) 
 	{
 		strcpy(m_pEntity->conf.uri, strUri);
-		m_pEntity->conf.media_start_port = MEDIA_CONFIG_AUDIO_PORT_START;
-		m_pEntity->conf.media_stop_port = MEDIA_CONFIG_AUDIO_PORT_STOP;
+		m_pEntity->conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
+		m_pEntity->conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
 		m_pEntity->m_pEndpoint = endpoint_create(m_pEntity, &m_pEntity->conf,m_pEntity->m_iPickupPhoneState);
 		if (!m_pEntity->m_pEndpoint){
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
@@ -2039,7 +2026,7 @@ void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_Start
 		}
 	}
 	pCmd->local_ip = inet_addr(m_pEntity->m_localip);
-	pCmd->local_port = MEDIA_CONFIG_VIDEO_PORT;
+	pCmd->local_port = REC_COMMON_VIDEO_PORT;
 	pCmd->remote_ip = inet_addr(ctx->Info.remote_ip);
 	pCmd->remote_port = ctx->Info.remote_port;
 	pCmd->local_view_x = ctx->Info.local_view_x;
@@ -2237,7 +2224,7 @@ void CSIPPhoneSession::hangup_call(HangupCallCommand_t* cmd)
 void CSIPPhoneSession::release_call()
 {
 	if (m_pCall){
-		Terminatedcall(m_pCall);
+		terminatedcall(m_pCall);
 	}
 }
 

+ 6 - 14
Module/mod_sipphone/win/video_session.cpp

@@ -42,8 +42,6 @@ extern "C"{
 #pragma comment(lib, "dbghelp.lib")
 
 
-BOOL g_bIsSalesRecord = FALSE;
-
 HWND pg_local_hwnd = NULL;						// preview window
 HWND pg_remote_hwnd = NULL;						// remote window
 
@@ -58,14 +56,10 @@ video_session_t* pg_last_session = NULL;		// last used session
 #define MAX_PATH 260
 #endif
 
-#define DEVICE_STANDARD_TYPE		0
-#define DEVICE_PAD_TYPE				1
-#define DEVICE_MOBILEPAD_TYPE		2
-
 
 static void __dbg(void *user_data, const char *fmt, va_list arg)
 {
-	int n = _vscprintf(fmt, arg);
+	int n = _vsnprintf(NULL, 0, fmt, arg);
 	if (n >= MAX_LOG_LEN) {
 		char* buf = (char*)malloc((size_t)(n + 1));
 		_vsnprintf(buf, n + 1, fmt, arg);
@@ -118,10 +112,10 @@ static int translate_image_resolution(video_frame** dstframe,const int iwidth, c
 	video_frame* pframe = video_frame_new(iwidth, iheight,VIDEO_FORMAT_RGB24);
 	video_frame_fill_black(pframe);
 
-	SwsContext*sws = sws_getCachedContext(NULL,	psrcframe->width, psrcframe->height, 
+	SwsContext* sws = sws_getCachedContext(NULL, psrcframe->width, psrcframe->height,
 		PIX_FMT_BGR24,
 		iwidth,
-		iheight, 
+		iheight,
 		PIX_FMT_BGR24,
 		SWS_LANCZOS,
 		NULL,
@@ -169,11 +163,12 @@ static int calc_capture_mode(int width, int height, int *mode)
 	return Error_NotExist;
 }
 
+#ifdef RVC_OS_WIN
 static void __delete_frame(videoplayer_t *player, void *user_data, video_frame *frame)
 {
 	video_frame_delete(frame);
 }
-
+#endif
 
 static int video_shm_enqueue(Clibvideoqueue *shm_queue, video_frame *frame, int flags, int iframeid)
 {
@@ -187,7 +182,7 @@ static int video_shm_enqueue(Clibvideoqueue *shm_queue, video_frame *frame, int
 	unsigned int nowtime = y2k_time_now();
 	if (!shm_queue->InsertVideo(&tmp_frm, flags,nowtime)) 
 	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("caution: insert shm video failed!");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("caution: shm_queue video insert shm video failed!");
 		return Error_Unexpect;
 	} 
 	else 
@@ -196,7 +191,6 @@ static int video_shm_enqueue(Clibvideoqueue *shm_queue, video_frame *frame, int
 	}
 }
 
-
 static inline Clibvideoqueue *get_active_videoqueue(video_session_t *session)
 {
 	int agent_option = *session->conf.ref_camera_switch;
@@ -1505,9 +1499,7 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 		stop_video(session);
 		//SetEvent(session->ui_thread);	
 		DestroyWindow(session->local_hwnd);
-		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_WINDOW_DESTROY_SUCCESS, "destroy local window.");
 		DestroyWindow(session->remote_hwnd);
-		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_WINDOW_DESTROY_SUCCESS, "destroy remote window.");
 		return 0;
 	case WM_MOVE:
 		break;

+ 1 - 1
Module/mod_snapshot/CMakeLists.txt

@@ -22,7 +22,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libfacecapture
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libbizchan
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 )
 
 

+ 0 - 0
Other/unix/rvcmediacommon/common_video/videocommon.h → Other/rvcmediacommon/common_video/videocommon.h


+ 0 - 0
Other/unix/rvcmediacommon/rvc_media_common.h → Other/rvcmediacommon/rvc_media_common.h


+ 1 - 1
Other/unix/libvideocapture/CMakeLists.txt

@@ -25,7 +25,7 @@ add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
 message(STATUS "CONAN_INCLUDE_DIRS_LIBYUV = ${CONAN_INCLUDE_DIRS_LIBYUV}")
 target_include_directories(${MODULE_NAME} PRIVATE
 	${CMAKE_CURRENT_SOURCE_DIR}
-	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
+	${OTHER_LIB_BASE_DIR}/rvcmediacommon
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libvideoframework
 	${CONAN_INCLUDE_DIRS_FFMPEG}
 	${CONAN_INCLUDE_DIRS_LIBYUV}

+ 1 - 1
Other/unix/libvideoframework/videortp.c

@@ -19,7 +19,7 @@
 #include "rtp.h"
 #include "rtpsession.h"
 #include "memutil.h"
-#include "../rvcmediacommon/rvc_media_common.h"
+#include "../../rvcmediacommon/rvc_media_common.h"
 #include "x264.h"
 
 #include "video_common/ffmpeg_api_adapter.h"

+ 1 - 1
Other/win/libaudiorender/libaudiorender.cpp

@@ -5,7 +5,7 @@
 #define _CRT_SECURE_NO_WARNINGS
 
 #include "libaudiorender.h"
-#include "../rvcmediacommon/rvc_media_common.h"
+#include "../../rvcmediacommon/rvc_media_common.h"
 
 
 #ifndef RVC_AUDIO_FRAME_SIZE

+ 1 - 1
Other/win/libvideoframework/videortp.c

@@ -19,7 +19,7 @@
 #include "rtp.h"
 #include "rtpsession.h"
 #include "memutil.h"
-#include "../rvcmediacommon/rvc_media_common.h"
+#include "../../rvcmediacommon/rvc_media_common.h"
 #include "x264.h"
 
 #include "video_common/ffmpeg_api_adapter.h"

+ 0 - 21
Other/win/rvcmediacommon/common_video/videocommon.h

@@ -1,21 +0,0 @@
-#pragma once
-
-// Supported video types.
-enum VideoType {
-	kUnknown,
-	kI420,
-	kIYUV,
-	kRGB24,
-	kABGR,
-	kARGB,
-	kARGB4444,
-	kRGB565,
-	kARGB1555,
-	kYUY2,
-	kYV12,
-	kUYVY,
-	kMJPEG,
-	kNV21,
-	kNV12,
-	kBGRA,
-};

+ 0 - 98
Other/win/rvcmediacommon/rvc_media_common.h

@@ -1,98 +0,0 @@
-#pragma once
-
-// video codec: h264, audio codec: G729a 
-
-// video size of single screen: 320x240(remote), 320x240(local)
-// video size of dual screen:	640x480(remote), 320x240(local) 双屏双摄像头通知周小斌,改回320x240
-
-#define REC_COMMON_AUDIO_FRAME_PTIME	100
-#define REC_COMMON_AUDIO_FRAME_PSIZE	165
-
-#define REC_COMMON_AUDIO_CLOCK	8000
-#define REC_COMMON_VIDEO_CLOCK	90000
-
-#define REC_COMMON_VIDEO_FPS_DEN	1
-#define REC_COMMON_VIDEO_FPS_NUM	10			//8
-#define REC_COMMON_VIDEO_FPS_MOBILE 8           //5   //移动版视频5帧/s
-#define REC_COMMON_VIDEO_FPS_MOBILE_AGENT 8 	//2  //移动版坐席视频2帧/s
-#define REC_COMMON_VIDEO_FPS		10.0f		//8.0f
-#define REC_COMMON_VIDEO_RAW_FPS	15.0f		//8.0f
-#define REC_COMMON_VIDEO_PADRAW_FPS	10.0f	
-
-#define REC_COMMON_VIDEO_RAW_FPS_DEN	1
-#define REC_COMMON_VIDEO_RAW_FPS_NUM	8
-#define REC_COMMON_VIDEO_SNAPSHOT_FPS	1.0f
-#define REC_COMMON_VIDEO_CAPTURE_FRAME_INTERVAL	8
-#define REC_COMMON_VIDEO_ENCODE_FRAME_INTERVAL	1
-
-#define REC_COMMON_AUDIO_PT		18 // g729
-#define REC_COMMON_VIDEO_PT     101 // H264+
-#define REC_COMMON_VIDEO_H264_PT   97  // H264
-
-#define REC_COMMON_JITTER_MIN_CACHE_MSEC	1000
-#define REC_COMMON_JITTER_MAX_CACHE_MSEC	2000
-
-#define REC_COMMON_VIDEO_RTP_ENV_WIDTH	320	
-#define REC_COMMON_VIDEO_RTP_ENV_HEIGHT	180
-#define REC_COMMON_VIDEO_RTP_OPT_WIDTH	180
-#define REC_COMMON_VIDEO_RTP_OPT_HEIGHT	320
-
-#define REC_COMMON_VIDEO_RTP_EWS_WIDTH	320	
-#define REC_COMMON_VIDEO_RTP_EWS_HEIGHT	180
-
-#define REC_COMMON_VIDEO_PREVIEW_WIDTH	320
-#define REC_COMMON_VIDEO_PREVIEW_HEIGHT	240
-
-#define REC_COMMON_VIDEO_RTP_WIDTH			320
-#define REC_COMMON_VIDEO_RTP_HEIGHT			320
-#define REC_COMMON_VIDEO_RTP_PADDING		70
-
-#define REC_COMMON_VIDEO_SNAPSHOT_WIDTH		640
-#define REC_COMMON_VIDEO_SNAPSHOT_HEIGHT	360
-#define REC_COMMON_VIDEO_SNAPSHOT_PREVIEW_WIDTH		480
-#define REC_COMMON_VIDEO_SNAPSHOT_PREVIEW_HEIGHT	360
-
-#define REC_COMMON_VIDEO_AGENT_RAW_WIDTH	1280
-#define REC_COMMON_VIDEO_AGENT_RAW_HEIGHT	720
-
-#define REC_COMMON_VIDEO_AGENT_PREVIEW_WIDTH	320
-#define REC_COMMON_VIDEO_AGENT_PREVIEW_HEIGHT	320
-
-#define REC_COMMON_VIDEO_SSM_AGENT_WIDTH	320	// single screen mode(ssm)
-#define REC_COMMON_VIDEO_SSM_AGENT_HEIGHT	240
-#define REC_COMMON_VIDEO_DSM_AGENT_WIDTH	640	// dual screen mode(dsm)
-#define REC_COMMON_VIDEO_DSM_AGENT_HEIGHT	480
-
-#define REC_COMMON_AUDIO_PORT_START			40000
-#define REC_COMMON_AUDIO_PORT_STOP			50000
-#define REC_COMMON_VIDEO_PORT				30000
-
-#define CAMERA_TYPE_ERROR -1
-#define CAMERA_TYPE_ENV	0
-#define CAMERA_TYPE_OPT	1
-#define CAMERA_TYPE_AUTO 2
-#define CAMERA_TYPE_EWS 3
-
-#define REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE		"944209D5-F4D2-4EB8-9CE8-0A18828E30BF"  //"rvc.shm.snapshot.video.env.q"	    // 640x360@1fps BGR24
-#define REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE			"93CB53EE-BFCE-468B-9718-13A936568E8E"	//"rvc.shm.rtp.video.env.q"				// 320x180@8fps BGR24
-#define REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE		"D8B048E0-84DB-42C3-BB88-F1D15BE4AFD0"	//"rvc.shm.preview.video.env.q"			// 320x240@8fps BGR24
-
-#define REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE		"87691C06-921D-4EED-8503-AC3DDB7AD134"  //"rvc.shm.snapshot.video.opt.q"	    // 360x640@1fps BGR24
-#define REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE			"A4995E16-6CF4-437B-A864-728EA1569AAF"  //"rvc.shm.rtp.video.opt.q"				// 180x320@8fps BGR24
-#define REC_COMMON_VIDEO_OPT_SHM_PREVIEW_QUEUE		"2D60200E-4B69-406C-8173-D92EBE679471"  //"rvc.shm.preview.video.opt.q"			// 240x320@8fps BGR24
-
-#define REC_COMMON_VIDEO_EWS_SHM_SNAPSHOT_QUEUE		"4F85E066-158D-444A-9A37-86BB2AB44355"  //"rvc.shm.snapshot.ews_video.q"	    // 640x360@1fps RGB24
-#define REC_COMMON_VIDEO_EWS_SHM_RTP_QUEUE			"82A90F04-660C-4D03-9F39-7FF4DFCC1AD9"	//"rvc.shm.rtp.ews_video.q"				// 320x180@8fps I420
-#define REC_COMMON_VIDEO_SALES_EWS_SHM_RTP_QUEUE	"073109B3-A41E-44F9-8400-B515122B87E3"  //"rvc.shm.rtp.ews_sales_video.q"		// 320x180@8fps I420
-#define REC_COMMON_VIDEO_EWS_SHM_PREVIEW_QUEUE		"B3ACAF33-4162-4A26-88C7-6D03E5FBB99E"  //"rvc.shm.preview.ews_video.q"		    // 320x240@8fps RGB24
-
-#define REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE		"A15A1AE4-8846-43D6-9A74-198E311C2D21"	//"rvc.shm.rtp.video.remote.q"		    // 320x240@8fps //远端视频
-
-//#define REC_COMMON_VIDEO_ENV_SHM_RENDER_QUEUE		"46051A23-9E01-4973-A51A-357A557167A8"	//"rvc.shm.render.video.env.q"			// 640x360@10fps I420
-//#define REC_COMMON_VIDEO_OPT_SHM_RENDER_QUEUE		"C46C102C-F656-4B04-8B0D-31B71AD696B0"	//"rvc.shm.render.video.opt.q"			// 640x360@10fps I420
-
-#define REC_COMMON_AUDIO_SHM_QUEUE		            "FC5DFFDE-DA1F-4321-80EC-B9B03FD8BB95"	//"rvc.shm.audio.q"
-#define REC_COMMON_AUDIO_SALESOL_SHM_QUEUE		    "54A66218-7FAD-4A73-85CD-3BAF89EDED02"	//"rvc.shm.salesol_audio.q"
-#define REC_COMMON_AUDIO_SALES_SHM_QUEUE		    "72030F8D-5248-434C-BB36-FB0871EE461D"	//"rvc.shm.sales_audio.q"
-#define REC_COMMON_AUDIO_EWS_SHM_QUEUE		        "448C4CA3-DAE0-4567-AE5B-7307F64EBA68"	//"rvc.shm.ews_audio.q"
-#define REC_COMMON_REMOTEAUDIO_SHM_QUEUE		    "55934743-4E27-4A91-A237-9B6E02F03F96"	//"rvc.shm.agentaudio.q"