//----------------------------------------------
//接收到数据
//----------------------------------------------
procedure TForm1.UdpServerUDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
rBuf:array of shortint ;
sBuf:array of shortint ;
//smallint
Header
WaveHdr;
i : integer;
memblock : Pointer;
size : integer;
begin
//adpcm编码
{
size := adata.Size ;
setLength(rBuf,size);
setLength(sBuf,size);
Fstate.valprev := 0 ;
Fstate.index := 0 ;
adpcmdecoder(rbuf,sbuf,adata.size,Fstate);
}
//size := adata.Size ;
//showmessage(intTostr(size));
//G729编码
setLength(rBuf,60);
setLength(sBuf,960);
adata.ReadBuffer(rBuf[0],60);
DecodeAudioData(rbuf, 60, sbuf) ;
Header:=new(PWaveHdr);
memblock:=new(pointer);
getmem(memblock,960);
move(sbuf[0],memBlock^,960);
Header.lpdata:=memblock;
Header.dwbufferlength:=960;
Header.dwbytesrecorded:=960;
Header.dwUser:=0;
Header.dwflags:=0;
Header.dwloops:=0;
i:=WaveOutPrepareHeader(HWaveOut^,Header,sizeof(TWaveHdr));
if i<> 0 then
showmessage('WaveOutPrepareHeader error');
//播放声波数据
i:=WaveOutWrite(HWaveOut^,Header,sizeof(TWaveHdr));
if i<> 0 then
showmessage('WaveOutWrite error');
end;