Răsfoiți Sursa

Z991239-2175 #comment fix: 优化连线过程存在内存使用过多问题

陈礼鹏80274480 4 ani în urmă
părinte
comite
512e102829

+ 9 - 7
Module/mod_sipphone/video_session.cpp

@@ -428,8 +428,8 @@ static int on_rx_frame(video_frame *frame, void *user_data)
 					Dbg("eStand2sType record call mod insert remote video to queue failed.");
 				}
 				video_frame_delete(recordframe);
+				recordframe = NULL;
 			}
-			recordframe = NULL;
 		}
 		else {
 			int rc = video_shm_enqueue(session->video_shm_q_remote, frame, VIDEOQUEUE_FLAG_VERTICAL_FLIP);
@@ -467,6 +467,7 @@ static int on_rx_frame(video_frame *frame, void *user_data)
 			session->premote_render->RenderVideoFrame(frame);
 			session->bshow_remote = true;
 		}
+		used = 1;
 	}
 
 #endif
@@ -966,9 +967,10 @@ int show_agent_picture_proc(void *arg)
 				video_frame_fill_black(showframe);
 				video_frame_copy(showframe, t_record->show_frame);
 
-				int iused = on_rx_frame(showframe, t_record->session);
-				if (0 == iused){
+				on_rx_frame(showframe, t_record->session);
+				if (NULL != showframe){
 					video_frame_delete(showframe);
+					showframe = NULL;
 				}
 			}
 		} 
@@ -2245,7 +2247,7 @@ void* videorender_func(void* arg)
 						session->plocal_render->RenderVideoFrame(local_video_frame);
 					}
 					bshow_local = true;
-					delete local_video_frame;
+					video_frame_delete(local_video_frame);
 					local_video_frame = NULL;
 				}
 				else {
@@ -2323,8 +2325,7 @@ static int start_ui(video_session_t *session)
 		Dbg("%s:%d create ui stop event failed!", __FUNCTION__, __LINE__);
 		return Error_Resource;
 	}
-	else
-	{
+	else{
 		Dbg("%s:%d create ui stop event success!", __FUNCTION__, __LINE__);
 	}
 	int err = pthread_create(&session->ui_threadid, NULL, videorender_func, session);
@@ -2398,7 +2399,8 @@ static void stop_ui(video_session_t *session)
 	sem_post(&session->ui_stop_sem);
 	if (session->ui_threadid > 0) {
 		if (0 == pthread_join(session->ui_threadid, NULL)){
-			Dbg("video render thread pthread join success.");
+			Dbg("video render thread %u pthread join success.", session->ui_threadid);
+			session->ui_threadid = 0;
 		}
 		else{
 			Dbg("video render thread pthread join error for %s", strerror(errno));

+ 0 - 1
Other/libvideoframework/videoclock.c

@@ -146,7 +146,6 @@ void* local_video_sendfunc(void* param)
 	video_frame frame;
 	int dwTimeout = 1000/clock->fps_num;
 
-
 	if (video_frame_alloc(clock->frame_width, clock->frame_height, clock->frame_format, &frame) != 0){
 		goto on_error;
 	}

+ 15 - 17
Other/libvideoframework/videortp.c

@@ -371,7 +371,7 @@ static int decoder_process(videortp_t *vrtp, uint8_t *input_buf, int input_len){
 
 	//decode
 	while (input_len > 0) {
-		video_frame *decodered_frame;
+		video_frame *decodered_frame = NULL;
 		int key_frame = 0;
 		video_debug_write_play_file(AUDIO_DEC_IN, input_buf, input_len);
 
@@ -406,22 +406,23 @@ static int decoder_process(videortp_t *vrtp, uint8_t *input_buf, int input_len){
 				video_debug_write_play_file(VIDEO_RENDER_IN, video_debug_buf, length);
 				free(video_debug_buf);
 			}
-
-			//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++;
-			//}
 		}
 
 		//notify render
 		before_render_ms = TimeInMilliseconds();
 		if(vrtp->config.on_rx_frame){
-			vrtp->config.on_rx_frame(decodered_frame, vrtp->config.user_data);
+			int iret = vrtp->config.on_rx_frame(decodered_frame, vrtp->config.user_data);
+			if (1 == iret){
+#ifdef _WIN32
+#else
+				video_frame_delete(decodered_frame);
+				decodered_frame = NULL;
+#endif
+			}
 		}else {
 			//render is null, we need delete self.
 			video_frame_delete(decodered_frame);
+			decodered_frame = NULL;
 		}
 		after_render_ms = TimeInMilliseconds();
 		video_stats_receiver_on_rendered_frame(after_render_ms, after_render_ms - before_render_ms);
@@ -1174,14 +1175,13 @@ void* recv_proc(void* arg)
 		{
 			int n;
 			{
+#ifdef _WIN32
 				unsigned rtcp_flags = 0;
 				int result = rtp_session_recv_rtcp(vrtp->rtp_sess, &rtcp_flags);
-#ifdef _WIN32
 				if (result >= 0) {
 					receiver_process_rtcp_packet(vrtp, rtcp_flags);
 				}
 #endif
-
 			}
 			do {
 				unsigned short seq = 0;
@@ -1238,9 +1238,7 @@ void* recv_proc(void* arg)
 						//注意,cc中的ts是以真实时间毫秒为单位,rtp的时间戳是90000为1秒,这里需要转换
 						seg.timestamp = (send_time == 0 ? (ts / (VIDEO_CLOCK / 1000)) : send_time);
 						seg.data_size = n;
-						rtpDbg(vrtp, "%s:%d ", __FUNCTION__, __LINE__);
 						sim_recv_video(&seg);
-						rtpDbg(vrtp, "%s:%d ", __FUNCTION__, __LINE__);
 					}
 #endif
 
@@ -1254,10 +1252,10 @@ void* recv_proc(void* arg)
 						receiver_process_standard_h264_packet(vrtp, part_data, n, seq, mark, ts, pt);
 					}
 					rtp_timeout_cnt = 0;
-				} else {
+				} 
+				else {
 					rtpframe_part_destroy(vrtp, part_data);
 				}
-
 			} while (n > 0);
 
 			{
@@ -2244,11 +2242,11 @@ void videortp_stop(videortp_t* vrtp)
 		sem_post(&vrtp->sem_evt);
 		if (0 != vrtp->recv_threadid) {
 			if (0 == pthread_join(vrtp->recv_threadid, NULL)){
+				rtpDbg(vrtp, "%s:%d vrtp receive thread %u thread join success.", __FUNCTION__, __LINE__, vrtp->recv_threadid);
 				vrtp->recv_threadid = 0;
-				rtpDbg(vrtp, "%s:%d vrtp recv thread pthread join success.", __FUNCTION__, __LINE__);
 			}
 			else {
-				rtpDbg(vrtp, "%s:%d vrtp recv thread pthread join failed for %s.", __FUNCTION__, __LINE__, strerror(errno));
+				rtpDbg(vrtp, "%s:%d vrtp receive thread thread join failed for %s.", __FUNCTION__, __LINE__, strerror(errno));
 			}
 		}
 		sem_destroy(&vrtp->sem_evt);