فهرست منبع

Z991239-1812 #comment other 增加支持远程双录回显功能

陈礼鹏80274480 4 سال پیش
والد
کامیت
7de0709fb1
3فایلهای تغییر یافته به همراه103 افزوده شده و 76 حذف شده
  1. 3 3
      Module/mod_localmediaplay/mod_localmediaplay.cpp
  2. 1 1
      Module/mod_sipphone/endpoint.cpp
  3. 99 72
      Module/mod_sipphone/video_session.cpp

+ 3 - 3
Module/mod_localmediaplay/mod_localmediaplay.cpp

@@ -557,7 +557,7 @@ ErrorCodeEnum CLocalMediaPlayEntity::__OnStart(ErrorCodeEnum preOperationError)
 #else
 	int err = pthread_create(&m_scanThreadId, NULL, queryMedia, this);
 	if (0 == err){
-		Dbg("create queryMedia thread success, %lu.", m_scanThreadId);
+		Dbg("create queryMedia thread success, %u.", m_scanThreadId);
 	}
 	else{
 		Dbg("create queryMedia thread failed.");
@@ -983,7 +983,7 @@ void CLocalMediaPlayEntity::StartVideo(int nCfgInx, int nWndX, int nWndY, int nW
 	pthread_t uMediaPlayThreadId = 0;
 	int err = pthread_create(&uMediaPlayThreadId, NULL, StartMediaPlayFunc, this);
 	if (0 == err) {
-		Dbg("create media play thread[%lu] success.", uMediaPlayThreadId);
+		Dbg("create media play thread[%u] success.", uMediaPlayThreadId);
 	}
 	else {
 		Dbg("create media play thread failed.");
@@ -1029,7 +1029,7 @@ void CLocalMediaPlayEntity::StartAudio(const char *pAudioNames)
 
 	int err = pthread_create(&m_uAudioPlayThreadId, NULL, StartAudioPlayingThreadFunc, this);
 	if (0 == err) {
-		Dbg("create audio play thread[%lu] success.", m_uAudioPlayThreadId);
+		Dbg("create audio play thread[%u] success.", m_uAudioPlayThreadId);
 	}
 	else {
 		Dbg("create audio play thread failed.");

+ 1 - 1
Module/mod_sipphone/endpoint.cpp

@@ -1712,7 +1712,7 @@ int local_remote_show_video(endpoint_call_t *call,int local_view_x, int local_vi
 		return -1;
 	}
 	else{
-		Dbg("local remote show video success start video session %0x.", call->video);
+		Dbg("local remote show video success start video session 0x%0x.", call->video);
 	}
 
 	return 0;

+ 99 - 72
Module/mod_sipphone/video_session.cpp

@@ -85,7 +85,8 @@ typedef struct picture_record_s{
 	HANDLE evt;
 	HANDLE work_thread;
 #else
-
+	sem_t sem_evt;
+	pthread_t work_threadid;
 #endif // RVC_OS_WIN
 
 	video_session_t* session;
@@ -728,10 +729,21 @@ int show_agent_picture_proc(void *arg)
 
 #ifdef RVC_OS_WIN
 	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
-	
+#endif 
+
 	for (;;) {
+#ifdef RVC_OS_WIN
 		DWORD dwRet = WaitForSingleObject(t_record->evt, 200);
-		if (dwRet == WAIT_TIMEOUT) {
+		if (dwRet == WAIT_TIMEOUT)
+#else
+		struct timespec ts;
+		clock_gettime(CLOCK_REALTIME, &ts);
+		long unsec = ts.tv_nsec + (1000 * 1000 * 200);
+		ts.tv_sec += (unsec / 1000000000);
+		ts.tv_nsec = (unsec % 1000000000);
+		if (0 != sem_timedwait(&t_record->sem_evt, &ts))
+#endif
+		{
 			if (NULL != t_record->session)
 			{
 				if (NULL != t_record->session->video_shm_q_remote)
@@ -758,9 +770,6 @@ int show_agent_picture_proc(void *arg)
 			break;
 		}
 	}
-#else
-
-#endif
 
 	return 0;
 }
@@ -792,10 +801,10 @@ int show_agent_picture_proc(void *arg)
 
 
 //坐席端图像显示线程
-#ifdef _WIN32
+#ifdef RVC_OS_WIN
 static unsigned int __stdcall agent_picture_show_thread(void* arg)
 #else
-static unsigned int __attribute__((__stdcall)) agent_picture_show_thread(void* arg)
+void* agent_picture_show_thread(void* arg)
 #endif
 {
 	//__try {
@@ -816,7 +825,21 @@ static int agent_picture_video_start(picture_record_t* t_record)
 	t_record->evt = CreateEventA(NULL, FALSE, FALSE, NULL);
 	t_record->work_thread = (HANDLE)_beginthreadex(NULL, 0, &agent_picture_show_thread, t_record, 0, NULL);
 #else
-
+	sem_init(&t_record->sem_evt, 0, 0);
+	pthread_attr_t attr;
+	pthread_attr_init(&attr);
+	struct sched_param param;
+	param.sched_priority = sched_get_priority_max(SCHED_RR);
+	pthread_attr_setschedpolicy(&attr, SCHED_RR);
+	pthread_attr_setschedparam(&attr, &param);
+	pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+	int err = pthread_create(&t_record->work_threadid, &attr, agent_picture_show_thread, t_record);
+	if (0 == err) {
+		Dbg("create agent picture show thread success, %u.", t_record->work_threadid);
+	}
+	else {
+		Dbg("create agent picture show thread failed.");
+	}
 #endif // RVC_OS_WIN
 	return 0;
 }
@@ -838,6 +861,12 @@ static int agent_picture_video_stop(picture_record_t* t_record)
 	}
 
 #else
+	
+	sem_post(&t_record->sem_evt);
+	if (t_record->work_threadid > 0) {
+		pthread_join(t_record->work_threadid, NULL);
+		t_record->work_threadid = 0;
+	}
 
 #endif // RVC_OS_WIN
 	if (t_record->record_frame){
@@ -1108,8 +1137,9 @@ static int start_video(video_session_t *session)
 		Dbg("session->video_shm_q_opt is NULL.");
 	}
 
-#ifdef RVC_OS_WIN
 	Dbg("session nCallType is %d, remote_video_view_cx = %d,remote_video_view_cy = %d,remote_video_width = %d,remote_video_height = %d.", session->conf.nCallType,session->conf.remote_video_view_cx,session->conf.remote_video_view_cy,session->conf.remote_video_width,session->conf.remote_video_height);
+
+#ifdef RVC_OS_WIN
 	if (DOUBLERECORD_CALLTYPE != session->conf.nCallType){
 		Dbg("create new remote video player");
 		if (session->remote_hwnd)
@@ -1758,7 +1788,7 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 static unsigned int __stdcall ui_proc(void *arg)
 {
 	video_session_t *session = (video_session_t*)arg;
-	Dbg("ui_proc session addr is %0x", session);
+	Dbg("ui_proc session addr is 0x%0x", session);
 
 	WNDCLASSA wc = {0};
 	ATOM a = 0;
@@ -1916,26 +1946,7 @@ void* videorender_func(void* arg)
 	Dbg("%s:%d local(%d,%d,%d,%d) remote(%d,%d,%d,%d).", __FUNCTION__, __LINE__, session->conf.local_video_view_x, session->conf.local_video_view_y, session->conf.local_video_view_cx, session->conf.local_video_view_cy,
 		session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy);
 
-	if (NULL != session->premote_render)
-	{
-		videorender_param_t tparam_remote = { 0 };
-		tparam_remote.icx = session->conf.remote_video_view_x;
-		tparam_remote.icy = session->conf.remote_video_view_y;
-		tparam_remote.uwidth = session->conf.remote_video_view_cx;
-		tparam_remote.uheight = session->conf.remote_video_view_cy;
-		//tparam_remote.uvideowidth = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
-		//tparam_remote.uvideoheight = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
-		tparam_remote.ivideoformat = VIDEO_FORMAT_RGB24;
-		if (0 == session->premote_render->SetVideoRenderParam(&tparam_remote)) {
-			session->premote_render->ShowVideoWindow();
-		}
-
-		start_video(session);
-	}
-	else {
-		Dbg("session remote video render is null.");
-	}
-
+	session->plocal_render = new VideoRenderObj();
 	if (NULL != session->plocal_render){
 		videorender_param_t tparam = { 0 };
 		tparam.icx = session->conf.local_video_view_x;
@@ -1946,34 +1957,7 @@ void* videorender_func(void* arg)
 		//tparam.uvideoheight = REC_COMMON_VIDEO_PREVIEW_HEIGHT;
 		tparam.ivideoformat = VIDEO_FORMAT_RGB24;
 		if (0 == session->plocal_render->SetVideoRenderParam(&tparam)){
-			session->plocal_render->ShowVideoWindow();
-			video_frame* vfrm = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
-
-			for ( ; ; ){
-				struct timespec ts;
-				clock_gettime(CLOCK_REALTIME, &ts);
-				long unsec = ts.tv_nsec + (1000 * 1000 * 100);
-				ts.tv_sec += (unsec / 1000000000);
-				ts.tv_nsec = (unsec % 1000000000);
-				if (0 != sem_timedwait(&session->ui_stop_sem, &ts) && (ETIMEDOUT == errno))
-				{
-					video_frame_fill_black(vfrm);
-					video_frame* tmp_frame_preview = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
-					videoq_frame qfrm;
-					qfrm.data = tmp_frame_preview->data[0];
-					//Dbg("%s:%d,and current video queue len is %d", __FUNCTION__, __LINE__, session->video_shm_q_preview->GetVideoLens());
-					bool result = session->video_shm_q_preview->GetVideo(&qfrm, VIDEOQUEUE_FLAG_HORIZONTAL_FLIP);
-					if (result) {
-						session->plocal_render->RenderVideoFrame(tmp_frame_preview);
-					}
-				}
-				else {
-					Dbg("%s:%d videorender_func exit!", __FUNCTION__, __LINE__);
-					session->plocal_render->HideVideoWindow();
-					break;
-				}
-			}
-			video_frame_delete(vfrm);
+			session->plocal_render->HideVideoWindow();
 		}
 		else {
 			Dbg("%s:%d set video render param failed!", __FUNCTION__, __LINE__);
@@ -1983,6 +1967,59 @@ void* videorender_func(void* arg)
 		Dbg("%s:%d session local video render is null.", __FUNCTION__, __LINE__);
 	}
 
+	if (session->conf.remote_video_view_x || session->conf.remote_video_view_y || session->conf.remote_video_view_cx || session->conf.remote_video_view_cy){
+		Dbg("create remote video hwnd x = %d, y = %d, width = %d, height = %d.", session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy);
+		session->premote_render = new VideoRenderObj();
+		if (session->premote_render){
+			videorender_param_t tparam_remote = { 0 };
+			tparam_remote.icx = session->conf.remote_video_view_x;
+			tparam_remote.icy = session->conf.remote_video_view_y;
+			tparam_remote.uwidth = session->conf.remote_video_view_cx;
+			tparam_remote.uheight = session->conf.remote_video_view_cy;
+			//tparam_remote.uvideowidth = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
+			//tparam_remote.uvideoheight = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
+			tparam_remote.ivideoformat = VIDEO_FORMAT_RGB24;
+			if (0 == session->premote_render->SetVideoRenderParam(&tparam_remote)) {
+				session->premote_render->ShowVideoWindow();
+			}
+		}
+		else {
+			Dbg("session remote video render is null.");
+		}
+	}
+
+	if (session->plocal_render){
+		start_video(session);
+		session->plocal_render->ShowVideoWindow();
+
+		video_frame* vfrm = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
+		for (; ; ) {
+			struct timespec ts;
+			clock_gettime(CLOCK_REALTIME, &ts);
+			long unsec = ts.tv_nsec + (1000 * 1000 * 100);
+			ts.tv_sec += (unsec / 1000000000);
+			ts.tv_nsec = (unsec % 1000000000);
+			if (0 != sem_timedwait(&session->ui_stop_sem, &ts) && (ETIMEDOUT == errno))
+			{
+				video_frame_fill_black(vfrm);
+				video_frame* tmp_frame_preview = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
+				videoq_frame qfrm;
+				qfrm.data = tmp_frame_preview->data[0];
+				//Dbg("%s:%d,and current video queue len is %d", __FUNCTION__, __LINE__, session->video_shm_q_preview->GetVideoLens());
+				bool result = session->video_shm_q_preview->GetVideo(&qfrm, VIDEOQUEUE_FLAG_HORIZONTAL_FLIP);
+				if (result) {
+					session->plocal_render->RenderVideoFrame(tmp_frame_preview);
+				}
+			}
+			else {
+				Dbg("%s:%d videorender_func exit!", __FUNCTION__, __LINE__);
+				session->plocal_render->HideVideoWindow();
+				break;
+			}
+		}
+		video_frame_delete(vfrm);
+	}
+
 	return 0;
 }
 
@@ -2137,7 +2174,7 @@ static int load_record_area_png(video_session_t *session)
 	GetCurrentRunPath(strPath);
 	sprintf(strRecordAreaPath, "%s\\bin\\recordarea.png", strPath);
 #else
-
+	strcpy_s(strRecordAreaPath, MAX_PATH_SIZE, "./bin/recordarea.png");
 #endif // RVC_OS_WIN
 
 	if (ExistsFile(strRecordAreaPath))
@@ -2197,7 +2234,7 @@ int Local_video_session_create(const video_session_conf_t *conf, video_session_t
 	if (session) 
 	{
 		memcpy(&session->conf, conf, sizeof(video_session_conf_t));
-		if ((conf->eDeviceType == eDesk2SType||conf->eDeviceType == eDesk1SType||conf->eDeviceType == eDesk2SIntegratedType) && g_bIsSalesRecord) //edit by ly@20180725
+		if ((conf->eDeviceType == eDesk2SType||conf->eDeviceType == eDesk1SType||conf->eDeviceType == eDesk2SIntegratedType) && g_bIsSalesRecord) 
 		{
 			//modify by clp  20191011  低柜区分是否远程连线模式双录
 			if (g_bEwsRecord)
@@ -2211,7 +2248,7 @@ int Local_video_session_create(const video_session_conf_t *conf, video_session_t
 				Dbg("[dbg] use env preview share memory.");
 			}
 		}
-		else if ((conf->eDeviceType == ePadtype || conf->eDeviceType == eMobilePadType) && g_bEwsRecord) // edit by ly@2019/04/18
+		else if ((conf->eDeviceType == ePadtype || conf->eDeviceType == eMobilePadType) && g_bEwsRecord)
 		{
 			session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_EWS_SHM_PREVIEW_QUEUE);
 			Dbg("[dbg] use ews preview share memory");
@@ -2256,10 +2293,6 @@ int Local_video_session_create(const video_session_conf_t *conf, video_session_t
 			}
 		}
 
-#ifdef RVC_OS_WIN
-#else
-		session->plocal_render = new VideoRenderObj();
-#endif
 		*p_session = session;
 	}
 	return 0;
@@ -2393,12 +2426,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 			session->video_shm_q_opt = new Clibvideoqueue(REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE);
 		}
 
-#ifdef RVC_OS_WIN
-#else
-		session->plocal_render = new VideoRenderObj();
-		session->premote_render = new VideoRenderObj();
-
-#endif
 		*p_session = session;
 	}
 	return 0;