本文整理汇总了C++中VideoSource::PlayCallBackAudio方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoSource::PlayCallBackAudio方法的具体用法?C++ VideoSource::PlayCallBackAudio怎么用?C++ VideoSource::PlayCallBackAudio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoSource
的用法示例。
在下文中一共展示了VideoSource::PlayCallBackAudio方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PushAudio
/**************************************************
获取音频数据函数
参数:
lpData :输入数据的内存
size:输入数据的长度
pts:输入数据的时间戳
***************************************************/
void CDemandMediaAudio::PushAudio(const void *lpData, unsigned int size, int64_t pts, IBaseVideo *Video, bool bCanPlay)
{
VideoSource *Source = dynamic_cast<VideoSource*>(Video);
if (!m_uBlockSize || !Source)
return;
if (m_sAudioParam.iChannel <= 2)
{
if (fVolume != 1.0f)
{
short *Tem = (short*)lpData;
for (int i = 0; i < size; i += 2)
{
long sVolume = Tem[i / 2];
sVolume *= fVolume;
if (sVolume > 0x7fff)
{
sVolume = 0x7fff;
}
else if (sVolume < -0x8000)
{
sVolume = -0x8000;
}
Tem[i / 2] = (short)sVolume;
}
}
Source->PlayCallBackAudio((LPBYTE)lpData, size);
}
else
{
UINT totalSamples = size * 8 / m_sAudioParam.iBitPerSample;
if (TemconvertBuffer.Num() < totalSamples)
TemconvertBuffer.SetSize(totalSamples);
OutputconvertBuffer.SetSize(totalSamples / m_sAudioParam.iChannel * 2);
if (m_sAudioParam.iBitPerSample == 8)
{
float *tempConvert = TemconvertBuffer.Array();
char *tempSByte = (char*)lpData;
while (totalSamples--)
{
*(tempConvert++) = float(*(tempSByte++)) / 127.0f;
}
}
else if (m_sAudioParam.iBitPerSample == 16)
{
float *tempConvert = TemconvertBuffer.Array();
short *tempShort = (short*)lpData;
while (totalSamples--)
{
*(tempConvert++) = float(*(tempShort++)) / 32767.0f;
}
}
else if (m_sAudioParam.iBitPerSample == 24)
{
float *tempConvert = TemconvertBuffer.Array();
BYTE *tempTriple = (BYTE*)lpData;
TripleToLong valOut;
while (totalSamples--)
{
TripleToLong &valIn = (TripleToLong&)tempTriple;
valOut.wVal = valIn.wVal;
valOut.tripleVal = valIn.tripleVal;
if (valOut.tripleVal > 0x7F)
valOut.lastByte = 0xFF;
*(tempConvert++) = float(double(valOut.val) / 8388607.0);
tempTriple += 3;
}
}
else if (m_sAudioParam.iBitPerSample == 32)
{
float *tempConvert = TemconvertBuffer.Array();
long *tempShort = (long*)lpData;
while (totalSamples--)
{
*(tempConvert++) = float(double(*(tempShort++)) / 2147483647.0);
}
}
float *inputTemp = TemconvertBuffer.Array();
//.........这里部分代码省略.........