|
@@ -2,16 +2,18 @@
|
|
|
#include "libvideorecord_impl.h"
|
|
|
#include "videoutil.h"
|
|
|
#include "io.h"
|
|
|
-#include <windowsx.h>
|
|
|
+//#include <windowsx.h>
|
|
|
#include <stdint.h>
|
|
|
#include <stdio.h>
|
|
|
#include <process.h>
|
|
|
-#include <windows.h> //包含头文件 windows.h
|
|
|
-#include <MMSystem.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")
|
|
|
+//#include <DbgHelp.h>
|
|
|
+//#pragma comment(lib, "dbghelp.lib")
|
|
|
+//#pragma comment(lib, "WMVCORE.lib")
|
|
|
#ifndef RECORD_SAFE_DELETE
|
|
|
#define RECORD_SAFE_DELETE(p) \
|
|
|
do{ \
|
|
@@ -45,24 +47,6 @@ static bool ReNameFile(const char* file, const char* newfilename)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//混音
|
|
|
-static void MixtureAudio(int buflens, char* localbuf, char* remotebuf)
|
|
|
-{
|
|
|
- for (int i = 0; i < buflens - 2; i += 2)
|
|
|
- {
|
|
|
- *(__int16*)(localbuf + i) = *(__int16*)(localbuf + i)
|
|
|
- + *(__int16*)(remotebuf + i) - ((*(__int16*)(localbuf + i)) * (*(__int16*)(remotebuf + i)) >> 0x10);
|
|
|
-
|
|
|
- if (*(__int16*)(localbuf + i) > 32767) {
|
|
|
- *(__int16*)(localbuf + i) = 32767;
|
|
|
- }
|
|
|
- else if (*(__int16*)(localbuf + i) < -32768) {
|
|
|
- *(__int16*)(localbuf + i) = -32768;
|
|
|
- }
|
|
|
- }
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
static uint32_t BindPCMAudioData(uint32_t uBufferLen, char* pLocalAudios, uint32_t uLocalAudioLen, char* pRemoteAudios, uint32_t uRemoteAudioLen, uint32_t uBitDeepth, eStereoArrayType eType)
|
|
|
{
|
|
@@ -369,40 +353,40 @@ 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 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)
|
|
@@ -816,7 +800,7 @@ bool libvideorecord_impl::CalcuRecordAudioParams(audio_frame* paudio)
|
|
|
m_iLocalAudioFps = m_iAudioPerSecBufLen / paudio->framesize;
|
|
|
m_pHostApi->Debug(RECORD_LOG_DEBUG, "音频帧的帧频 m_iLocalAudioFps=%d", m_iLocalAudioFps);
|
|
|
if (eSingleSide != m_eRecordType) {
|
|
|
- if (ePad2Agent == m_eRecordType || eStand2Agent == m_eRecordType) { //可视柜台渠道的双向录像,本地端和坐席端声音采用左右声道方式录制
|
|
|
+ if (eStand2Agent == m_eRecordType) { //可视柜台渠道的双向录像,本地端和坐席端声音采用左右声道方式录制
|
|
|
|
|
|
m_iRemoteAudioFps = 50;
|
|
|
m_iRecordAudioBufSize = m_iAudioPerSecBufLen * 2;
|
|
@@ -1918,16 +1902,11 @@ bool libvideorecord_impl::GetRecordAudioFrame()
|
|
|
if (m_iAudioBufferLen < m_iAudioPerSecBufLen) {
|
|
|
bRet = GetLocalAudioFrame(nAudioLens); //本地音频
|
|
|
}
|
|
|
- //混音
|
|
|
if ((m_iRemoteAudioBufLen == m_iAudioPerSecBufLen) && (m_iAudioBufferLen == m_iAudioPerSecBufLen)) {
|
|
|
- if (ePhone2Pad == m_eRecordType) {
|
|
|
- MixtureAudio(m_iAudioBufferLen, m_pRecordAudioBuffer, m_pRemoteAudioBuffer);
|
|
|
- }
|
|
|
- else {//可视远程双录场景,本地和坐席端分别录制到左右声道
|
|
|
- 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;
|
|
|
- }
|
|
|
+ //可视远程双录场景,本地和坐席端分别录制到左右声道
|
|
|
+ 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)) { //本地端无数据不混音,双录语音播报场景
|
|
@@ -1959,7 +1938,7 @@ bool libvideorecord_impl::GetRecordAudioFrame()
|
|
|
int libvideorecord_impl::WriteAudioFrame()
|
|
|
{
|
|
|
int iRet = 0;
|
|
|
- if (ReceiveRecordAudioData((BYTE*)m_pRecordAudioBuffer, m_iAudioBufferLen)) {
|
|
|
+ if (ReceiveRecordAudioData((unsigned char*)m_pRecordAudioBuffer, m_iAudioBufferLen)) {
|
|
|
m_iRecordAudioNum++;
|
|
|
if (0 == m_iRecordAudioNum % 10) {
|
|
|
m_pHostApi->Debug(RECORD_LOG_DEBUG, "已成功写入音频帧数为(%d), 当前音频包大小为(%d).", m_iRecordAudioNum, m_iAudioBufferLen);
|
|
@@ -1967,7 +1946,7 @@ int libvideorecord_impl::WriteAudioFrame()
|
|
|
|
|
|
m_iAudioBufferLen = 0;
|
|
|
m_iRemoteAudioBufLen = 0;
|
|
|
- memset(m_pRecordAudioBuffer, 0, m_iRecordAudioBufSize);
|
|
|
+ memset((void*)m_pRecordAudioBuffer, 0, m_iRecordAudioBufSize);
|
|
|
if (NULL != m_pRemoteAudioBuffer) {
|
|
|
memset(m_pRemoteAudioBuffer, 0, m_iAudioPerSecBufLen);
|
|
|
}
|