|
@@ -26,7 +26,6 @@
|
|
|
#include "CvxText.h" // 用于中文字幕添加 add by ly
|
|
|
#include <speex/speex_resampler.h>
|
|
|
#include "iaudionsinterface.h"
|
|
|
-#include "libaudiotransqueue.h"
|
|
|
#include <semaphore.h>
|
|
|
|
|
|
#define SLASH '/'
|
|
@@ -134,7 +133,6 @@ public:
|
|
|
memset(videoframe,0,sizeof(videoq_frame));
|
|
|
audioframe = new audio_frame;
|
|
|
memset(audioframe,0,sizeof(audio_frame));
|
|
|
- m_hRecordThread = NULL;
|
|
|
m_nRecordthreadId = 0;
|
|
|
sem_init(&m_semt, 0, 0);
|
|
|
|
|
@@ -149,35 +147,31 @@ public:
|
|
|
memset(m_videoqueue2name, 0, MAX_PATH);
|
|
|
memset(m_remotevideoqueuename, 0, MAX_PATH);
|
|
|
memset(m_remoteaudioqueuename, 0, MAX_PATH);
|
|
|
- //音频传输队列,初始化为空
|
|
|
- m_salestransqueue = NULL;
|
|
|
- // 支持现场销售双录使用独立的音频队列 edit by ly@2018/06/13
|
|
|
m_audioqueue = NULL;
|
|
|
- //m_localaudioqueue = new Clibaudioqueue((char *)audioqueuename);
|
|
|
+
|
|
|
strncpy(m_audioqueuename, audioqueuename, (strlen(audioqueuename) > MAX_PATH) ? (MAX_PATH - 1): strlen(audioqueuename));
|
|
|
m_salesaudioqueue = NULL;
|
|
|
- if (salesaudioqueuename)
|
|
|
- {
|
|
|
+ if (salesaudioqueuename){
|
|
|
strncpy(m_salesaudioqueuename, salesaudioqueuename, (strlen(salesaudioqueuename) > MAX_PATH) ? (MAX_PATH - 1) : strlen(salesaudioqueuename));
|
|
|
}
|
|
|
+
|
|
|
m_videoqueue = NULL;
|
|
|
- if (videoqueuename)
|
|
|
- {
|
|
|
+ if (videoqueuename){
|
|
|
strncpy(m_videoqueuename, videoqueuename, (strlen(videoqueuename) > MAX_PATH) ? (MAX_PATH - 1) : strlen(videoqueuename));
|
|
|
}
|
|
|
+
|
|
|
m_videoqueue2 = NULL;
|
|
|
- if (videoqueue2name)
|
|
|
- {
|
|
|
+ if (videoqueue2name){
|
|
|
strncpy(m_videoqueue2name, videoqueue2name, (strlen(videoqueue2name) > MAX_PATH) ? (MAX_PATH - 1) : strlen(videoqueue2name));
|
|
|
}
|
|
|
+
|
|
|
m_remotevideoqueue = NULL;
|
|
|
- if (remotevideoqueuename)
|
|
|
- {
|
|
|
+ if (remotevideoqueuename){
|
|
|
strncpy(m_remotevideoqueuename, remotevideoqueuename, (strlen(remotevideoqueuename) > MAX_PATH) ? (MAX_PATH - 1) : strlen(remotevideoqueuename));
|
|
|
}
|
|
|
+
|
|
|
m_remoteaudioqueue = NULL;
|
|
|
- if (remoteaudioqueuename)
|
|
|
- {
|
|
|
+ if (remoteaudioqueuename){
|
|
|
strncpy(m_remoteaudioqueuename, remoteaudioqueuename, (strlen(remoteaudioqueuename) > MAX_PATH) ? (MAX_PATH - 1) : strlen(remoteaudioqueuename));
|
|
|
}
|
|
|
|
|
@@ -192,68 +186,53 @@ public:
|
|
|
|
|
|
~libwmvrecord_impl()
|
|
|
{
|
|
|
- if (videoframe->data != NULL)
|
|
|
- {
|
|
|
+ if (videoframe->data != NULL){
|
|
|
delete videoframe->data;
|
|
|
videoframe->data = NULL;
|
|
|
}
|
|
|
|
|
|
- if (videoframe != NULL)
|
|
|
- {
|
|
|
+ if (videoframe != NULL){
|
|
|
delete videoframe;
|
|
|
videoframe = NULL;
|
|
|
}
|
|
|
|
|
|
- if (audioframe != NULL)
|
|
|
- {
|
|
|
+ if (audioframe != NULL){
|
|
|
delete audioframe;
|
|
|
audioframe = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_hRecordThread)
|
|
|
- {
|
|
|
- m_hRecordThread = NULL;
|
|
|
- }
|
|
|
-
|
|
|
- if (m_pWriter!= NULL)
|
|
|
- {
|
|
|
+ if (m_pWriter!= NULL){
|
|
|
delete m_pWriter;
|
|
|
m_pWriter = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_localaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_localaudioqueue != NULL){
|
|
|
delete m_localaudioqueue;
|
|
|
m_localaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_salesaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_salesaudioqueue != NULL){
|
|
|
delete m_salesaudioqueue;
|
|
|
m_salesaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
m_audioqueue = NULL;
|
|
|
- if (m_remoteaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_remoteaudioqueue != NULL){
|
|
|
delete m_remoteaudioqueue;
|
|
|
m_remoteaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_videoqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_videoqueue != NULL){
|
|
|
delete m_videoqueue;
|
|
|
m_videoqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_videoqueue2 != NULL)
|
|
|
- {
|
|
|
+ if (m_videoqueue2 != NULL){
|
|
|
delete m_videoqueue2;
|
|
|
m_videoqueue2 = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_remotevideoqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_remotevideoqueue != NULL){
|
|
|
delete m_remotevideoqueue;
|
|
|
m_remotevideoqueue = NULL;
|
|
|
}
|
|
@@ -267,12 +246,6 @@ public:
|
|
|
DestroyIAudioNsObj(m_pAudioNsObj);
|
|
|
m_pAudioNsObj = NULL;
|
|
|
}
|
|
|
-
|
|
|
- if (NULL != m_salestransqueue){
|
|
|
- //Dbg("delete m_salestransqueue ing .......");
|
|
|
- delete m_salestransqueue;
|
|
|
- m_salestransqueue = NULL;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
CWmvHostApi* GetHostApi()
|
|
@@ -290,11 +263,8 @@ private:
|
|
|
BOOL m_bIsAudioTransOn; //是否开始音频传输到识别服务器开关
|
|
|
|
|
|
int m_nFps;
|
|
|
- ////字幕信息 add by ly
|
|
|
- //struct RecordSubTitle m_SubTitle;
|
|
|
/************************************************************************/
|
|
|
int m_videoquality;
|
|
|
- //int m_audioOutBitRate;
|
|
|
SubtitleParam m_SubtitleParam;
|
|
|
BOOL m_bWholeSection;
|
|
|
BOOL m_bSessionManage;
|
|
@@ -304,10 +274,10 @@ private:
|
|
|
Clibaudioqueue*m_audioqueue;
|
|
|
Clibvideoqueue*m_videoqueue;
|
|
|
Clibvideoqueue*m_videoqueue2;
|
|
|
- Clibvideoqueue*m_remotevideoqueue; //远端视频,用于双向录像,add by chh 20170320
|
|
|
- Clibaudioqueue*m_remoteaudioqueue; //远端音频,用于双向录像,add by chh 20170320
|
|
|
- Clibaudioqueue*m_localaudioqueue; //本地音频,add by ly@2018/06/13
|
|
|
- Clibaudioqueue*m_salesaudioqueue; //现场销售音频,add by ly@2018/06/13
|
|
|
+ Clibvideoqueue*m_remotevideoqueue; //远端视频,用于双向录像
|
|
|
+ Clibaudioqueue*m_remoteaudioqueue; //远端音频,用于双向录像
|
|
|
+ Clibaudioqueue*m_localaudioqueue; //本地音频
|
|
|
+ Clibaudioqueue*m_salesaudioqueue; //现场销售音频
|
|
|
char m_audioqueuename[MAX_PATH];
|
|
|
char m_videoqueuename[MAX_PATH];
|
|
|
char m_videoqueue2name[MAX_PATH];
|
|
@@ -315,9 +285,6 @@ private:
|
|
|
char m_remotevideoqueuename[MAX_PATH];
|
|
|
char m_remoteaudioqueuename[MAX_PATH];
|
|
|
|
|
|
- Clibaudiotransqueue *m_salestransqueue;
|
|
|
-
|
|
|
- pthread_t m_hRecordThread;
|
|
|
pthread_t m_nRecordthreadId;
|
|
|
char m_FileName[MAX_PATH];
|
|
|
char m_PathName[MAX_PATH];
|
|
@@ -339,60 +306,53 @@ private:
|
|
|
|
|
|
BOOL EndRecord()
|
|
|
{
|
|
|
- if (!m_pWriter->End())
|
|
|
- {
|
|
|
+ if (!m_pWriter->End()){
|
|
|
return FALSE;
|
|
|
}
|
|
|
- if (m_pWriter)
|
|
|
- {
|
|
|
+
|
|
|
+ if (m_pWriter){
|
|
|
delete m_pWriter;
|
|
|
m_pWriter = NULL;
|
|
|
}
|
|
|
- if (videoframe->data)
|
|
|
- {
|
|
|
+
|
|
|
+ if (videoframe->data){
|
|
|
delete videoframe->data;
|
|
|
videoframe->data = NULL;
|
|
|
}
|
|
|
- if (m_pAudioBufferTmp!=NULL)
|
|
|
- {
|
|
|
+
|
|
|
+ if (m_pAudioBufferTmp!=NULL){
|
|
|
delete m_pAudioBufferTmp;
|
|
|
m_pAudioBufferTmp = NULL;
|
|
|
m_iAudioBufferSize = 0;
|
|
|
}
|
|
|
|
|
|
- if (m_localaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_localaudioqueue != NULL){
|
|
|
delete m_localaudioqueue;
|
|
|
m_localaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_salesaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_salesaudioqueue != NULL){
|
|
|
delete m_salesaudioqueue;
|
|
|
m_salesaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
m_audioqueue = NULL;
|
|
|
- if (m_remoteaudioqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_remoteaudioqueue != NULL){
|
|
|
delete m_remoteaudioqueue;
|
|
|
m_remoteaudioqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_videoqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_videoqueue != NULL){
|
|
|
delete m_videoqueue;
|
|
|
m_videoqueue = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_videoqueue2 != NULL)
|
|
|
- {
|
|
|
+ if (m_videoqueue2 != NULL){
|
|
|
delete m_videoqueue2;
|
|
|
m_videoqueue2 = NULL;
|
|
|
}
|
|
|
|
|
|
- if (m_remotevideoqueue != NULL)
|
|
|
- {
|
|
|
+ if (m_remotevideoqueue != NULL){
|
|
|
delete m_remotevideoqueue;
|
|
|
m_remotevideoqueue = NULL;
|
|
|
}
|
|
@@ -431,6 +391,7 @@ private:
|
|
|
//开始录制视频
|
|
|
BOOL StartRecord()
|
|
|
{
|
|
|
+ BOOL bRet = FALSE;
|
|
|
m_pWriter = new FFmpegWmvWriter(this);
|
|
|
if (m_bIsAudioNsOn){
|
|
|
audions_callback_t t_callback = { 0 };
|
|
@@ -440,12 +401,13 @@ private:
|
|
|
}
|
|
|
|
|
|
if (0 == pthread_create(&m_nRecordthreadId, NULL, VideoRecordThread, (void*)this)) {
|
|
|
+ bRet = TRUE;
|
|
|
m_pHostApi->Debug("create video record thread and thread id is %u.", m_nRecordthreadId);
|
|
|
}
|
|
|
else {
|
|
|
m_pHostApi->Debug("create video record thread failed.");
|
|
|
}
|
|
|
- return TRUE;
|
|
|
+ return bRet;
|
|
|
}
|
|
|
|
|
|
//获取指定队列的SIZE
|
|
@@ -691,7 +653,7 @@ private:
|
|
|
{
|
|
|
//将大机摄像头和远端视频拼接到一张画布中
|
|
|
memset(Video->data,0,Video->framesize);
|
|
|
- BOOL bRslt =FALSE;
|
|
|
+ BOOL bRslt = FALSE;
|
|
|
int width = 0;
|
|
|
int height = 0;
|
|
|
m_videoqueue->GetFrameSize(width,height);
|
|
@@ -1160,7 +1122,7 @@ private:
|
|
|
TtcDir += fontfile;
|
|
|
pText = new CvxText(m_pHostApi, TtcDir.c_str());
|
|
|
int type = 0;
|
|
|
- CvScalar scalar = {22, 0.5, 0.2, 0}; //字体大小/空白比例/间隔比例/旋转角度
|
|
|
+ CvScalar scalar = {16, 0.3, 0.2, 0}; //字体大小/空白比例/间隔比例/旋转角度
|
|
|
bool underline = false;
|
|
|
float diaphaneity = 1.0;
|
|
|
pText->setFont(&type, &scalar, &underline, &diaphaneity); //字体类型/size/下滑线/透明度
|
|
@@ -1496,17 +1458,6 @@ private:
|
|
|
if ((0 == nAudioFromQueNum%100) && 0 != audioframe->iseriesnumber){
|
|
|
//m_pHostApi->Debug("single side record current audio queue len is %d and audio series number is: %d.",nAudioLens, audioframe->iseriesnumber);
|
|
|
}
|
|
|
-
|
|
|
- if (m_bIsAudioTransOn && NULL != m_salestransqueue){
|
|
|
- if (m_salestransqueue->Enqueue(audioframe)){
|
|
|
- //if (0 == audioframe->iseriesnumber%100){
|
|
|
- //m_pHostApi->Debug("audio frame enqueue sales trans queue, and frame series number is %d.", audioframe->iseriesnumber);
|
|
|
- //}
|
|
|
- }
|
|
|
- else{
|
|
|
- //m_pHostApi->Debug("audio frame enqueue sales trans queue failed, and frame series number is %d.", audioframe->iseriesnumber);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
else{
|
|
|
//m_pHostApi->Debug("get audio from m_audioqueue failed.");
|
|
@@ -2006,36 +1957,35 @@ private:
|
|
|
return &iRet;
|
|
|
}
|
|
|
public:
|
|
|
- //开始录制 ly@2018/06/05
|
|
|
+
|
|
|
BOOL StartWmvRecord(int fps,int videoquality,const SubtitleParam *subtitleParam,BOOL bWholeSection,
|
|
|
BOOL bSessionManage,const char *pathname,int pathlength,const char *wmvfilename,int filenamelength, Rvc_RecordAudioParam_t* pAudioParam)//开始记录
|
|
|
{
|
|
|
- m_salestransqueue = NULL;
|
|
|
m_audioqueue = NULL;
|
|
|
m_localaudioqueue = new Clibaudioqueue((char *)m_audioqueuename);
|
|
|
+
|
|
|
m_salesaudioqueue = NULL;
|
|
|
- if (strlen(m_salesaudioqueuename) != 0)
|
|
|
- {
|
|
|
+ if (strlen(m_salesaudioqueuename) != 0){
|
|
|
m_salesaudioqueue = new Clibaudioqueue((char*)m_salesaudioqueuename);
|
|
|
}
|
|
|
+
|
|
|
m_videoqueue = NULL;
|
|
|
- if (strlen(m_videoqueuename) != 0)
|
|
|
- {
|
|
|
+ if (strlen(m_videoqueuename) != 0){
|
|
|
m_videoqueue = new Clibvideoqueue((char*)m_videoqueuename);
|
|
|
}
|
|
|
+
|
|
|
m_videoqueue2 = NULL;
|
|
|
- if (strlen(m_videoqueue2name) != 0)
|
|
|
- {
|
|
|
+ if (strlen(m_videoqueue2name) != 0){
|
|
|
m_videoqueue2 = new Clibvideoqueue((char*)m_videoqueue2name);
|
|
|
}
|
|
|
+
|
|
|
m_remotevideoqueue = NULL;
|
|
|
- if (strlen(m_remotevideoqueuename) != 0)
|
|
|
- {
|
|
|
+ if (strlen(m_remotevideoqueuename) != 0){
|
|
|
m_remotevideoqueue = new Clibvideoqueue((char*)m_remotevideoqueuename);
|
|
|
}
|
|
|
+
|
|
|
m_remoteaudioqueue = NULL;
|
|
|
- if (strlen(m_remoteaudioqueuename) != 0)
|
|
|
- {
|
|
|
+ if (strlen(m_remoteaudioqueuename) != 0){
|
|
|
m_remoteaudioqueue = new Clibaudioqueue((char*)m_remoteaudioqueuename);
|
|
|
}
|
|
|
|
|
@@ -2063,21 +2013,8 @@ public:
|
|
|
m_videoquality = 75;
|
|
|
}
|
|
|
|
|
|
- //if (audioOutBitRate < 8 || audioOutBitRate > 256){
|
|
|
- // //m_pHostApi->Debug("warn: audioOutBitRate is illegal, will use default instead!");
|
|
|
- // //m_audioOutBitRate = 8000;
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // m_audioOutBitRate = audioOutBitRate*1000;
|
|
|
- //}
|
|
|
- //远程双录双声道,输出码率是原来的2倍
|
|
|
- //if (eStand2Agent == eRecordType || ePad2Agent == eRecordType){
|
|
|
- // m_audioOutBitRate *= 2;
|
|
|
- //}
|
|
|
-
|
|
|
memset(&m_SubtitleParam, 0, sizeof(SubtitleParam));
|
|
|
- if(subtitleParam != NULL) // 接收字幕信息 add by ly
|
|
|
+ if(subtitleParam != NULL) // 接收字幕信息
|
|
|
{
|
|
|
memcpy(&m_SubtitleParam, subtitleParam, sizeof(SubtitleParam));
|
|
|
}
|
|
@@ -2095,24 +2032,13 @@ public:
|
|
|
m_audioqueue = m_salesaudioqueue;
|
|
|
}
|
|
|
|
|
|
- //Dbg("m_audioOutBitRate = %d.", m_audioOutBitRate);
|
|
|
m_pHostApi->Debug("record output audio quality type is = %s, noise suppression flag is %s, noise suppression policy is %d, audio transfer flag is %s.", audio_quality_type_table[m_eAudioType], m_bIsAudioNsOn ? "true":"false", m_iNsPolicy, m_bIsAudioTransOn ? "true":"false");
|
|
|
- //m_salestransqueue = new Clibaudiotransqueue(m_FileName);
|
|
|
- if (m_bIsAudioTransOn){
|
|
|
- m_salestransqueue = new Clibaudiotransqueue(m_FileName);
|
|
|
- if (NULL != m_salestransqueue){
|
|
|
- Dbg("get sales trans audio queue success, queue name is %s and addr is 0x%08x.", m_FileName, m_salestransqueue);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (m_hRecordThread == NULL)
|
|
|
- {
|
|
|
- return StartRecord();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return FALSE;
|
|
|
+ if (0 != m_nRecordthreadId){
|
|
|
+ StopWmvRecord();
|
|
|
}
|
|
|
+
|
|
|
+ return StartRecord();
|
|
|
}
|
|
|
|
|
|
BOOL StopWmvRecord() //退出
|
|
@@ -2126,7 +2052,6 @@ public:
|
|
|
else {
|
|
|
m_pHostApi->Debug("thread join video record thread failed!");
|
|
|
}
|
|
|
- m_eRecordType = eSingleSide;
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
@@ -2188,7 +2113,7 @@ Clibwmvrecord::~Clibwmvrecord()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-// ly@2018/06/05
|
|
|
+
|
|
|
BOOL Clibwmvrecord::StartWmvRecord(
|
|
|
int fps,
|
|
|
int videoquality,
|
|
@@ -2229,7 +2154,7 @@ BOOL Clibwmvrecord::SetRightVideoWaterMark(wchar_t* strWaterMark)
|
|
|
}
|
|
|
|
|
|
size_t ulen = wcslen(strWaterMark);
|
|
|
- m_pImpl->setRightWaterMark(strWaterMark, ulen);
|
|
|
+ bRet = m_pImpl->setRightWaterMark(strWaterMark, ulen*sizeof(wchar_t));
|
|
|
|
|
|
return bRet;
|
|
|
}
|