|
@@ -3,7 +3,7 @@
|
|
|
#include "LocalMediaPlay_msg_g.h"
|
|
|
#include "fileutil.h"
|
|
|
#include "y2k_time.h"
|
|
|
-
|
|
|
+#include "../../Other/rvcmediacommon/rvc_media_common.h"
|
|
|
|
|
|
#define DEFAULT_SLEEP_TIME (60 * 1000)
|
|
|
#define DEFAULT_ADVERT_TYPE 'A'
|
|
@@ -92,6 +92,7 @@ CLocalMediaPlayEntity::CLocalMediaPlayEntity()
|
|
|
m_badplayflag = true;
|
|
|
m_bgetflag = false;
|
|
|
m_bgetico = false;
|
|
|
+ m_remote_audio_queue = NULL;
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
ZeroMemory(&m_mediaParam, sizeof(MediaPlayParam));
|
|
@@ -514,6 +515,37 @@ int CLocalMediaPlayEntity::GetAudioOutDevName(char* strDev, size_t uLen)
|
|
|
int CLocalMediaPlayEntity::PlayingAudioDataCallback(audio_param_t* param, const void* input, unsigned long uaudiolen)
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
+ if (m_bStartRecord) {
|
|
|
+ if (8000 == param->freq && 1 == param->channels && 1 == param->fmt) {
|
|
|
+ Dbg("%s:%d uaudiolen:%d", __FUNCTION__, __LINE__, uaudiolen);
|
|
|
+ int icount = (uaudiolen + m_leftlen) / RVC_AUDIO_LEN;
|
|
|
+ if (icount > 0) {
|
|
|
+ memcpy(m_audiobuffer + m_leftlen, (char*)input, icount * RVC_AUDIO_LEN - m_leftlen);
|
|
|
+ for (int i = 0; i < icount; i++) {
|
|
|
+ audio_frame frm;
|
|
|
+ char straudio[RVC_AUDIO_LEN] = { 0 };
|
|
|
+ memcpy(straudio, m_audiobuffer + i * RVC_AUDIO_LEN, RVC_AUDIO_LEN);
|
|
|
+ frm.bitspersample = 16;
|
|
|
+ frm.format = param->fmt;
|
|
|
+ frm.data = straudio;
|
|
|
+ frm.framesize = RVC_AUDIO_LEN;
|
|
|
+ frm.nchannels = param->channels;
|
|
|
+ frm.samplespersec = param->freq;
|
|
|
+ if (!m_remote_audio_queue->InsertAudio(&frm)) {
|
|
|
+ Dbg("InsertAudio failed! frameCount:%d", frm.framesize);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Dbg("%s:%d InsertAudio success", __FUNCTION__, __LINE__);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ memset(m_audiobuffer, 0, RVC_AUDIO_BUFFER_LEN);
|
|
|
+ }
|
|
|
+ m_leftlen = (uaudiolen + m_leftlen) % RVC_AUDIO_LEN;
|
|
|
+ if ((0 != m_leftlen) && (icount * RVC_AUDIO_LEN < uaudiolen)) {
|
|
|
+ memcpy(m_audiobuffer, (char*)input + icount * RVC_AUDIO_LEN, m_leftlen);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return iRet;
|
|
|
}
|
|
@@ -595,20 +627,32 @@ void CLocalMediaPlayEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID n
|
|
|
const DWORD dwSysError, const DWORD dwUserCode, const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName, const char *pszMessage)
|
|
|
{
|
|
|
- if (dwUserCode == LOG_EVT_SELFCHECK_IEBROWSER_IDLE)
|
|
|
- {
|
|
|
+ if (dwUserCode == LOG_EVT_SELFCHECK_IEBROWSER_IDLE){
|
|
|
Dbg("IEBrowser to idle, stop all media!");
|
|
|
StopAll();
|
|
|
}
|
|
|
+ else if(LOG_EVT_UI_STARTREMOTERECORD == dwUserCode){
|
|
|
+ Dbg("Start remote record.");
|
|
|
+ m_bStartRecord = true;
|
|
|
+ memset(m_audiobuffer, 0, RVC_AUDIO_LEN);
|
|
|
+ m_leftlen = 0;
|
|
|
+ m_remote_audio_queue = new Clibaudioqueue(REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
|
|
|
+ }
|
|
|
+ else if (LOG_EVT_UI_STOPREMOTERECORD == dwUserCode) {
|
|
|
+ Dbg("Stop remote record.");
|
|
|
+ m_bStartRecord = false;
|
|
|
+ if (NULL != m_remote_audio_queue) {
|
|
|
+ delete m_remote_audio_queue;
|
|
|
+ m_remote_audio_queue = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
void CLocalMediaPlayEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
-
|
|
|
ErrorCodeEnum Error = __OnStart(Error_Succeed);
|
|
|
-
|
|
|
pTransactionContext->SendAnswer(Error);
|
|
|
}
|
|
|
|
|
@@ -657,6 +701,8 @@ void CLocalMediaPlayEntity::OnStarted()
|
|
|
loadDefaultMedia();
|
|
|
|
|
|
GetFunction()->SubscribeLog(m_SubIDIEIdle, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_SELFCHECK_IEBROWSER_IDLE, NULL, false);
|
|
|
+ GetFunction()->SubscribeLog(m_SubIDStartRecord, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD, NULL, false);
|
|
|
+ GetFunction()->SubscribeLog(m_SubIDStopRecord, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD, NULL, false);
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
m_scanThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)& qryMedia, this, 0, NULL);
|
|
@@ -702,6 +748,9 @@ ErrorCodeEnum CLocalMediaPlayEntity::__OnClose(ErrorCodeEnum preOperationError)
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
GetFunction()->UnsubscribeLog(m_SubIDIEIdle);
|
|
|
+ GetFunction()->UnsubscribeLog(m_SubIDStartRecord);
|
|
|
+ GetFunction()->UnsubscribeLog(m_SubIDStopRecord);
|
|
|
+
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|