当前位置: 首页>>代码示例>>C++>>正文


C++ VideoSource::PlayCallBackAudio方法代码示例

本文整理汇总了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();
//.........这里部分代码省略.........
开发者ID:wwllww,项目名称:LiveStream_MultiIntance,代码行数:101,代码来源:MediaAudio.cpp


注:本文中的VideoSource::PlayCallBackAudio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。