Преглед на файлове

Z991239-6192 #comment: 优化免提麦克风故障时告警信息上送逻辑

80274480 преди 4 месеца
родител
ревизия
ac1024a9c0

+ 2 - 18
Module/mod_mediacontroller/capture.cpp

@@ -1676,7 +1676,8 @@ namespace MediaController {
 			if ('N' == cap->config.strAudioState[0] || 'P' == cap->config.strAudioState[0]) {
 				ErrorCodeEnum rslt = start_audio_capture(cap->handfree_audio);
 				if (Error_Succeed != rslt) {
-					return rslt;
+					//return rslt;
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("start handfree audio capture failed!");
 				}
 			}
 			else {
@@ -1803,23 +1804,6 @@ namespace MediaController {
 		}
 	}
 
-	int capture_detect_audioin_bug(capture_t* cap, int* audioin_n)
-	{
-		*audioin_n = 0;
-		if (cap->handfree_audio)
-		{
-			if (cap->handfree_audio->shm_queue)
-			{
-				*audioin_n = cap->handfree_audio->shm_queue->GetAudioLens();
-			}
-		}
-		else
-		{
-			*audioin_n = -1;
-		}
-
-		return 0;
-	}
 
 	int capture_detect_camera_bug(capture_t *cap, int *env_n, int *opt_n, bool bsinglecam)
 	{

+ 0 - 1
Module/mod_mediacontroller/capture.h

@@ -188,7 +188,6 @@ namespace MediaController {
 	int capture_detect_camera_bug(capture_t *cap, int *env_n, int *opt_n, bool bsinglecam);
 	int capture_get_last_frametime(capture_t *cap, unsigned int* env_n, unsigned int* opt_n);
 	
-	int capture_detect_audioin_bug(capture_t* cap, int* audioin_n);
 	int capture_get_last_audio_frametime(capture_t* cap, unsigned int* handfreein_n);
 
 	int salesaudio_capture_create(rvc_audio_capture_config_t *config, rvc_sales_audio_capture_t **p_cap);

+ 9 - 26
Module/mod_mediacontroller/mod_mediacontroller.cpp

@@ -609,6 +609,7 @@ void CMediaControllerEntity::OnTimeout(DWORD dwTimerID)
 #endif
 }
 
+
 void CMediaControllerEntity::OnTimeHandfreeMicroStatusCheck()
 {
 	CSimpleStringA strValue = m_capture->config.strAudioState;
@@ -616,32 +617,13 @@ void CMediaControllerEntity::OnTimeHandfreeMicroStatusCheck()
 		return;
 	}
 
-	int audioin_n = -1;
 	unsigned int nHandfreeinAudioTime = 0;
-	static int iAudioInEmptyTimes = 0;
 	static bool bTimeout = false;
 	static bool bPost = false;
 
-	capture_detect_audioin_bug(m_capture, &audioin_n);
 	capture_get_last_audio_frametime(m_capture, &nHandfreeinAudioTime);
 
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("======last audio time is %d.======", nHandfreeinAudioTime);
-
-	if (audioin_n == 0) {
-		if (iAudioInEmptyTimes < AUDIO_BUG_THRESHOLD) {
-			iAudioInEmptyTimes++;
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get handfree in audio fail, times=%d.", iAudioInEmptyTimes);
-		}
-	}
-	else if (audioin_n == -1) {
-		iAudioInEmptyTimes = AUDIO_BUG_THRESHOLD;
-	}
-	else {
-		if (iAudioInEmptyTimes == AUDIO_BUG_THRESHOLD) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("handfree in get audio success again.");
-		}
-		iAudioInEmptyTimes = 0;
-	}
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("======last audio time is %d.======", nHandfreeinAudioTime);
 
 	if (nHandfreeinAudioTime > 0)
 	{
@@ -650,18 +632,19 @@ void CMediaControllerEntity::OnTimeHandfreeMicroStatusCheck()
 			bTimeout = true;
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("bTimeout.");
 		}
-		else if (((y2k_time_now() - nHandfreeinAudioTime) < m_iCamTimeout) && bTimeout)
+		else if (((y2k_time_now() - nHandfreeinAudioTime) < 60) && bTimeout)
 		{
 			bTimeout = false;
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change handfree audio in from bTimeout to ok.");
 		}
 	}
 
-	if (((iAudioInEmptyTimes == AUDIO_BUG_THRESHOLD) || bTimeout)&& (!bPost))
-	{
-		LogWarn(Severity_Middle, Error_Hardware, ERROR_MOD_MEDIACONTROLLER_HANDFREEIN_BUG, "免提麦克风故障,采集不到音频");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA2820")("免提麦克风故障,采集不到音频");
-		bPost = true;
+	if (bTimeout){
+		if (!bPost) {
+			LogWarn(Severity_Middle, Error_Hardware, ERROR_MOD_MEDIACONTROLLER_HANDFREEIN_BUG, CSimpleStringA::Format("{%s}故障,采集不到音频", m_capture->config.strAudioIn.GetData()).GetData());
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA2820")("免提麦克风故障,采集不到音频");
+			bPost = true;
+		}
 	}
 }
 

+ 2 - 2
Other/libvideorecord/FFmpegWriter.cpp

@@ -836,10 +836,10 @@ bool FFmpegWriter::ReceiveAudioData(unsigned char* pData, unsigned long len)
     int frame_size = av_samples_get_buffer_size(NULL, frame->channels,
         frame->nb_samples,
         (AVSampleFormat)frame->format, 0);
-    //m_pLogApi->Debug("ReceiveAudioData len:%d, available_data_len:%d, frame_size:%d", len, audio_input_buffer->bytesRemaining(), frame_size);
+    //m_pLogApi->Debug("ReceiveAudioData len:%d, available_data_len:%d, frame_size:%d.", len, audio_input_buffer->bytesRemaining(), frame_size);
     //循环写帧
     while (frame_size <= m_audio_input_buffer->bytesRemaining()) {
-        //m_pLogApi->Debug("ReceiveAudioData available_data_len:%d", audio_input_buffer->bytesRemaining());
+        //m_pLogApi->Debug("ReceiveAudioData available_data_len:%d.", audio_input_buffer->bytesRemaining());
         int result = write_audio_frame(m_pLogApi, m_formatctx, m_audio_st, m_audio_input_buffer);
         if (result < 0) {
             m_pLogApi->Debug("write_audio_frame Failed, %d.", result);

+ 14 - 3
Other/libvideorecord/libvideorecord_impl.cpp

@@ -2300,10 +2300,21 @@ bool libvideorecord_impl::InitVideoRecordParams()
 	else {
 		//获取音频帧大小
 		if (!GetRecordAudioFrameSize()) {
-			if (false == m_bStopRecord) {
-				LogFailedEvent(eLocalAudioGetFailed, "Get Audio Frame Failed Max Times.", true);
+			if (eSingleSide == m_eRecordType) {
+				if (false == m_bStopRecord) {
+					m_bMuteAudio = true;
+					m_iAudioFrameSize = 320;
+				}
+				else {
+					return bRet;
+				}
+			}
+			else {
+				if (false == m_bStopRecord) {
+					LogFailedEvent(eLocalAudioGetFailed, "Get Audio Frame Failed Max Times.", true);
+				}
+				return bRet;
 			}
-			return bRet;
 		}
 	}