Procházet zdrojové kódy

Z991239-1781 #comment other 优化opt摄像头采集功能

陈礼鹏80274480 před 4 roky
rodič
revize
9f4912aa90

+ 47 - 23
Module/mod_mediacontroller/capture.cpp

@@ -6,8 +6,6 @@
 #include "../../Other/libvideohorflip/videohorflip.h"
 #include "../../Other/libvideoframework/video_common/ffmpeg_api_cpp_adapter.h"
 #else
-
-
 #endif // RVC_OS_WIN
 
 #include <locale.h>
@@ -571,11 +569,11 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 
 	rc = video_shm_enqueue(video_cap->snapshot_shm_queue, frame, VIDEOQUEUE_FLAG_VERTICAL_FLIP);
 
-	static int isnapshot_shm_queue = 0;
-	if (isnapshot_shm_queue == 0) {
-		video_frame_save_bmpfile("snapshot_shm_queue_1.bmp", frame);
-		isnapshot_shm_queue++;
-	}
+	//static int isnapshot_shm_queue = 0;
+	//if (isnapshot_shm_queue == 0) {
+	//	video_frame_save_bmpfile("snapshot_shm_queue_1.bmp", frame);
+	//	isnapshot_shm_queue++;
+	//}
 
 	if (rc != Error_Succeed) 
 	{
@@ -593,6 +591,7 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 #ifdef RVC_OS_WIN
 			InterlockedDecrement(cap->config.ref_env_capture_count);
 #else
+			__sync_fetch_and_sub(cap->config.ref_env_capture_count, 1);
 #endif
 			LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_ENV, "agent capture env ok, and capture env finished!");
 		} 
@@ -602,7 +601,7 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 #ifdef RVC_OS_WIN
 			_InterlockedAnd(cap->config.ref_envopt_capture_count, 0xfffffffD);
 #else
-
+			__sync_fetch_and_add(cap->config.ref_env_capture_count, 0xfffffffD);
 #endif // RVC_OS_WIN
 
 			if (*cap->config.ref_envopt_capture_count == 0) 
@@ -624,15 +623,17 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 			Dbg("preview_shm_queue enqueue failed, error = %d", rc);
 		}
 		else {
-			//Dbg("preview_shm_queue enqueue[%d] success, and current video queue len is %d.", video_cap->frame_id, video_cap->preview_shm_queue->GetVideoLens());
+			//if (0 == video_cap->frame_id%10){
+			//	Dbg("preview_shm_queue enqueue[%d] success, and current video queue len is %d.", video_cap->frame_id, video_cap->preview_shm_queue->GetVideoLens());
+			//}
 		}
 		video_frame_free(&preview_frame);
 
-		static int ipreview_shm_queue = 0;
-		if (ipreview_shm_queue == 0) {
-			video_frame_save_bmpfile("preview_shm_queue_1.bmp", frame);
-			ipreview_shm_queue++;
-		}
+		//static int ipreview_shm_queue = 0;
+		//if (ipreview_shm_queue == 0) {
+		//	video_frame_save_bmpfile("preview_shm_queue_1.bmp", frame);
+		//	ipreview_shm_queue++;
+		//}
 	}
 	// rtp
 	{
@@ -649,11 +650,11 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 		//	Dbg("rtp_shm_queue enqueue success!");
 		//}
 
-		/*static*/ int irtp_frame = 0;
-		if (irtp_frame == 0){
-			video_frame_save_bmpfile("rtp_shm_queue.bmp", &rtp_frame);
-			irtp_frame++;
-		}
+		//static int irtp_frame = 0;
+		//if (irtp_frame == 0){
+		//	video_frame_save_bmpfile("rtp_shm_queue.bmp", &rtp_frame);
+		//	irtp_frame++;
+		//}
 		
 #if 0
 		static int i = 0;
@@ -741,22 +742,38 @@ static void opt_cap_on_frame(void *user_data, video_frame *frame)
 	{
 		Dbg("opt snapshot queue enqueue shm failed! Error = %d, camera_type=%d", rc, video_cap->camera_type);
 	}
-	//else {
-	//	Dbg("opt snapshot queue enqueue success!" );
+	else {
+		//Dbg("opt snapshot queue enqueue[%d] success, and current video queue len is %d.", video_cap->frame_id, video_cap->snapshot_shm_queue->GetVideoLens());
+	}
+
+	//static int isnapshot_shm_queue = 0;
+	//if (isnapshot_shm_queue == 0) {
+	//	video_frame_save_bmpfile("opt_snapshot_shm_queue.bmp", &rframe);
+	//	isnapshot_shm_queue++;
 	//}
+
 	// snapshot
 	if (rc==Error_Succeed)
 	{
 		if (*cap->config.ref_opt_capture_count) 
 		{
 			Dbg("opt camera ref_opt_capture_count=%d",*cap->config.ref_opt_capture_count);
+#ifdef RVC_OS_WIN
 			InterlockedDecrement(cap->config.ref_opt_capture_count);
+#else
+			__sync_fetch_and_sub(cap->config.ref_opt_capture_count, 1);
+#endif
 			LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_OPT, "agent capture opt ok, and capture opt finished!");
 		} 
 		else if (*cap->config.ref_envopt_capture_count&1) 
 		{
 			Dbg("opt camera ref_envopt_capture_count=%d",*cap->config.ref_envopt_capture_count);
+#ifdef RVC_OS_WIN
 			if (InterlockedDecrement(cap->config.ref_envopt_capture_count) == 0) 
+#else
+			__sync_fetch_and_sub(cap->config.ref_envopt_capture_count,1);
+			if (0 == cap->config.ref_envopt_capture_count)
+#endif
 			{
 				LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_ENVOPT, "agent capture opt ok, and capture envopt finished!");
 			}
@@ -772,9 +789,16 @@ static void opt_cap_on_frame(void *user_data, video_frame *frame)
 		{
 			Dbg("rtp_shm_queue enqueue shm failed! Error = %d, camera_type=%d", rc, video_cap->camera_type);
 		}
-		//else {
-		//	Dbg("rtp_shm_queue enqueue success!");
+		else {
+			//Dbg("opt rtp_shm_queue enqueue[%d] success, and current video queue len is %d.", video_cap->frame_id, video_cap->rtp_shm_queue->GetVideoLens());
+		}
+
+		//static int irtp_frame = 0;
+		//if (irtp_frame == 0){
+		//	video_frame_save_bmpfile("opt_rtp_shm_queue.bmp", &rtp_frame);
+		//	irtp_frame++;
 		//}
+
 		video_frame_free(&rtp_frame);
 	}
 

+ 5 - 5
Module/mod_sipphone/video_session.cpp

@@ -450,11 +450,11 @@ static int on_rx_frame(video_frame *frame, void *user_data)
 		}
 	}
 #else
-	/*static*/ int icount = 0;
-	if (icount == 0){
-		video_frame_save_bmpfile("remote_test.bmp", frame);
-		//icount++;
-	}
+	//static int icount = 0;
+	//if (icount == 0){
+	//	video_frame_save_bmpfile("remote_test.bmp", frame);
+	//	icount++;
+	//}
 	if (NULL != session->premote_render){
 		//Dbg("session plocal_render RenderVideoFrame");
 		video_frame* echoframe = NULL;

+ 10 - 10
Other/libvideoframework/videortp.c

@@ -408,11 +408,11 @@ static int decoder_process(videortp_t *vrtp, uint8_t *input_buf, int input_len){
 			}
 
 			//rtpDbg(vrtp, "%s:%d: decodered_frame->format = %d", __FILE__, __LINE__, decodered_frame->format);
-			static int icount = 0;
-			if (icount == 0) {
-				video_frame_save_bmpfile("formattest.bmp", decodered_frame);
-				icount++;
-			}
+			//static int icount = 0;
+			//if (icount == 0) {
+			//	video_frame_save_bmpfile("formattest.bmp", decodered_frame);
+			//	icount++;
+			//}
 		}
 
 		//notify render
@@ -2330,11 +2330,11 @@ int videortp_send_yuvframe(videortp_t *vrtp, const video_frame *vframe)
 {
 	videortp_send_frame(vrtp, vframe);
 
-	static int itest = 0;
-	if (itest == 0) {
-		video_frame_save_bmpfile("videortp_send_yuvframe.bmp", vframe);
-		itest++;
-	}
+	//static int itest = 0;
+	//if (itest == 0) {
+	//	video_frame_save_bmpfile("videortp_send_yuvframe.bmp", vframe);
+	//	itest++;
+	//}
 
 	return 0;
 }