瀏覽代碼

Z991239-5471 #comment 优化双录流程

80274480 1 年之前
父節點
當前提交
a24e65f2f4

+ 19 - 5
Module/mod_SalesRecorder/mod_SalesRecorder.cpp

@@ -233,12 +233,15 @@ static bool FindMatchedFile(const char* pstrFindPath, const char* pstrFindFileNa
 #else
 static bool FindMatchedFile(const char* sFindPath, const char* sFindFileName, uint32_t& uCountFile)
 {
+	bool bRet = false;
 	DIR* pDir = NULL;
 	struct dirent* pFile = NULL;
 	CSimpleStringA tmpFindFileName = sFindFileName;
 
 	pDir = opendir(sFindPath);
-	if (pDir == NULL) return false;
+	if (pDir == NULL) {
+		return bRet;
+	}
 
 	//linux不支持*查找,去掉后缀
 	char strsuffix[MAX_PATH] = { 0 };
@@ -254,11 +257,13 @@ static bool FindMatchedFile(const char* sFindPath, const char* sFindFileName, ui
 		else {
 			if (0 == _strnicmp(pFile->d_name, tmpFindFileName.GetData(), tmpFindFileName.GetLength())) {
 				++uCountFile;
+				bRet = true;
 			}
 		}
 	}
 	closedir(pDir);
-	return true;
+
+	return bRet;
 }
 #endif
 
@@ -712,7 +717,6 @@ void CSalesRecorderEntity::OnRecordEntityExcption()
 
 void CSalesRecorderEntity::OnRecordFinished()
 {
-	LogEvent(Severity_High, LOG_EVT_SALESRECORD_FINISHED, "现场销售双录已完成.");
 	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FINISHED, "现场销售双录已完成.");
 }
 
@@ -998,6 +1002,10 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 {
 	ErrorCodeEnum ErrorCode = Error_Succeed;
 
+	if (NULL == videofilename || 0 == strlen(videofilename)) {
+		return Error_Param;
+	}
+
 	if(!m_bStarted)
 	{
 		CSimpleStringA sourPath;
@@ -1025,7 +1033,7 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 						destPath += SPLIT_SLASH_STR;
 					}
 					CSimpleStringA sourFileName(""), destFileName("");
-					bool bMoveSucc = true;
+					bool bMoveSucc = false;
 					for(int i = 0; i != uVideoCount; ++i)
 					{
 						sourFileName = CSimpleStringA::Format("%s%s_%d.%s", sourPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
@@ -1034,7 +1042,6 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 						LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FILESIZE, CSimpleStringA::Format("%s file size is %u byte.", sourFileName.GetData(), ufilesize).GetData());
 						bRet = rvcMoveFile(sourFileName.GetData(), destFileName.GetData());
 						if (!bRet) {
-							bMoveSucc = false;
 							ErrorCode = Error_NotImpl;
 						#ifdef RVC_OS_WIN
 							LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, CSimpleStringA::Format("Error Code %lu while move %s.", GetLastError(), sourFileName.GetData()).GetData());
@@ -1046,6 +1053,7 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 						#endif // RVC_OS_WIN
 						}
 						else {
+							bMoveSucc = true;
 							CSimpleStringA strVideoName = CSimpleStringA::Format("%s_%d.%s", strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
 							if (m_bPostOn) {
 								AddToSalesRecordList(destFileName.GetData(), strVideoName.GetData(), ufilesize);
@@ -1056,6 +1064,7 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 							LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_INVALID_FILE, CSimpleStringA::Format("%s file size is %u.", sourFileName.GetData(), ufilesize).GetData());
 						}
 					}
+
 					if (bMoveSucc) {
 						LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_SAVED_SUCCESS, CSimpleStringA::Format("succeed to save sales video, move it from %s to %s.", sourFileName.GetData(), destFileName.GetData()).GetData());
 						if (m_bPostOn) {
@@ -1792,6 +1801,11 @@ int CSalesRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
 		return iRet;
 	}
 
+	if (!ExistsFile(videofilename)) {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("File %s is not exist.", videofilename);
+		return iRet;
+	}
+
 	filecryption_callback_t cb = { 0 };
 	cb.dbg = &rvcDbg;
 

+ 1 - 1
Other/unix/libaudioqueue/libaudioqueue.h

@@ -21,7 +21,7 @@
 
 using namespace std ;
 
-#define MAX_AUDIOQUEUE_LENS     50					//音频队列最大节点数量
+#define MAX_AUDIOQUEUE_LENS     45					//音频队列最大节点数量
 #define MAX_AUDIOQNODE_SIZE     16000				//音频队列单个节点默认最大长度
 
 typedef struct audio_frame 

+ 41 - 80
Other/unix/libvideorecord/libvideorecord_impl.cpp

@@ -127,11 +127,11 @@ static bool FindMatchedFile(const char* sFindPath, const char* sFindFileName, st
 
 static bool ReNameFile(const char* file, const char* newfilename)
 {
-#ifdef _WIN32
+#ifdef RVC_OS_WIN
 	if (!_access(file, 0))
 #else
 	if (!access(file, F_OK))
-#endif //_WIN32
+#endif //RVC_OS_WIN
 	{
 		if (!rename(file, newfilename)){
 			return true;
@@ -1214,7 +1214,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameData(videoq_frame* Video, int fl
 		bRslt = m_env_videoqueue->GetVideo(tmp_frm, flags);
 		delete tmp_frm;
 		if (!bRslt) {
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "get env video fail!");
+			//m_pHostApi->Debug(RECORD_LOG_ERROR, "get env video fail!");
 			return -1;
 		}
 	}
@@ -1231,7 +1231,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameData(videoq_frame* Video, int fl
 		bRslt = m_opt_videoqueue->GetVideo3(tmp_frm, flags);
 		delete tmp_frm;
 		if (!bRslt) {
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "get opt video fail!");
+			m_pHostApi->Debug(RECORD_LOG_ERROR, "get opt video fail!");
 			return -2;
 		}
 	}
@@ -1262,28 +1262,20 @@ int libvideorecord_impl::GetDoubleCameraVideoFrameData(videoq_frame* Video, int
 }
 
 
-bool libvideorecord_impl::IsRecordingCamError(int iRecordingCam, eRvcRecordType eRecordType)
+bool libvideorecord_impl::IsRecordingCamError(int iRecordingCam)
 {
 	bool bRet = false;
-	if (eStand2Agent == eRecordType) {
-		if (0 == iRecordingCam) {
-			if ('E' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState()) {
-				bRet = true;
-			}
-		}
-		else {
-			if ('O' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState() || 'E' == m_pHostApi->GetCameraState()) {
-				bRet = true;
-			}
+	if (0 == iRecordingCam) {
+		if ('E' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState()) {
+			bRet = true;
 		}
 	}
 	else {
-		if ('B' == m_pHostApi->GetCameraState()) {
+		if ('O' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState() || 'E' == m_pHostApi->GetCameraState()) {
 			bRet = true;
 		}
 	}
 
-
 	return bRet;
 }
 
@@ -1885,23 +1877,6 @@ int libvideorecord_impl::WriteVideoFrame()
 				return -1;
 			}
 		}
-		else {
-			if (IsRecordingCamError(nInitActiveCam, eSingleSide)) {
-				LogFailedEvent(eVideoGetFailed, "recording camera error!");
-				return -1;
-			}
-			else {
-				struct timespec ts;
-				clock_gettime(CLOCK_REALTIME, &ts);
-				long unsec = ts.tv_nsec + (1000 * 1000 * 2);
-				ts.tv_sec += (unsec / 1000000000);
-				ts.tv_nsec = (unsec % 1000000000);
-				if (0 != sem_timedwait(&m_semt, &ts) && (ETIMEDOUT == errno)) {
-
-				}
-				return -2;
-			}
-		}
 	}
 
 	return iret;
@@ -1996,7 +1971,6 @@ bool libvideorecord_impl::GetLocalAudioFrame(int iAudioLens)
 			bRet = true;
 		}
 		else {
-			m_pHostApi->Debug(RECORD_LOG_ERROR, "not support audio sample rate, and audio samplespersec=%d,framesize=%d,channels=%d,format=%d,bitspersample=%d,series number=%d.", m_audioframe->samplespersec, m_audioframe->framesize, m_audioframe->nchannels, m_audioframe->format, m_audioframe->bitspersample, m_audioframe->iseriesnumber);
 			LogFailedEvent(eSampNotSupport, "not support audio sample rate.");
 		}
 	}
@@ -2032,32 +2006,6 @@ bool libvideorecord_impl::GetSingleSideAudioFrame()
 }
 
 
-bool libvideorecord_impl::AddMuteAudioFrame(bool bLocal, int iAudioFrameSize)
-{
-	bool bRet = false;
-
-	if (0 == iAudioFrameSize) {
-		return bRet;
-	}
-
-	if (bLocal) {
-		memset(m_pRecordAudioBuffer + m_iAudioBufferLen, 0, iAudioFrameSize);
-		m_iAudioBufferLen += iAudioFrameSize;
-		m_iAudioFromQueNum++;
-		m_pHostApi->Debug(RECORD_LOG_INFO, "m_iAudioFromQueNum is %d(Mute AudioFrame).", m_iAudioFromQueNum);
-		bRet = true;
-	}
-	else {
-		memset(m_pRemoteAudioBuffer + m_iRemoteAudioBufLen, 0, iAudioFrameSize);
-		m_iRemoteAudioBufLen += iAudioFrameSize;
-		m_iRemoteAudioNum++;
-		m_pHostApi->Debug(RECORD_LOG_INFO, "m_iRemoteAudioNum is %d(Mute Audio Frame).", m_iRemoteAudioNum);
-		bRet = true;
-	}
-
-	return bRet;
-}
-
 bool libvideorecord_impl::GetRecordAudioFrame()
 {
 	bool bRet = false;
@@ -2070,32 +2018,45 @@ bool libvideorecord_impl::GetRecordAudioFrame()
 		int nAudioLens = m_audioqueue->GetAudioLens();
 		int nRemoteAudioLens = m_remote_audioqueue->GetAudioLens();
 		m_pHostApi->Debug(RECORD_LOG_DEBUG,"current local audio length is %d, and remote audio length is %d.", nAudioLens, nRemoteAudioLens);
-		//1. 取本地音频
-		if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {
-			if (nAudioLens > 0) {//取到本地音频
+		if ((nAudioLens > 0) && (nRemoteAudioLens <= 0)) {
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {	//取出音频
 				bRet = GetLocalAudioFrame(nAudioLens);
 			}
-			else {//本地音频队列为空,用静音填充
-				bRet = AddMuteAudioFrame(true, m_iAudioPerSecBufLen/50);
-			}
 		}
-
-		//2. 取远端音频
-		if (m_iRemoteAudioBufLen < m_iAudioPerSecBufLen) {  
-			if (nRemoteAudioLens > 0) {
+		else if ((nAudioLens > 0) && (nRemoteAudioLens > 0)) {
+			if (m_iRemoteAudioBufLen < m_iAudioPerSecBufLen) {  //收到的远端音频不够1秒
 				bRet = GetRemoteAudioFrame(nRemoteAudioLens);	//取远端音频
 			}
-			else{
-				bRet = AddMuteAudioFrame(false, m_iAudioPerSecBufLen / 50);
+
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {
+				bRet = GetLocalAudioFrame(nAudioLens);	//本地音频
+			}
+			//混音
+			if ((m_iRemoteAudioBufLen == m_iAudioPerSecBufLen) && (m_iAudioBufferLen == m_iAudioPerSecBufLen)) {
+				//可视远程双录场景,本地和坐席端分别录制到左右声道
+				uint32_t uOutlen = BindPCMAudioData(m_iRecordAudioBufSize, m_pRecordAudioBuffer, m_iAudioBufferLen, m_pRemoteAudioBuffer, m_iRemoteAudioBufLen, m_audioframe->bitspersample / 8, eLocalLeft);
+				m_pHostApi->Debug(RECORD_LOG_DEBUG, "double channel buffer length is %d, local buffer len is %d, remote buffer len is %d.", m_iRecordAudioBufSize, m_iAudioBufferLen, m_iRemoteAudioBufLen);
+				m_iAudioBufferLen = uOutlen;
 			}
 		}
+		else if ((nAudioLens <= 0) && (nRemoteAudioLens > 0)) {  //本地端无数据不混音,双录语音播报场景
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {		 //取出音频
+				m_audioframe->data = m_pRecordAudioBuffer + m_iAudioBufferLen;
+				bool bGetAudio = false;
+				if (nRemoteAudioLens <= MAX_AUDIOQUEUE_LENS && nRemoteAudioLens > 1) {
+					bGetAudio = m_remote_audioqueue->GetAudioAndDel(m_audioframe);
+				}
+				else {
+					bGetAudio = m_remote_audioqueue->GetAudio(m_audioframe);
+				}
 
-		//3. 可视远程双录场景,本地和坐席端分别录制到左右声道
-		if ((m_iRemoteAudioBufLen == m_iAudioPerSecBufLen) && (m_iAudioBufferLen == m_iAudioPerSecBufLen)) {
-			
-			uint32_t uOutlen = BindPCMAudioData(m_iRecordAudioBufSize, m_pRecordAudioBuffer, m_iAudioBufferLen, m_pRemoteAudioBuffer, m_iRemoteAudioBufLen, m_audioframe->bitspersample / 8, eLocalLeft);
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "double channel buffer length is %d, local buffer len is %d, remote buffer len is %d.", m_iRecordAudioBufSize, m_iAudioBufferLen, m_iRemoteAudioBufLen);
-			m_iAudioBufferLen = uOutlen;
+				if (bGetAudio) {
+					m_pHostApi->Debug(RECORD_LOG_DEBUG,"remote audio series number is %d, channels is %d, samplespersec is %d.", m_audioframe->iseriesnumber, m_audioframe->nchannels, m_audioframe->samplespersec);
+					m_iAudioBufferLen += m_audioframe->framesize;
+					m_iAudioFromQueNum++;
+					m_pHostApi->Debug(RECORD_LOG_DEBUG,"m_iAudioFromQueNum is %d.", m_iAudioFromQueNum);
+				}
+			}
 		}
 	}
 	m_pHostApi->Debug(RECORD_LOG_DEBUG, "current m_iAudioBufferLen = %d, m_iAudioPerSecBufLen = %d.", m_iAudioBufferLen, m_iAudioPerSecBufLen);
@@ -2115,7 +2076,7 @@ int libvideorecord_impl::WriteAudioFrame()
 
 		m_iAudioBufferLen = 0;
 		m_iRemoteAudioBufLen = 0;
-		memset((void*)m_pRecordAudioBuffer, 0, m_iRecordAudioBufSize);
+		memset(m_pRecordAudioBuffer, 0, m_iRecordAudioBufSize);
 		if (NULL != m_pRemoteAudioBuffer) {
 			memset(m_pRemoteAudioBuffer, 0, m_iAudioPerSecBufLen);
 		}

+ 2 - 2
Other/unix/libvideorecord/libvideorecord_impl.h

@@ -1,5 +1,6 @@
 #pragma once
 #include "FFmpegWriter.h"
+//#include "WmvWriter.h"
 #include "libvideorecord.h"
 
 #include "libaudioqueue.h"
@@ -63,7 +64,7 @@ private:
 	int GetVideoFrameSize(int& nWidth, int& nHeight, Clibvideoqueue* queue);
 	//从指定队列读取video
 	bool GetVideoFrame(video_frame* Video, int flags, Clibvideoqueue* queue);
-	bool IsRecordingCamError(int iRecordingCam, eRvcRecordType eRecordType = eStand2Agent);
+	bool IsRecordingCamError(int iRecordingCam);
 	bool InitCvxText();
 	void GetVideoFullName();
 	bool AddCvxText(unsigned char** pData, int iDataSize, int iWidth, int iHeight);
@@ -107,7 +108,6 @@ private:
 	bool ReSetRecordParams();
 	bool InitVideoRecordParams();
 	int HandleLeftAudioData();
-	bool AddMuteAudioFrame(bool bLocal, int iAudioFrameSize);
 
 
 private:

+ 85 - 65
Other/win/libvideorecord/libvideorecord_impl.cpp

@@ -2,13 +2,18 @@
 #include "libvideorecord_impl.h"
 #include "videoutil.h"
 #include "io.h"
+//#include <windowsx.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <process.h>
 #include <string.h>
 #include <timeapi.h>
+//#include <windows.h>	//包含头文件 windows.h
+//#include <MMSystem.h>
 #pragma comment(lib, "winmm.lib")
-
+//#include <DbgHelp.h>
+//#pragma comment(lib, "dbghelp.lib")
+//#pragma comment(lib, "WMVCORE.lib")
 #ifndef RECORD_SAFE_DELETE
 #define RECORD_SAFE_DELETE(p) \
 			do{ \
@@ -29,20 +34,15 @@
 
 static bool ReNameFile(const char* file, const char* newfilename)
 {
-#ifdef _WIN32
-	if (!_access(file, 0))
-#else
-	if (!access(file, F_OK))
-#endif //_WIN32
-	{
-		if (!rename(file, newfilename)){
+	if (!_access(file, 0)) {
+		if (!rename(file, newfilename)) {
 			return true;
 		}
-		else{
+		else {
 			return false;
 		}
 	}
-	else{
+	else {
 		return false;
 	}
 }
@@ -62,7 +62,7 @@ static uint32_t BindPCMAudioData(uint32_t uBufferLen, char* pLocalAudios, uint32
 		memset(pLocalAudios, 0, uBufferLen);
 	}
 
-	for (uint32_t i = 0; i < uLocalAudioLen / uBitDeepth; i++) {
+	for (int i = 0; i < uLocalAudioLen / uBitDeepth; i++) {
 		if (eLocalLeft == eType) {
 			memcpy((uint32_t*)pLocalAudios + i, ((uint16_t*)(pBuffer)) + i, uBitDeepth);
 			uint16_t* pindex = (uint16_t*)((uint32_t*)pLocalAudios + i) + 1;
@@ -353,6 +353,41 @@ static void DeleteDumpFiles()
 }
 
 
+//static void videorecorddump_exception(PEXCEPTION_POINTERS ExceptionInfo, libvideorecord_impl* pVideoRecord)
+//{
+//	if (NULL != pVideoRecord) {
+//		pVideoRecord->EndRecord();
+//		if (NULL != pVideoRecord->m_pHostApi) {
+//			pVideoRecord->m_pHostApi->Debug(RECORD_LOG_ERROR, "VideoRecord Thread Exception.");
+//			pVideoRecord->m_pHostApi->OnRecordEntityExcption();
+//		}
+//	}
+//
+//	DeleteDumpFiles();
+//
+//	char tmp[MAX_PATH] = { 0 };
+//	HANDLE hDumpFile;
+//	sprintf_s(tmp, MAX_PATH, ".\\videorecord_%d.dmp", GetCurrentProcessId());
+//	hDumpFile = CreateFileA(tmp, GENERIC_READ | GENERIC_WRITE,
+//		0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+//	if ((hDumpFile != NULL) && (hDumpFile != INVALID_HANDLE_VALUE))
+//	{
+//		MINIDUMP_EXCEPTION_INFORMATION mdei;
+//		MINIDUMP_TYPE mdt;
+//
+//		mdei.ThreadId = GetCurrentThreadId();
+//		mdei.ExceptionPointers = ExceptionInfo;
+//		mdei.ClientPointers = false;
+//
+//		mdt = MiniDumpWithFullMemory;
+//
+//		MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
+//			hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0);
+//
+//		CloseHandle(hDumpFile);
+//	}
+//}
+
 
 static void __recordlog(void* user_data, const char* fmt, va_list arg)
 {
@@ -372,9 +407,13 @@ static unsigned int __stdcall VideoRecordThread(LPVOID n)
 	libvideorecord_impl* Record = (libvideorecord_impl*)n;
 	int iRet = -1;
 
+	//__try 
+	//{
 	iRet = Record->VideoRecord();
+	//}
+	//__except (videorecorddump_exception(GetExceptionInformation(), Record), EXCEPTION_EXECUTE_HANDLER) {
 
-
+	//}
 
 	return iRet;
 }
@@ -1095,7 +1134,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameData(videoq_frame* Video, int fl
 		bRslt = m_env_videoqueue->GetVideo(tmp_frm, flags);
 		delete tmp_frm;
 		if (!bRslt) {
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "get env video fail!");
+			m_pHostApi->Debug(RECORD_LOG_ERROR, "get env video fail!");
 			return -1;
 		}
 	}
@@ -1112,7 +1151,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameData(videoq_frame* Video, int fl
 		bRslt = m_opt_videoqueue->GetVideo3(tmp_frm, flags);
 		delete tmp_frm;
 		if (!bRslt) {
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "get opt video fail!");
+			//m_pHostApi->Debug(RECORD_LOG_ERROR, "get opt video fail!");
 			return -2;
 		}
 	}
@@ -1804,7 +1843,6 @@ bool libvideorecord_impl::GetLocalAudioFrame(int iAudioLens)
 			bRet = true;
 		}
 		else {
-			m_pHostApi->Debug(RECORD_LOG_ERROR, "not support audio sample rate, and audio samplespersec=%d,framesize=%d,channels=%d,format=%d,bitspersample=%d,series number=%d.", m_audioframe->samplespersec, m_audioframe->framesize, m_audioframe->nchannels, m_audioframe->format, m_audioframe->bitspersample, m_audioframe->iseriesnumber);
 			LogFailedEvent(eSampNotSupport, "not support audio sample rate.");
 		}
 	}
@@ -1840,32 +1878,6 @@ bool libvideorecord_impl::GetSingleSideAudioFrame()
 }
 
 
-bool libvideorecord_impl::AddMuteAudioFrame(bool bLocal, int iAudioFrameSize)
-{
-	bool bRet = false;
-
-	if (0 == iAudioFrameSize) {
-		return bRet;
-	}
-
-	if (bLocal) {
-		memset(m_pRecordAudioBuffer + m_iAudioBufferLen, 0, iAudioFrameSize);
-		m_iAudioBufferLen += iAudioFrameSize;
-		m_iAudioFromQueNum++;
-		m_pHostApi->Debug(RECORD_LOG_INFO, "m_iAudioFromQueNum is %d(Mute AudioFrame).", m_iAudioFromQueNum);
-		bRet = true;
-	}
-	else {
-		memset(m_pRemoteAudioBuffer + m_iRemoteAudioBufLen, 0, iAudioFrameSize);
-		m_iRemoteAudioBufLen += iAudioFrameSize;
-		m_iRemoteAudioNum++;
-		m_pHostApi->Debug(RECORD_LOG_INFO, "m_iRemoteAudioNum is %d(Mute Audio Frame).", m_iRemoteAudioNum);
-		bRet = true;
-	}
-
-	return bRet;
-}
-
 bool libvideorecord_impl::GetRecordAudioFrame()
 {
 	bool bRet = false;
@@ -1878,32 +1890,44 @@ bool libvideorecord_impl::GetRecordAudioFrame()
 		int nAudioLens = m_audioqueue->GetAudioLens();
 		int nRemoteAudioLens = m_remote_audioqueue->GetAudioLens();
 		m_pHostApi->Debug(RECORD_LOG_DEBUG,"current local audio length is %d, and remote audio length is %d.", nAudioLens, nRemoteAudioLens);
-		//1. 取本地音频
-		if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {
-			if (nAudioLens > 0) {//取到本地音频
+		if ((nAudioLens > 0) && (nRemoteAudioLens <= 0)) {
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {	//取出音频
 				bRet = GetLocalAudioFrame(nAudioLens);
 			}
-			else {//本地音频队列为空,用静音填充
-				bRet = AddMuteAudioFrame(true, m_iAudioPerSecBufLen/50);
-			}
 		}
-
-		//2. 取远端音频
-		if (m_iRemoteAudioBufLen < m_iAudioPerSecBufLen) {  
-			if (nRemoteAudioLens > 0) {
+		else if ((nAudioLens > 0) && (nRemoteAudioLens > 0)) {
+			if (m_iRemoteAudioBufLen < m_iAudioPerSecBufLen) {  //收到的远端音频不够1秒
 				bRet = GetRemoteAudioFrame(nRemoteAudioLens);	//取远端音频
 			}
-			else{
-				bRet = AddMuteAudioFrame(false, m_iAudioPerSecBufLen / 50);
+
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {
+				bRet = GetLocalAudioFrame(nAudioLens);	//本地音频
+			}
+			if ((m_iRemoteAudioBufLen == m_iAudioPerSecBufLen) && (m_iAudioBufferLen == m_iAudioPerSecBufLen)) {
+				//可视远程双录场景,本地和坐席端分别录制到左右声道
+				uint32_t uOutlen = BindPCMAudioData(m_iRecordAudioBufSize, m_pRecordAudioBuffer, m_iAudioBufferLen, m_pRemoteAudioBuffer, m_iRemoteAudioBufLen, m_audioframe->bitspersample / 8, eLocalLeft);
+				m_pHostApi->Debug(RECORD_LOG_DEBUG, "double channel buffer length is %d, local buffer len is %d, remote buffer len is %d.", m_iRecordAudioBufSize, m_iAudioBufferLen, m_iRemoteAudioBufLen);
+				m_iAudioBufferLen = uOutlen;
 			}
 		}
+		else if ((nAudioLens <= 0) && (nRemoteAudioLens > 0)) {  //本地端无数据不混音,双录语音播报场景
+			if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {		 //取出音频
+				m_audioframe->data = m_pRecordAudioBuffer + m_iAudioBufferLen;
+				bool bGetAudio = false;
+				if (nRemoteAudioLens <= MAX_AUDIOQUEUE_LENS && nRemoteAudioLens > 1) {
+					bGetAudio = m_remote_audioqueue->GetAudioAndDel(m_audioframe);
+				}
+				else {
+					bGetAudio = m_remote_audioqueue->GetAudio(m_audioframe);
+				}
 
-		//3. 可视远程双录场景,本地和坐席端分别录制到左右声道
-		if ((m_iRemoteAudioBufLen == m_iAudioPerSecBufLen) && (m_iAudioBufferLen == m_iAudioPerSecBufLen)) {
-			
-			uint32_t uOutlen = BindPCMAudioData(m_iRecordAudioBufSize, m_pRecordAudioBuffer, m_iAudioBufferLen, m_pRemoteAudioBuffer, m_iRemoteAudioBufLen, m_audioframe->bitspersample / 8, eLocalLeft);
-			m_pHostApi->Debug(RECORD_LOG_DEBUG, "double channel buffer length is %d, local buffer len is %d, remote buffer len is %d.", m_iRecordAudioBufSize, m_iAudioBufferLen, m_iRemoteAudioBufLen);
-			m_iAudioBufferLen = uOutlen;
+				if (bGetAudio) {
+					m_pHostApi->Debug(RECORD_LOG_DEBUG,"remote audio series number is %d, channels is %d, samplespersec is %d.", m_audioframe->iseriesnumber, m_audioframe->nchannels, m_audioframe->samplespersec);
+					m_iAudioBufferLen += m_audioframe->framesize;
+					m_iAudioFromQueNum++;
+					m_pHostApi->Debug(RECORD_LOG_DEBUG,"m_iAudioFromQueNum is %d.", m_iAudioFromQueNum);
+				}
+			}
 		}
 	}
 	m_pHostApi->Debug(RECORD_LOG_DEBUG, "current m_iAudioBufferLen = %d, m_iAudioPerSecBufLen = %d.", m_iAudioBufferLen, m_iAudioPerSecBufLen);
@@ -1945,17 +1969,13 @@ bool libvideorecord_impl::InitVideoRecordParams()
 
 	//获取视频帧大小
 	if (!GetRecordVideoFrameSize()) {
-		if (false == m_bStopRecord) {
-			LogFailedEvent(eVideoGetFailed, "Get Video Frame Failed Max Times.", true);
-		}
+		LogFailedEvent(eVideoGetFailed, "Get Video Frame Failed Max Times.", true);
 		return bRet;
 	}
 
 	//获取音频帧大小
 	if (!GetRecordAudioFrameSize()) {
-		if (false == m_bStopRecord) {
-			LogFailedEvent(eLocalAudioGetFailed, "Get Audio Frame Failed Max Times.", true);
-		}
+		LogFailedEvent(eLocalAudioGetFailed, "Get Audio Frame Failed Max Times.", true);
 		return bRet;
 	}
 

+ 0 - 1
Other/win/libvideorecord/libvideorecord_impl.h

@@ -106,7 +106,6 @@ private:
 	bool ReSetRecordParams();
 	bool InitVideoRecordParams();
 	int HandleLeftAudioData();
-	bool AddMuteAudioFrame(bool bLocal, int iAudioFrameSize);
 
 
 private: