Эх сурвалжийг харах

Revert "#IQRV #comment [sipphone] 图像采集库兼容支持不包含640*360分辨率摄像头"

This reverts commit 7567ca771144415c206325468d3e70e73eab3520.
gifur 4 жил өмнө
parent
commit
0d14ef5964

+ 64 - 67
Other/libvideocapture/linux/videocapture_linux.cpp

@@ -56,13 +56,10 @@ VideoCaptureImpl::VideoCaptureImpl(ICaptureCallback* pCallback)
 	m_deviceId = -1;
 	m_deviceFd = -1;
 
-	m_in_cap_width = 0;
-	m_in_cap_height = 0;
-	m_real_cap_width = 0;
-	m_real_cap_height = 0;
-	m_out_cap_width = 0;
-	m_out_cap_height = 0;
-
+	m_capture_width = 0;
+	m_capture_height = 0;
+	m_dest_cap_width = 0;
+	m_dest_cap_height = 0;
 	m_rotate = libyuv::kRotate0;
 	m_frame_fmt = VIDEO_FORMAT_I420;
 	m_captureVideoType = VideoType::kI420;
@@ -220,12 +217,12 @@ int VideoCaptureImpl::VideoCaptureSetParam(videocap_param_t* param)
 	
 	m_rotate = RotateTrans(param->irotate);
 
-	m_in_cap_width = m_out_cap_width = mode_width[m_capture->param.cap_mode];
-	m_in_cap_height = m_out_cap_height = mode_height[m_capture->param.cap_mode];
+	m_dest_cap_width = mode_width[m_capture->param.cap_mode];
+	m_dest_cap_height = mode_height[m_capture->param.cap_mode];
 
 	if (libyuv::kRotate90 == m_rotate || libyuv::kRotate270 == m_rotate){
-		m_out_cap_width = mode_height[m_capture->param.cap_mode];
-		m_out_cap_height = mode_width[m_capture->param.cap_mode];
+		m_dest_cap_width = mode_height[m_capture->param.cap_mode];
+		m_dest_cap_height = mode_width[m_capture->param.cap_mode];
 	}
 	
 	return 0;
@@ -348,7 +345,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 
 	if (0 == m_ilogcount){
 		if (m_callback){
-			m_callback->Debug("IncomingFrame capture_time is %d, videoType=%d, rotate=%d, videoFrameLength=%d, width=%d, height=%d, and destination width=%d, height=%d.", captureTime, frameInfo.videoType, m_rotate, videoFrameLength, width, height, m_out_cap_width, m_out_cap_height);
+			m_callback->Debug("IncomingFrame capture_time is %d, videoType=%d, rotate=%d, videoFrameLength=%d, width=%d, height=%d, and destination width=%d, height=%d.", captureTime, frameInfo.videoType, m_rotate, videoFrameLength, width, height, m_dest_cap_width, m_dest_cap_height);
 		}
 		m_ilogcount++;
 	}
@@ -363,9 +360,9 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 		return -1;
 	}
 
-	int stride_y = m_in_cap_width;
-	int stride_u = (m_in_cap_width + 1)/2;
-	int stride_v = (m_in_cap_width + 1)/2;
+	int stride_y = width;
+	int stride_u = (width + 1)/2;
+	int stride_v = (width + 1)/2;
 
 	//uint8_t* i420y = (uint8_t*)AlignedMalloc(I420DataSize(height, stride_y, stride_u, stride_v), kBufferAlignment);
 	//uint8_t* brg24 = (uint8_t*)AlignedMalloc(RGB24DataSize(m_dest_cap_height, m_dest_cap_width, (m_dest_cap_width+1)/2, (m_dest_cap_width + 1) / 2), kBufferAlignment);
@@ -373,16 +370,16 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 	int conversionResult = libyuv::ConvertToI420(videoFrame, videoFrameLength,
 		m_i420,
 		stride_y,
-		m_i420 + stride_y * m_in_cap_height,
+		m_i420 + stride_y * height,
 		stride_u,
-		m_i420 + stride_y * m_in_cap_height + stride_u * ((m_in_cap_height + 1) / 2),
+		m_i420 + stride_y * height + stride_u * ((height + 1) / 2),
 		stride_v,
 		0, 
-		(height - m_in_cap_height) / 2,  // No Cropping
+		0,  // No Cropping
 		width, 
 		height,
 		width,
-		m_in_cap_height,
+		height,
 		libyuv::kRotate180,
 		ConvertVideoType(frameInfo.videoType)
 	);
@@ -397,27 +394,27 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 	//{
 	//	video_frame frmi420 = { 0 };
 	//	frmi420.data[0] = m_i420;
-	//	frmi420.linesize[0] = m_in_cap_height * 3 / 2;
-	//	frmi420.width = m_in_cap_width;
-	//	frmi420.height = m_in_cap_height;
+	//	frmi420.linesize[0] = m_dest_cap_width * 3 / 2;
+	//	frmi420.width = m_dest_cap_width;
+	//	frmi420.height = m_dest_cap_height;
 	//	frmi420.format = VIDEO_FORMAT_I420;
 	//	//m_capture->param.on_frame_i420(m_capture->param.user_data, &frmi420);
 	//	char stroptname[260] = { 0 };
-	//	snprintf(stroptname, 260, "%d_%d_%d_%d_i420.bmp", m_ilogcount, (int)m_rotate, m_in_cap_width, m_in_cap_height);
+	//	snprintf(stroptname, 260, "%d_%d_%d_%d_i420.bmp", m_ilogcount, (int)m_rotate, m_dest_cap_width, m_dest_cap_height);
 	//	video_frame_save_bmpfile(stroptname, &frmi420);
 	//}
 
 	if (libyuv::kRotate0 == m_rotate || libyuv::kRotate180 == m_rotate){
 		conversionResult = libyuv::ConvertFromI420(m_i420,
 					stride_y,
-					m_i420 + stride_y * m_in_cap_height,
+					m_i420 + stride_y * m_capture_height,
 					stride_u,
-					m_i420 + stride_y * m_in_cap_height + stride_u * ((m_in_cap_height + 1) / 2),
+					m_i420 + stride_y * m_capture_height + stride_u * ((m_capture_height + 1) / 2),
 					stride_v,
 					m_rgb24,
-					m_out_cap_width * 3,
-					m_out_cap_width,
-					m_out_cap_height,
+					m_dest_cap_width * 3,
+					m_dest_cap_width,
+					m_dest_cap_height,
 					ConvertVideoType(kRGB24));
 		if (conversionResult < 0) {
 			if (m_callback) {
@@ -432,24 +429,24 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 			if (libyuv::kRotate90 == m_rotate) {
 				erotate = libyuv::kRotate270;
 			}
-			int opt_stride_y = m_out_cap_width;
-			int opt_stride_u = (m_out_cap_width + 1) / 2;
-			int opt_stride_v = (m_out_cap_width + 1) / 2;
+			int opt_stride_y = m_dest_cap_width;
+			int opt_stride_u = (m_dest_cap_width + 1) / 2;
+			int opt_stride_v = (m_dest_cap_width + 1) / 2;
 			//uint8_t* iopt420 = (uint8_t*)AlignedMalloc(I420DataSize(m_dest_cap_height, opt_stride_y, opt_stride_u, opt_stride_v), kBufferAlignment);
 			int rotateResult = libyuv::I420Rotate(m_i420,
 				stride_y,
-				m_i420 + stride_y * m_in_cap_height,
+				m_i420 + stride_y * height,
 				stride_u,
-				m_i420 + stride_y * m_in_cap_height + stride_u * ((m_in_cap_height + 1) / 2),
+				m_i420 + stride_y * height + stride_u * ((height + 1) / 2),
 				stride_v,
 				m_opti420,
 				opt_stride_y,
-				m_opti420 + opt_stride_y * m_out_cap_height,
+				m_opti420 + opt_stride_y * m_dest_cap_height,
 				opt_stride_u,
-				m_opti420 + opt_stride_y * m_out_cap_height + opt_stride_u * ((m_out_cap_height + 1) / 2),
+				m_opti420 + opt_stride_y * m_dest_cap_height + opt_stride_u * ((m_dest_cap_height + 1) / 2),
 				opt_stride_v,
-				m_in_cap_width,
-				m_in_cap_height,
+				width,
+				height,
 				erotate);
 
 			if (rotateResult < 0) {
@@ -462,27 +459,27 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 			//{
 			//	video_frame frmi420 = { 0 };
 			//	frmi420.data[0] = m_opti420;
-			//	frmi420.linesize[0] = m_out_cap_width * 3 / 2;
-			//	frmi420.width = m_out_cap_width;
-			//	frmi420.height = m_out_cap_height;
+			//	frmi420.linesize[0] = m_dest_cap_width * 3 / 2;
+			//	frmi420.width = m_dest_cap_width;
+			//	frmi420.height = m_dest_cap_height;
 			//	frmi420.format = VIDEO_FORMAT_I420;
 			//	//m_capture->param.on_frame_i420(m_capture->param.user_data, &frmi420);
 			//	char stroptname[260] = { 0 };
-			//	snprintf(stroptname, 260, "%d_%d_%d_%d_i420.bmp", m_ilogcount, (int)m_rotate, m_out_cap_width, m_out_cap_height);
+			//	snprintf(stroptname, 260, "%d_%d_%d_%d_i420.bmp", m_ilogcount, (int)m_rotate, m_dest_cap_width, m_dest_cap_height);
 			//	video_frame_save_bmpfile(stroptname, &frmi420);
 			//}
 			//yu12_to_dib24(brg24, iopt420, m_dest_cap_width, m_dest_cap_height);
 
 			conversionResult = libyuv::ConvertFromI420(m_opti420,
 				opt_stride_y,
-				m_opti420 + opt_stride_y * m_out_cap_height,
+				m_opti420 + opt_stride_y * m_dest_cap_height,
 				opt_stride_u,
-				m_opti420 + opt_stride_y * m_out_cap_height + opt_stride_u * ((m_out_cap_height + 1) / 2),
+				m_opti420 + opt_stride_y * m_dest_cap_height + opt_stride_u * ((m_dest_cap_height + 1) / 2),
 				opt_stride_v,
 				m_rgb24,
-				m_out_cap_width * 3,
-				m_out_cap_width,
-				m_out_cap_height,
+				m_dest_cap_width * 3,
+				m_dest_cap_width,
+				m_dest_cap_height,
 				ConvertVideoType(kRGB24));
 				
 			if (conversionResult < 0) {
@@ -499,14 +496,14 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 	if (NULL != m_capture->param.on_frame) {
 		video_frame frm = { 0 };
 		frm.data[0] = m_rgb24;
-		frm.linesize[0] = m_out_cap_width * 3;
-		frm.width = m_out_cap_width;
-		frm.height = m_out_cap_height;
+		frm.linesize[0] = m_dest_cap_width * 3;
+		frm.width = m_dest_cap_width;
+		frm.height = m_dest_cap_height;
 		frm.format = VIDEO_FORMAT_RGB24;
 
 		m_capture->param.on_frame(m_capture->param.user_data, &frm);
 		//char strrgbname[260] = { 0 };
-		//snprintf(strrgbname, 260, "%d_%d_%d_%d_rgb.bmp", m_ilogcount, (int)m_rotate, m_out_cap_width, m_out_cap_height);
+		//snprintf(strrgbname, 260, "%d_%d_%d_%d_rgb.bmp", m_ilogcount, (int)m_rotate, m_dest_cap_width, m_dest_cap_height);
 		//video_frame_save_bmpfile(strrgbname, &frm);
 		//m_ilogcount++;
 	}
@@ -607,8 +604,8 @@ static void* VideoCaptureProcess(void *arg)
 int VideoCaptureImpl::StartVideoCapture()
 {	
 	if (m_bCaptureStarted){
-		if (m_real_cap_width == mode_width[m_capture->param.cap_mode] &&
-			m_real_cap_height == mode_height[m_capture->param.cap_mode] &&
+		if (m_capture_width == mode_width[m_capture->param.cap_mode] &&
+			m_capture_height == mode_height[m_capture->param.cap_mode] &&
 			m_frame_fmt == m_capture->param.frame_fmt){
 			return 0;
 		}
@@ -724,10 +721,10 @@ int VideoCaptureImpl::StartVideoCapture()
 		else
 		{
 			// initialize current width and height
-			m_real_cap_width = video_fmt.fmt.pix.width;
-			m_real_cap_height = video_fmt.fmt.pix.height;
+			m_capture_width = video_fmt.fmt.pix.width;
+			m_capture_height = video_fmt.fmt.pix.height;
 			if (m_callback){
-				m_callback->Debug("real camera capture m_capture_width = %d, m_capture_height = %d.", m_real_cap_width, m_real_cap_height);
+				m_callback->Debug("real camera capture m_capture_width = %d, m_capture_height = %d.", m_capture_width, m_capture_height);
 			}
 		}
 	}
@@ -780,7 +777,7 @@ int VideoCaptureImpl::StartVideoCapture()
 	// If driver doesn't support framerate control, need to hardcode.
 	// Hardcoding the value based on the frame size.
 	if (!driver_framerate_support) {
-		if (m_in_cap_width >= 800 && m_captureVideoType != VideoType::kMJPEG) {
+		if (m_capture_width >= 800 && m_captureVideoType != VideoType::kMJPEG) {
 			m_currentFrameRate = 15;
 		}
 		else {
@@ -916,17 +913,17 @@ bool VideoCaptureImpl::DeAllocateVideoBuffers()
 bool VideoCaptureImpl::AlignedMallocVideoBuffer()
 {
 	bool bret = false;
-	int stride_y = m_in_cap_width;
-	int stride_u = (m_in_cap_width + 1) / 2;
-	int stride_v = (m_in_cap_width + 1) / 2;
+	int stride_y = m_capture_width;
+	int stride_u = (m_capture_width + 1) / 2;
+	int stride_v = (m_capture_width + 1) / 2;
 
-	m_i420 = (uint8_t*)AlignedMalloc(I420DataSize(m_in_cap_height, stride_y, stride_u, stride_v), kBufferAlignment);
-	m_rgb24 = (uint8_t*)AlignedMalloc(RGB24DataSize(m_out_cap_height, m_out_cap_width, (m_out_cap_width + 1) / 2, (m_out_cap_width + 1) / 2), kBufferAlignment);
+	m_i420 = (uint8_t*)AlignedMalloc(I420DataSize(m_capture_height, stride_y, stride_u, stride_v), kBufferAlignment);
+	m_rgb24 = (uint8_t*)AlignedMalloc(RGB24DataSize(m_dest_cap_height, m_dest_cap_width, (m_dest_cap_width + 1) / 2, (m_dest_cap_width + 1) / 2), kBufferAlignment);
 
-	int opt_stride_y = m_out_cap_width;
-	int opt_stride_u = (m_out_cap_width + 1) / 2;
-	int opt_stride_v = (m_out_cap_width + 1) / 2;
-	m_opti420 = (uint8_t*)AlignedMalloc(I420DataSize(m_out_cap_height, opt_stride_y, opt_stride_u, opt_stride_v), kBufferAlignment);
+	int opt_stride_y = m_dest_cap_width;
+	int opt_stride_u = (m_dest_cap_width + 1) / 2;
+	int opt_stride_v = (m_dest_cap_width + 1) / 2;
+	m_opti420 = (uint8_t*)AlignedMalloc(I420DataSize(m_dest_cap_height, opt_stride_y, opt_stride_u, opt_stride_v), kBufferAlignment);
 
 	if (m_i420 && m_rgb24 && m_opti420){
 		bret = true;
@@ -980,12 +977,12 @@ VideoType VideoCaptureImpl::GetCaptureVideoType()
 
 int VideoCaptureImpl::GetCapture_Width()
 {
-	return m_real_cap_width;
+	return m_capture_width;
 }
 
 int VideoCaptureImpl::GetCapture_Height()
 {
-	return m_real_cap_height;
+	return m_capture_height;
 }
 
 bool VideoCaptureImpl::GetStopCaptureFlag()

+ 4 - 10
Other/libvideocapture/linux/videocapture_linux.h

@@ -95,16 +95,10 @@ private:
 	int m_deviceFd;
 
 	int m_frame_fmt;
-	
-	int m_in_cap_width;
-	int m_in_cap_height;
-
-	int m_real_cap_width;
-	int m_real_cap_height;
-	
-	int m_out_cap_width;
-	int m_out_cap_height;
-
+	int m_capture_width;
+	int m_capture_height;
+	int m_dest_cap_width;
+	int m_dest_cap_height;
 	libyuv::RotationMode m_rotate;
 	VideoType m_captureVideoType;
 	int m_currentFrameRate;

+ 2 - 2
Other/libvideorender/CMakeLists.txt

@@ -12,8 +12,8 @@ endif(RVC_DEBUG_MODE)
 set(${MODULE_PREFIX}_SRCS
     ivideorenderinterface.h
 	ivideorenderinterface.cpp
-	libvideorender.h
-	libvideorender.cpp
+	./linux/videorender_linux.h
+	./linux/videorender_linux.cpp
 )
 
 add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})

+ 1 - 1
Other/libvideorender/ivideorenderinterface.cpp

@@ -1,5 +1,5 @@
 #include "ivideorenderinterface.h"
-#include "libvideorender.h"
+#include "./linux/videorender_linux.h"
 
 
 IVideoRender* CreateVideoRenderObj(IRenderCallback* pCallback)

+ 1 - 8
Other/libvideorender/ivideorenderinterface.h

@@ -14,13 +14,6 @@
 
 #include <stdint.h>
 
-typedef enum
-{
-	RVC_FLIP_NONE = 0x00000000,     /**< Do not flip */
-	RVC_FLIP_HORIZONTAL = 0x00000001,    /**< flip horizontally */
-	RVC_FLIP_VERTICAL = 0x00000002     /**< flip vertically */
-} RVC_RendererFlip;
-
 struct video_frame;
 
 typedef struct videorender_param_s {
@@ -51,7 +44,7 @@ public:
 	virtual void VideoRenderDestroy() = 0;
 	virtual int ShowVideoWindow() = 0;
 	virtual int HideVideoWindow() = 0;
-	virtual int RenderVideoFrame(video_frame* pframe, RVC_RendererFlip eFlipType = RVC_FLIP_NONE) = 0;
+	virtual int RenderVideoFrame(video_frame* pframe) = 0;
 };
 
 

+ 36 - 143
Other/libvideorender/libvideorender.cpp → Other/libvideorender/linux/videorender_linux.cpp

@@ -1,15 +1,5 @@
-#include"libvideorender.h"
-#include "../libvideoframework/videoutil.h"
-
-
-//Refresh Event
-#ifndef REFRESH_EVENT
-#define REFRESH_EVENT  (SDL_USEREVENT + 1)
-#endif
-
-#ifndef RVC_DEFAULT_DELAY_TIME
-#define RVC_DEFAULT_DELAY_TIME 5
-#endif
+#include"videorender_linux.h"
+#include "../../libvideoframework/videoutil.h"
 
 
 VideoRenderImpl::VideoRenderImpl(IRenderCallback* pCallback)
@@ -18,7 +8,6 @@ VideoRenderImpl::VideoRenderImpl(IRenderCallback* pCallback)
 	m_rending_texture = NULL;
 	m_renderer = NULL;
 	m_callback = pCallback;
-	m_refresh_flag = false;
 
 	m_cx = SDL_WINDOWPOS_UNDEFINED;
 	m_cy = SDL_WINDOWPOS_UNDEFINED;
@@ -26,6 +15,7 @@ VideoRenderImpl::VideoRenderImpl(IRenderCallback* pCallback)
 	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 | SDL_WINDOW_POPUP_MENU;
+	m_convertbuffer = NULL;
 }
 
 
@@ -45,6 +35,11 @@ VideoRenderImpl::~VideoRenderImpl()
 		SDL_DestroyWindow(m_sdl_window);
 		m_sdl_window = NULL;
 	}
+
+	if (NULL != m_convertbuffer){
+		delete []m_convertbuffer;
+		m_convertbuffer = NULL;
+	}
 		
 	SDL_Quit();
 }
@@ -74,6 +69,10 @@ int VideoRenderImpl::SetWindowProperty(videorender_param_t* tparam)
 
 	m_videoformat = tparam->ivideoformat;
 
+	if (VIDEO_FORMAT_RGB24 == m_videoformat){
+		m_convertbuffer = new unsigned char[m_videowidth* m_videoheight*4];
+	}
+
 	iRet = 0;
 
 	return iRet;
@@ -230,87 +229,14 @@ int VideoRenderImpl::VideoRenderSetParam(videorender_param_t* tparam)
 }
 
 
-static int refresh_video(void *opaque)
-{
-	VideoRenderImpl* pImpl = (VideoRenderImpl*)opaque;
-	while (pImpl->GetReFreshFlag()) {
-		SDL_Event event;
-		event.type = REFRESH_EVENT;
-		SDL_PushEvent(&event);
-		SDL_Delay(RVC_DEFAULT_DELAY_TIME);
-	}
-	return 0;
-}
-
-
-static SDL_HitTestResult SDLCALL
-	SDL_HitTestCallback(SDL_Window *win, const SDL_Point *area, void *data)
-{
-	int w, h;
-	const int RESIZE_BORDER = 8;
-	const int DRAGGABLE_TITLE = 32;
-
-	VideoRenderImpl* pImpl = (VideoRenderImpl*)data;
-
-	SDL_GetWindowSize(win, &w, &h);
-
-	if (area->x < RESIZE_BORDER) {
-		if (area->y < RESIZE_BORDER) {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_TOPLEFT");
-			return SDL_HITTEST_RESIZE_TOPLEFT;
-		} else if (area->y >= (h-RESIZE_BORDER)) {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_BOTTOMLEFT");
-			return SDL_HITTEST_RESIZE_BOTTOMLEFT;
-		} else {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_LEFT");
-			return SDL_HITTEST_RESIZE_LEFT;
-		}
-	} else if (area->x >= (w-RESIZE_BORDER)) {
-		if (area->y < RESIZE_BORDER) {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_TOPRIGHT");
-			return SDL_HITTEST_RESIZE_TOPRIGHT;
-		} else if (area->y >= (h-RESIZE_BORDER)) {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_BOTTOMRIGHT");
-			return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
-		} else {
-			pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_RIGHT");
-			return SDL_HITTEST_RESIZE_RIGHT;
-		}
-	} else if (area->y >= (h-RESIZE_BORDER)) {
-		pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_BOTTOM");
-		return SDL_HITTEST_RESIZE_BOTTOM;
-	} else if (area->y < RESIZE_BORDER) {
-		pImpl->GetCallBack()->Debug("SDL_HITTEST_RESIZE_TOP");
-		return SDL_HITTEST_RESIZE_TOP;
-	} else if (area->y < DRAGGABLE_TITLE) {
-		pImpl->GetCallBack()->Debug("SDL_HITTEST_DRAGGABLE");
-		return SDL_HITTEST_DRAGGABLE;
-	}
-	return SDL_HITTEST_NORMAL;
-}
-
-IRenderCallback* VideoRenderImpl::GetCallBack()
-{
-	return m_callback;
-}
-
-bool VideoRenderImpl::GetReFreshFlag()
-{
-	return m_refresh_flag;
-}
-
 int VideoRenderImpl::StartVideoRender()
 {
-	m_refresh_flag = true;
-	m_refresh_thread = SDL_CreateThread(refresh_video,"refresh video thread", this);
-	SDL_SetWindowHitTest(m_sdl_window, SDL_HitTestCallback, this);
 	return 0;
 }
 
 int VideoRenderImpl::ShowVideoWindow()
 {
 	int iret = -1;
-
 	if (NULL != m_sdl_window){
 		SDL_ShowWindow(m_sdl_window);
 		iret = 0;
@@ -332,11 +258,6 @@ int VideoRenderImpl::HideVideoWindow()
 int VideoRenderImpl::StopVideoRender()
 {
 	HideVideoWindow();
-	
-	m_refresh_flag = false;
-
-	SDL_WaitThread(m_refresh_thread, NULL);
-
 	return 0;
 }
 
@@ -347,67 +268,39 @@ void VideoRenderImpl::VideoRenderDestroy()
 }
 
 
-int VideoRenderImpl::RenderVideoFrame(video_frame* pframe, RVC_RendererFlip eFlipType)
+int VideoRenderImpl::RenderVideoFrame(video_frame* pframe)
 {
 	int iret = -1;
 	if (NULL == m_sdl_window || NULL == pframe || NULL == m_renderer || NULL == m_rending_texture){
 		return iret;
 	}
 
-	
-	//SDL_Event ev;
-	//while(SDL_PollEvent(&ev)){
-	//	switch(ev.type)
-	//	{
-	//	case SDL_MOUSEBUTTONDOWN:
-	//		m_callback->Debug("%s:%d SDL_MOUSEBUTTONDOWN", __FUNCTION__, __LINE__);
-	//		break;
-
-	//	case SDL_MOUSEBUTTONUP:
-	//		m_callback->Debug("%s:%d SDL_MOUSEBUTTONUP", __FUNCTION__, __LINE__);
-	//		break;
-
-	//	}
-	//}
-
-	SDL_Event event;
-	SDL_WaitEvent(&event);
-
-	if(REFRESH_EVENT == event.type){
-		SDL_SetRenderDrawColor(m_renderer, 0, 0, 0, 255); /*black*/
-		SDL_RenderClear(m_renderer);
-
-		/* 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)
-		*/
-		//SDL_QueryTexture()
-
-		if (VIDEO_FORMAT_RGB24 == pframe->format || VIDEO_FORMAT_I420 == pframe->format){
-			if (VIDEO_FORMAT_RGB24 == pframe->format){
-				SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width*3);
-			}
-			else{
-				SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width);
-			}
-		
-			if (RVC_FLIP_NONE == eFlipType){
-				SDL_RenderCopy(m_renderer, m_rending_texture, NULL, NULL);
-			}
-			else{
-				SDL_Point point = {m_videowidth/2, m_videoheight/2};
-				SDL_RenderCopyEx(m_renderer, m_rending_texture, NULL, NULL, 0, &point, (SDL_RendererFlip)eFlipType);
-			}
-		}
-		else{
-			m_callback->Debug("%s:%d not support format, return", __FUNCTION__, __LINE__);
-			return iret;
-		}
+	SDL_SetRenderDrawColor(m_renderer, 0, 0, 0, 255); /*black*/
+	SDL_RenderClear(m_renderer);
 
-		SDL_RenderPresent(m_renderer);
+	/* 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)
+	 */
+	//SDL_QueryTexture()
 
-		SDL_Delay(RVC_DEFAULT_DELAY_TIME);
+	if (VIDEO_FORMAT_RGB24 == pframe->format){
+		//ConVert24to32(pframe->data[0], m_convertbuffer, pframe->width, pframe->height);
+		SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width*3);
+		SDL_Point point = {m_videowidth/2, m_videoheight/2};
+		SDL_RenderCopyEx(m_renderer, m_rending_texture, NULL, NULL, 0, &point, SDL_FLIP_VERTICAL);
 	}
+	else if(VIDEO_FORMAT_I420 == pframe->format){
+		SDL_UpdateTexture(m_rending_texture, NULL, pframe->data[0], pframe->width);
+		SDL_RenderCopy(m_renderer, m_rending_texture, NULL, NULL);
+	}
+	else
+	{
+		m_callback->Debug("%s:%d not support format, return", __FUNCTION__, __LINE__);
+		return iret;
+	}
+
+	SDL_RenderPresent(m_renderer);
 
 	iret = 0;
 

+ 4 - 6
Other/libvideorender/libvideorender.h → Other/libvideorender/linux/videorender_linux.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "ivideorenderinterface.h"
+#include "../ivideorenderinterface.h"
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_video.h>
 #include <SDL2/SDL_render.h>
@@ -20,21 +20,19 @@ public:
 	void VideoRenderDestroy();
 	int ShowVideoWindow();
 	int HideVideoWindow();
-	int RenderVideoFrame(video_frame* pframe, RVC_RendererFlip eFlipType = RVC_FLIP_NONE);
+	int RenderVideoFrame(video_frame* pframe);
 
 	int SetWindowProperty(videorender_param_t* tparam);
 	SDL_PixelFormatEnum GetPixelFormat();
 	void ConVert24to32(unsigned char* image_in, unsigned char* image_out, int w, int h);
-	IRenderCallback* GetCallBack();
-	bool GetReFreshFlag();
+
 
 private:
 	SDL_Window* m_sdl_window;
 	SDL_Texture* m_rending_texture;
 	SDL_Renderer* m_renderer;
 	IRenderCallback* m_callback;
-	SDL_Thread *m_refresh_thread;
-	bool m_refresh_flag;
+	unsigned char* m_convertbuffer;
 
 	int m_cx;
 	int m_cy;