Kaynağa Gözat

Z991239-1621 #comment fea 回显库增加支持回显i420格式功能

陈礼鹏80274480 4 yıl önce
ebeveyn
işleme
7fbb4d717d

+ 2 - 0
Module/mod_mediacontroller/capture.h

@@ -105,6 +105,8 @@ namespace MediaController {
 #else
 		VideoCapObj* pVideoCap;
 #endif
+		Clibvideoqueue* render_shm_queue;
+		Clibvideoqueue* opt_render_shm_queue;
 		Clibvideoqueue *snapshot_shm_queue;
 		Clibvideoqueue *preview_shm_queue;
 		Clibvideoqueue *rtp_shm_queue;

+ 1 - 1
Other/libfacecapture/libfacecapture.cpp

@@ -202,7 +202,7 @@ public:
 		m_pHostEvent = NULL;
 		m_eMonitorState = NoBody;
 
-#ifdef _RVC_OS_WIN
+#ifdef RVC_OS_WIN
 		InitializeCriticalSection(&CS);
 
 		m_hEventWait = ::CreateEventA(NULL, TRUE, 0, 0);

+ 4 - 1
Other/libsharememory/libsharememory.cpp

@@ -68,6 +68,9 @@ public:
 		Debug("%s:%d", __FUNCTION__, __LINE__);
 	}
 
+
+#ifdef RVC_OS_WIN
+#else
 	bool CreateShareMemLinux(const char* szName, unsigned int dwBytes)
 	{
 		bool bRet = false;
@@ -127,9 +130,9 @@ public:
 				}
 			}
 		}
-
 		return bRet;
 	}
+#endif
 
 	//´´½¨¹²ÏíÄÚ´æÇø
 	bool CreateShareMem(const char* szName, unsigned int dwBytes)

+ 1 - 0
Other/libvideocapture/ivideocaptureinterface.h

@@ -108,6 +108,7 @@ typedef struct videocap_param_s
 	/* called from inner thread, should not block, can be null */
 	void (*on_frame)(void* user_data, video_frame* frame);
 	void (*on_frame_raw)(void* user_data, video_frame* frame); // for rgb24
+	int (*on_frame_i420)(void* user_data, video_frame* frame); // for i420
 	/* triggered when video capture device is lost */
 	void (*on_device_lost)(void* user_data);
 	/* after grab */

+ 7 - 6
Other/libvideocapture/libvideocapture.cpp

@@ -327,12 +327,13 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 
 	yvyu_to_yu12(i420, videoFrame, width, height);
 
-	//video_frame frmi420 = { 0 };
-	//frmi420.data[0] = i420y;
-	//frmi420.linesize[0] = width * 3 / 2;
-	//frmi420.width = width;
-	//frmi420.height = height;
-	//frmi420.format = VIDEO_FORMAT_I420;
+	video_frame frmi420 = { 0 };
+	frmi420.data[0] = i420y;
+	frmi420.linesize[0] = width * 3 / 2;
+	frmi420.width = width;
+	frmi420.height = height;
+	frmi420.format = VIDEO_FORMAT_I420;
+	m_capture->param.on_frame_i420(m_capture->param.user_data, &frmi420);
 
 	//video_frame_save_bmpfile("VIDEO_FORMAT_I420.bmp", &frmi420);
 

+ 7 - 3
Other/libvideoqueue/libvideoqueue.cpp

@@ -3,7 +3,6 @@
 
 #include "libvideoqueue.h"
 #include "../libsharememory/libsharememory.h"
-//#include "../../Other/rvcmediacommon/common_video/videoutil.h"
 #include "../../Other/libvideoframework/videoutil.h"
 
 
@@ -149,7 +148,7 @@ public:
 		} 
 		else if(m_ShareMem.Open(szName))
 		{
-			int i = m_ShareMem.GetBytes();
+			m_ShareMem.GetBytes();
 			m_lpMem = m_ShareMem.Lock(1000);
 			if(m_lpMem != NULL)
 			{
@@ -228,7 +227,12 @@ public:
 					videoq_frame*videotmp			= (videoq_frame*)aVideoFrameAddr[m_pQueue->rearindex];
 					videotmp->data					= (unsigned char*)aImgDataAddr[m_pQueue->rearindex ];
 					videotmp->format				= Video->format;
-					videotmp->framesize				= Video->height * Video->width * 3;
+					if (VIDEOQ_FORMAT_I420 == Video->format){
+						videotmp->framesize = Video->height * Video->width * 3/2;
+					}
+					else {
+						videotmp->framesize = Video->height * Video->width * 3;
+					}					
 					videotmp->height				= Video->height;
 					videotmp->width					= Video->width;
 					unsigned int*Ptr				= (unsigned int*)nTimeSignAddr;

+ 1 - 0
Other/libvideorender/ivideorenderinterface.h

@@ -25,6 +25,7 @@ typedef struct videorender_param_s {
 	uint32_t uheight;
 	uint32_t uwinflags;
 	bool bpersonarea;
+	int ivideoformat;
 }videorender_param_t;
 
 struct IRenderCallback

+ 19 - 10
Other/libvideorender/libvideorender.cpp

@@ -11,8 +11,9 @@ VideoRenderImpl::VideoRenderImpl(IRenderCallback* pCallback)
 
 	m_cx = SDL_WINDOWPOS_UNDEFINED;
 	m_cy = SDL_WINDOWPOS_UNDEFINED;
-	m_width = 640;
-	m_height = 360;
+	m_width = 0;
+	m_height = 0;
+	m_videoformat = VIDEO_FORMAT_RGB24;
 	m_flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR;
 }
 
@@ -60,11 +61,23 @@ int VideoRenderImpl::SetWindowProperty(videorender_param_t* tparam)
 
 	m_flags |= tparam->uwinflags;
 
+	m_videoformat = tparam->ivideoformat;
+
 	iRet = 0;
 
 	return iRet;
 }
 
+SDL_PixelFormatEnum VideoRenderImpl::GetPixelFormat()
+{
+	SDL_PixelFormatEnum eType = SDL_PIXELFORMAT_BGR24;
+	if (VIDEO_FORMAT_I420 == m_videoformat){
+		eType = SDL_PIXELFORMAT_IYUV;
+	}
+
+	return eType;
+}
+
 int VideoRenderImpl::VideoRenderSetParam(videorender_param_t* tparam)
 {
 	if (SetWindowProperty(tparam)){
@@ -190,7 +203,7 @@ int VideoRenderImpl::VideoRenderSetParam(videorender_param_t* tparam)
 	SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE);
 
 	m_rending_texture = SDL_CreateTexture(m_renderer,
-		SDL_PIXELFORMAT_BGR24,
+		GetPixelFormat(),
 		SDL_TEXTUREACCESS_STREAMING,
 		m_videowidth,
 		m_videoheight);
@@ -246,16 +259,13 @@ void VideoRenderImpl::VideoRenderDestroy()
 int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
 {
 	int iret = -1;
-	m_callback->Debug("%s:%d", __FUNCTION__, __LINE__);
 	if (NULL == m_sdl_window || NULL == pframe || NULL == m_renderer || NULL == m_rending_texture){
 		return iret;
 	}
-	m_callback->Debug("%s:%d",__FUNCTION__, __LINE__);
 
 	SDL_SetRenderDrawColor(m_renderer, 0, 0, 0, 255); /*black*/
 	SDL_RenderClear(m_renderer);
 
-	m_callback->Debug("%s:%d", __FUNCTION__, __LINE__);
 	/* since data is continuous we can use SDL_UpdateTexture
 	 * instead of SDL_UpdateYUVTexture.
 	 * no need to use SDL_Lock/UnlockTexture (it doesn't seem faster)
@@ -264,7 +274,9 @@ int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
 
 	if (VIDEO_FORMAT_RGB24 == pframe->format){
 		SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width*3);
-		m_callback->Debug("%s:%d", __FUNCTION__, __LINE__);
+	}
+	else if(VIDEO_FORMAT_I420 == pframe->format){
+		SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width);
 	}
 	else
 	{
@@ -274,12 +286,9 @@ int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
 
 
 	SDL_RenderCopy(m_renderer, m_rending_texture, NULL, NULL);
-	m_callback->Debug("%s:%d", __FUNCTION__, __LINE__);
 
 	SDL_RenderPresent(m_renderer);
 
-	m_callback->Debug("%s:%d", __FUNCTION__, __LINE__);
-
 	iret = 0;
 
 	return iret;

+ 2 - 0
Other/libvideorender/libvideorender.h

@@ -23,6 +23,7 @@ public:
 	int RenderVideoFrame(video_frame* pframe);
 
 	int SetWindowProperty(videorender_param_t* tparam);
+	SDL_PixelFormatEnum GetPixelFormat();
 
 
 private:
@@ -38,4 +39,5 @@ private:
 	uint32_t m_width;
 	uint32_t m_height;
 	uint32_t m_flags;
+	int m_videoformat;
 };

+ 3 - 0
Other/rvcmediacommon/rvc_media_common.h

@@ -88,6 +88,9 @@
 
 #define REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE		"rvc.shm.rtp.video.remote.q"	    // 320x240@8fps //Ô¶¶ËÊÓÆµ
 
+#define REC_COMMON_VIDEO_ENV_SHM_RENDER_QUEUE		"rvc.shm.render.video.env.q"	    // 640x360@10fps I420
+#define REC_COMMON_VIDEO_OPT_SHM_RENDER_QUEUE		"rvc.shm.render.video.opt.q"	    // 640x360@10fps I420
+
 #define REC_COMMON_AUDIO_SHM_QUEUE		            "rvc.shm.audio.q"
 #define REC_COMMON_AUDIO_SALESOL_SHM_QUEUE		    "rvc.shm.salesol_audio.q"
 #define REC_COMMON_AUDIO_SALES_SHM_QUEUE		    "rvc.shm.sales_audio.q"