|
|
@@ -92,6 +92,22 @@ static uint32_t Transform2Pcm8k(char* pdstbuf, const uint32_t udstlen, char* pcm
|
|
|
return nLen;
|
|
|
}
|
|
|
|
|
|
+static uint32_t Transform48k2Pcm8k(char* pdstbuf, const uint32_t udstlen, char* pcm_48kdata, int idata_size, int ichannels)
|
|
|
+{
|
|
|
+ uint32_t nLen = 0;
|
|
|
+ int nSkipByte = 6 * ichannels;
|
|
|
+ int nSourcePos = 0;
|
|
|
+ char* pcm_8k_data = (char*)pdstbuf;
|
|
|
+ for (nLen = 0; nSourcePos + 1 < idata_size; nLen = nLen + 2)
|
|
|
+ {
|
|
|
+ pcm_8k_data[nLen] = pcm_48kdata[nSourcePos];
|
|
|
+ pcm_8k_data[nLen + 1] = pcm_48kdata[nSourcePos + 1];
|
|
|
+
|
|
|
+ nSourcePos = nSourcePos + nSkipByte * 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ return nLen;
|
|
|
+}
|
|
|
|
|
|
static uint32_t PcmConvert(char* pdstbuf, const uint32_t udstlen, char* pcmsrcdata, int isrclen, int isamplespersec, int ichannels)
|
|
|
{
|
|
|
@@ -103,17 +119,33 @@ static uint32_t PcmConvert(char* pdstbuf, const uint32_t udstlen, char* pcmsrcda
|
|
|
else if (44100 == isamplespersec) {
|
|
|
uLen = Transform2Pcm8k(pdstbuf, udstlen, pcmsrcdata, isrclen, 2);
|
|
|
}
|
|
|
+ else if (48000 == isamplespersec) {
|
|
|
+ uLen = Transform48k2Pcm8k(pdstbuf, udstlen, pcmsrcdata, isrclen, 2);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
if (44100 == isamplespersec) {
|
|
|
uLen = Transform2Pcm8k(pdstbuf, udstlen, pcmsrcdata, isrclen, 1);
|
|
|
}
|
|
|
+ else if (48000 == isamplespersec) {
|
|
|
+ uLen = Transform48k2Pcm8k(pdstbuf, udstlen, pcmsrcdata, isrclen, 1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return uLen;
|
|
|
}
|
|
|
|
|
|
|
|
|
+static bool IsSupportAudioSamprate(int isamprate)
|
|
|
+{
|
|
|
+ bool bret = false;
|
|
|
+ if (8000 == isamprate || 44100 == isamprate || 48000 == isamprate) {
|
|
|
+ bret = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return bret;
|
|
|
+}
|
|
|
+
|
|
|
static void CStringSplit(char* str, char** result, const char* del)
|
|
|
{
|
|
|
char* pdata = NULL;
|
|
|
@@ -856,9 +888,12 @@ int CLocalMediaPlayEntity::PlayingAudioDataCallback(audio_param_t* param, const
|
|
|
if (false == m_bloged) {
|
|
|
m_bloged = true;
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_PLAYING_AUDIO_INFOS, CSimpleStringA::Format("audio param target (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d), audio format(%d)).", param->channels, param->freq, param->channel_layout, param->frame_size, param->bytes_per_sec, param->fmt).GetData());
|
|
|
+ if (!IsSupportAudioSamprate(param->freq)) {
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_EVT_NOTSUPPORT_AUDIOFORMAT, CSimpleStringA::Format("not support audio param (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d), audio format(%d)).", param->channels, param->freq, param->channel_layout, param->frame_size, param->bytes_per_sec, param->fmt).GetData());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d uaudiolen:%d", __FUNCTION__, __LINE__, uaudiolen);
|
|
|
+ //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d uaudiolen:%d", __FUNCTION__, __LINE__, uaudiolen);
|
|
|
//AV_SAMPLE_FMT_S16 == 1
|
|
|
if (1 == param->fmt) {
|
|
|
int isingle_audioframe_len = param->bytes_per_sec/50;
|
|
|
@@ -893,9 +928,9 @@ int CLocalMediaPlayEntity::PlayingAudioDataCallback(audio_param_t* param, const
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("InsertAudio failed! frameCount:%d", frm.framesize);
|
|
|
}
|
|
|
else {
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d InsertAudio(series number = %d) success and framesize = %d.", __FUNCTION__, __LINE__, frm.iseriesnumber, frm.framesize);
|
|
|
+ //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d InsertAudio(series number = %d) success and framesize = %d.", __FUNCTION__, __LINE__, frm.iseriesnumber, frm.framesize);
|
|
|
if (m_bRecordPCM && m_pFile){
|
|
|
- fwrite(frm.data, isingle_audioframe_len, 1, m_pFile);
|
|
|
+ fwrite(frm.data, frm.framesize, 1, m_pFile);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -908,6 +943,12 @@ int CLocalMediaPlayEntity::PlayingAudioDataCallback(audio_param_t* param, const
|
|
|
if (!m_remote_audio_queue->InsertAudio(&frm)) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("InsertAudio failed! frameCount:%d", frm.framesize);
|
|
|
}
|
|
|
+ else {
|
|
|
+ //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d InsertAudio(series number = %d) success and framesize = %d.", __FUNCTION__, __LINE__, frm.iseriesnumber, frm.framesize);
|
|
|
+ if (m_bRecordPCM && m_pFile) {
|
|
|
+ fwrite(frm.data, frm.framesize, 1, m_pFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
delete []straudio;
|