?? pcm2g729atransformer.cxx
字號(hào):
// PCM2G729ATransformer.cpp: implementation of the PCM2G729ATransformer class.
//
//////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "PCM2G729ATransformer.h"
#include "AudioSampleManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
PCM2G729ATransformer::PCM2G729ATransformer()
{
char subFacilityName[100];
sprintf(subFacilityName, "PCM2G729ATransformer:%x", this);
tracer.SetSubFacilityName(subFacilityName);
SetTraceLevel();
}
PCM2G729ATransformer::~PCM2G729ATransformer()
{
}
int
PCM2G729ATransformer::SetTraceLevel()
{
#ifdef WIN32
long SystemMask = 0;
if ((SystemMask = GetRegKeyLong(HKEY_CURRENT_USER, "Software\\Cisco Systems\\MTC\\Tracing", "AllComponents", 0x0)) == 0)
{
SystemMask = GetRegKeyLong(HKEY_CURRENT_USER, "Software\\Cisco Systems\\MTC\\Tracing", "PCM2G729ATransformer", 0x100000);
}
#endif
return 0;
}
int
PCM2G729ATransformer::StartTransform()
{
g729Codec.StartEncoder();
return 0;
}
int
PCM2G729ATransformer::StopTransform()
{
g729Codec.StopEncoder();
return 0;
}
int
PCM2G729ATransformer::TransformAudioSamples(std::vector<std::pair<AudioSample *, AudioSource *> > &data, AudioSample **ppAudioSample)
{
AudioSample *inSample = data[0].first;
AudioSample *outSample;
int result = 0;
result = AudioSampleManager::GetInstance()->GetAudioSample(&outSample);
if (outSample)
{
*ppAudioSample = outSample;
WAVEFORMATEX wfmx = WaveFormat::GetWaveFormat(WaveFormat_G729);
outSample->SetFormat(wfmx);
if (inSample->DataSize() <= 0)
{
outSample->SetSilenceDuration(inSample->GetSilenceDuration());
}
else
{
int outputSize = outSample->BufferSize();
result = g729Codec.Encode(inSample->Data(), inSample->DataSize(), outSample->Data(), &outputSize);
outSample->SetDataSize(outputSize);
}
}
else
{
result = -10;
}
return result;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -