Explorar o código

Z991239-5614 #comment WIN支持下摄像头回显

80274480 hai 1 ano
pai
achega
e934dde4af

+ 12 - 2
Module/mod_sipphone/mod_sipphone.cpp

@@ -238,6 +238,16 @@ static bool IsBothSoundCardError(uint32_t unum)
 }
 
 
+static int tovalidwidth(int iwidth)
+{
+	if (0 == iwidth % 4) {
+		return iwidth;
+	}
+	else {
+		return ((iwidth + 4) / 4) * 4;
+	}
+}
+
 CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhoneState(ePickupMicrophoneState_Off) 
 {
 	m_kept_volume_in[0] = m_kept_volume_in[1] = 0;
@@ -2529,11 +2539,11 @@ void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_Start
 	pCmd->remote_port = ctx->Info.remote_port;
 	pCmd->local_view_x = ctx->Info.local_view_x;
 	pCmd->local_view_y = ctx->Info.local_view_y;
-	pCmd->local_view_cx = ctx->Info.local_view_cx;
+	pCmd->local_view_cx = tovalidwidth(ctx->Info.local_view_cx);
 	pCmd->local_view_cy = ctx->Info.local_view_cy;
 	pCmd->remote_view_x = ctx->Info.remote_view_x;
 	pCmd->remote_view_y = ctx->Info.remote_view_y;
-	pCmd->remote_view_cx = ctx->Info.remote_view_cx;
+	pCmd->remote_view_cx = tovalidwidth(ctx->Info.remote_view_cx);
 	pCmd->remote_view_cy = ctx->Info.remote_view_cy;
 	pCmd->remote_width = ctx->Info.remote_width;
 	pCmd->remote_height = ctx->Info.remote_height;

+ 22 - 20
Module/mod_sipphone/win/video_session.cpp

@@ -579,7 +579,10 @@ static int on_pull(videoplayer_t *player, void *user_data, video_frame **frame)
 		}
 		else
 		{
-			tmp_frame_preview = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
+			int iwidth = REC_COMMON_VIDEO_PREVIEW_WIDTH;
+			int iheight = REC_COMMON_VIDEO_PREVIEW_HEIGHT;
+			session->video_shm_q_preview->GetFrameSize(iwidth, iheight);
+			tmp_frame_preview = video_frame_new(iwidth, iheight, VIDEO_FORMAT_RGB24);
 			videoq_frame frm;
 			frm.data = tmp_frame_preview->data[0];
 			bool result = session->video_shm_q_preview->GetVideo(&frm, iflags);
@@ -1146,6 +1149,12 @@ static int start_video(video_session_t *session)
 		}
 
 		if (DOUBLERECORD_CALLTYPE != session->conf.nCallType){
+			int iwidth = REC_COMMON_VIDEO_PREVIEW_WIDTH;
+			int iheight = REC_COMMON_VIDEO_PREVIEW_HEIGHT;
+			if (session->conf.local_video_view_cx < session->conf.local_video_view_cy) {
+				iwidth = REC_COMMON_VIDEO_PREVIEW_HEIGHT;
+				iheight = REC_COMMON_VIDEO_PREVIEW_WIDTH;
+			}
 			rc = videoplayer_create(session->local_hwnd, 
 				0,
 				0,
@@ -1153,8 +1162,8 @@ static int start_video(video_session_t *session)
 				session->conf.local_video_view_cy,
 				REC_COMMON_VIDEO_FPS_NUM,
 				REC_COMMON_VIDEO_FPS_DEN,
-				bIsActiveInspect?REC_COMMON_VIDEO_SNAPSHOT_WIDTH:REC_COMMON_VIDEO_PREVIEW_WIDTH,
-				bIsActiveInspect?REC_COMMON_VIDEO_SNAPSHOT_WIDTH:REC_COMMON_VIDEO_PREVIEW_HEIGHT,
+				bIsActiveInspect?REC_COMMON_VIDEO_SNAPSHOT_WIDTH: iwidth,
+				bIsActiveInspect?REC_COMMON_VIDEO_SNAPSHOT_WIDTH: iheight,
 				//*VIDEOPLAYER_FLAG_DOUBLESIZE|*/VIDEOPLAYER_FLAG_PULL|VIDEOPLAYER_FLAG_CHECKTOP,
 				session->conf.ilocal_wind_flags,
 				"local",
@@ -1685,10 +1694,6 @@ static void __video_render_log(render_loglevel elevel, void* user_data, const ch
 static unsigned int __stdcall videorender_func(void* arg)
 {
 	video_session_t* session = (video_session_t*)arg;
-	char str_local_ip[MAX_PATH] = { 0 };
-	char str_remote_ip[MAX_PATH] = { 0 };
-	translate_ipaddr_from_int(str_local_ip, MAX_PATH, session->conf.local_rtp_ip);
-	translate_ipaddr_from_int(str_remote_ip, MAX_PATH, session->conf.remote_rtp_ip);
 
 	videorender_callback_t t_callback = { 0 };
 	t_callback.debug = &__video_render_log;
@@ -1926,21 +1931,23 @@ static void stop_ui(video_session_t *session)
 }
 
 
-int Local_video_session_create(const video_session_conf_t *conf, video_session_t **p_session, const bool bremote)
+int local_video_session_create(const video_session_conf_t *conf, video_session_t **p_session, const bool bremote)
 {
 	video_session_t *session = ZALLOC_T(video_session_t);
 	if (session) 
 	{
 		memcpy(&session->conf, conf, sizeof(video_session_conf_t));
-		session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE);
+
+		if (conf->local_video_view_cx >= conf->local_video_view_cy) {
+			session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE);
+		}
+		else {
+			session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_OPT_SHM_PREVIEW_QUEUE);
+		}
+			
 		
 		if (bremote){
-			if (eStand2sType == conf->eDeviceType){
-				session->video_shm_q_remote = new Clibvideoqueue(REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE);
-			}
-			else{
-				session->video_shm_q_remote = new Clibvideoqueue(REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE);
-			}
+			session->video_shm_q_remote = new Clibvideoqueue(REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE);
 		}
 		
 		if (conf->ref_Is_ActiveInspect != NULL)
@@ -1968,11 +1975,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 	video_session_t *session = ZALLOC_T(video_session_t);
 	if (session) 
 	{
-		char str_local[MAX_PATH] = {0};
-		char str_remote[MAX_PATH] = {0};
-		translate_ipaddr_from_int(str_local, MAX_PATH, conf->local_rtp_ip);
-		translate_ipaddr_from_int(str_remote, MAX_PATH, conf->remote_rtp_ip);
-
 		memcpy(&session->conf, conf, sizeof(video_session_conf_t));
 		session->video_shm_q_env = new Clibvideoqueue(REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE);
 		if (DOUBLERECORD_CALLTYPE != conf->nCallType){

+ 23 - 32
Other/win/libvideoframework/videoplayer.c

@@ -84,7 +84,7 @@ struct videoplayer_t
 
 	LPVOID black_frame_data;
 	LPVOID res_frame_data;
-	struct SwsContext *sws_context;
+	struct SwsContext *render_sws_context;
 
 	DWORD dwPlayTimer;
 	HDRAWDIB hdib;
@@ -120,7 +120,7 @@ int IsHideRemoteWin = 0;
 int IsHideLocalWin = 0;
 
 
-static void Dbg(const char *fmt, ...)
+static void player_dbg(const char *fmt, ...)
 {
 	int n;
 	va_list arg;
@@ -159,16 +159,6 @@ static int init_thunk(struct winthunk_t *thunk, DWORD_PTR proc, videoplayer_t *p
 
 static void display_frame_entry(videoplayer_t *player, video_frame *frame);
 
-static BOOL is_parent_window_of(HWND x, HWND y)
-{
-	HWND t = GetParent(y);
-	while (t) {
-		if (t == x)
-			return TRUE;
-		t = GetParent(t);
-	}
-	return FALSE;
-}
 
 static void check_on_top(videoplayer_t *player)
 {
@@ -285,15 +275,16 @@ static void display_frame_entry(videoplayer_t *player, video_frame *frame)
 				bmpheader.biCompression = BI_RGB;
 				bmpheader.biHeight = player->cy;
 				bmpheader.biWidth = player->cx;
-				if (player->sws_context) {
+				if (player->render_sws_context) {
 					unsigned char *src_data[4] = {frame->data[0], NULL, NULL, NULL};
 					int src_linesize[4] = {player->width*3, 0, 0, 0};
 					unsigned char *dst_data[4] = {player->res_frame_data, NULL, NULL, NULL};
 					int dst_linesize[4] = {player->cx*3, 0, 0, 0};
-					sws_scale(player->sws_context, src_data, src_linesize, 
+					sws_scale(player->render_sws_context, src_data, src_linesize,
 						0, player->height, dst_data, dst_linesize);
 					DrawDibDraw(player->hdib, hdc, 0, 0, -1, -1, &bmpheader, player->res_frame_data, 0, 0, player->cx, player->cy, DDF_SAME_DRAW|DDF_SAME_HDC);
-				} else {
+				}
+				else {
 					DrawDibDraw(player->hdib, hdc, 0, 0, -1, -1, &bmpheader, frame->data[0], 0, 0, player->cx, player->cy, DDF_SAME_DRAW|DDF_SAME_HDC);
 				}
 			}
@@ -386,7 +377,7 @@ static void OnMsgTimer_PushMode(videoplayer_t *player, HWND hWnd, UINT msg, WPAR
 			} else {
 				//Dbg("display frame");
 				display_frame_entry(player, entry->raw_frame);
-				displayed = TRUE;
+				displayed = true;
 				free_frame_entry(player, &player->current_frame);
 				player->current_frame.raw_frame = entry->raw_frame;
 				player->current_frame.free_frame = entry->free_frame;
@@ -397,7 +388,7 @@ static void OnMsgTimer_PushMode(videoplayer_t *player, HWND hWnd, UINT msg, WPAR
 			}
 		}
 		if (!displayed) {
-			player->q_caching = TRUE;
+			player->q_caching = 1;
 			Dbg("recaching");
 		}
 	}
@@ -441,8 +432,8 @@ static void OnMsgInit(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM wParam,
 	memset(player->black_frame_data, 0, player->cx*player->cy*3);
 
 	if (player->cx != player->width || player->cy != player->height) {
-		player->res_frame_data = malloc(player->cx*player->cy*3);
-		player->sws_context = sws_getCachedContext(
+		player->res_frame_data = malloc(player->cx *player->cy*3);
+		player->render_sws_context = sws_getCachedContext(
 			NULL,
 			player->width, 
 			player->height, 
@@ -512,11 +503,11 @@ static void OnMsgClear(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM wParam
 	}
 	assert(player->q_head == player->q_tail);
 
-	if (player->sws_context) {
+	if (player->render_sws_context) {
 		free(player->res_frame_data);
 		player->res_frame_data = NULL;
-		sws_freeContext(player->sws_context);
-		player->sws_context = NULL;
+		sws_freeContext(player->render_sws_context);
+		player->render_sws_context = NULL;
 	}
 
 	if (player->double_size_sws_context) {
@@ -601,7 +592,7 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 		if (((nWindowState==1 && player->cx != 960)&&(bMove==0))&&(player->flags & VIDEOPLAYER_FLAG_PULL)&&(player->flags & VIDEOPLAYER_FLAG_DOUBLESIZE)&&(IsHideLocalWin==0))
 		{
 			GetWindowRect(hWnd, &g_Rect);
-			MoveWindow(hWnd, g_Rect.left, g_Rect.top, player->cx<<1, player->cy<<1, TRUE);
+			MoveWindow(hWnd, g_Rect.left, g_Rect.top, player->cx<<1, player->cy<<1, true);
 			player->esizemode = eDoubleSize;
 			if (player->flags & VIDEOPLAYER_FLAG_DOUBLESIZE) 
 			{
@@ -638,7 +629,7 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 		}
 		else if ((nWindowState==0)&&bMove&&(player->flags & VIDEOPLAYER_FLAG_PULL)&&(player->flags & VIDEOPLAYER_FLAG_DOUBLESIZE || player->flags & VIDEOPLAYER_FLAG_ZOOMOUTSIZE)&&(IsHideLocalWin==0))
 		{
-			MoveWindow(hWnd, g_Rect.left, g_Rect.top, player->cx, player->cy, TRUE);
+			MoveWindow(hWnd, g_Rect.left, g_Rect.top, player->cx, player->cy, true);
 			player->esizemode = eNormalSize;
 			bMove = 0;
 			if (player->flags & VIDEOPLAYER_FLAG_DOUBLESIZE||player->flags & VIDEOPLAYER_FLAG_ZOOMOUTSIZE) 
@@ -678,7 +669,7 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 		{
 			//Dbg("zoom out size video echo.");
 			GetWindowRect(hWnd, &g_Rect);
-			MoveWindow(hWnd, g_Rect.left, g_Rect.top, SMALL_RECORD_VIDEO_WIDTH, SMALL_RECORD_VIDEO_HEIGHT, TRUE);
+			MoveWindow(hWnd, g_Rect.left, g_Rect.top, SMALL_RECORD_VIDEO_WIDTH, SMALL_RECORD_VIDEO_HEIGHT, true);
 			player->esizemode = eZoomOutSize;
 			if (player->flags&VIDEOPLAYER_FLAG_ZOOMOUTSIZE) 
 			{
@@ -738,11 +729,11 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 				GetWindowRect(hWnd, &rc);
 				if (eDoubleSize == player->esizemode) 
 				{
-					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, true);
 				} 
 				else 
 				{
-					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, true);
 				}
 			}
 		} 
@@ -763,11 +754,11 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 				GetWindowRect(hWnd, &rc);
 				if (eDoubleSize == player->esizemode) 
 				{
-					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, true);
 				} 
 				else 
 				{
-					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, true);
 				}
 			}
 		} else {
@@ -791,9 +782,9 @@ static LRESULT VideoWndProc(videoplayer_t *player, HWND hWnd, UINT msg, WPARAM w
 				RECT rc;
 				GetWindowRect(hWnd, &rc);
 				if (eDoubleSize == player->esizemode) {
-					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx<<1, player->cy<<1, true);
 				} else {
-					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, TRUE);
+					MoveWindow(hWnd, rc.left, rc.top, player->cx, player->cy, true);
 				}
 			}
 		} else {
@@ -909,7 +900,7 @@ int videoplayer_create(HWND hWndVideo,
 		player->min_cache_size = FRAME_MIN_CACHE_MSEC * fps_num / 1000 * fps_den;
 		player->max_cache_size = FRAME_MAX_CACHE_MSEC * fps_num / 1000 * fps_den;
 		player->res_frame_data = player->black_frame_data = NULL;
-		player->sws_context = NULL;
+		player->render_sws_context = NULL;
 		player->esizemode = eNormalSize;
 		player->double_size_sws_context = NULL;
 		player->double_size_data = NULL;