紧急求助!有关用acm控件实现语音聊天。(100分)

  • 主题发起人 主题发起人 sandra_phh
  • 开始时间 开始时间
S

sandra_phh

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在想实现语音聊天,用acm控件,我曾经有一个能够实现的例子,是在delphi 5中
实现的,但是我把acm控件加到delphi 6中,也步报错,也不传语音,请问是什么原因,
请大家帮忙。
我的代码:server端和client端的代码是一样的,只是client端的udp控件的localport和remoteport
与server端的是相反的。
server端:
unit ipunit;

interface

uses
Windows, SysUtils, Classes, Controls, Forms,
ACMWaveOut,mmsystem, ACMWaveIn, ACMDialog, StdCtrls,
Graphics, ExtCtrls, ComCtrls, NMUDP;

type
TForm1 = class(TForm)
ACMDialog: TACMDialog;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
udpServer: TNMUDP;
ACMWaveIn: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ACMWaveInData(data: Pointer;
size: Integer);
procedure udpServerDataReceived(Sender: TComponent;
NumberBytes: Integer;
FromIP: String;
Port: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var format:pointer;
begin

udpServer.RemoteHost := edit1.Text;
format:=ACMDialog.OpenDialog;
if format=nil then
exit;
ACMWaveIn.Open(format);
ACMWaveOut1.Open(format);
Button1.Enabled:=false;
Button2.Enabled:=true;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

ACMWaveIn.Close;
ACMWaveOut1.Close
Button1.Enabled:=true;
Button2.Enabled:=false;
end;


procedure TForm1.ACMWaveInData(data: Pointer;
size: Integer);
var
mdata:array[1..400000] of char;
k:integer;
mysize : Integer
begin

mysize := size
for k:=1 to sizedo
mdata[k]:=pchar(dword(data)+dword(k-1))^;
udpServer.SendBuffer(mdata,size);
end;


procedure TForm1.udpServerDataReceived(Sender: TComponent;
NumberBytes: Integer;
FromIP: String;
Port: Integer);
var
mdata:array[1..400000] of char;
data:Pchar;
begin

udpServer.ReadBuffer(mdata,NumberBytes);
data:=pchar(dword(@mdata));
if NumberBytes <> -1 then

ACMWaveOut1.PlayBack(data,NumberBytes);
end;

end.

 
len:=udpServer.ReadBuffer(mdata,NumberBytes);
data:=pchar(dword(@mdata));
if len <> -1 then

ACMWaveOut1.PlayBack(data,len);
 
后退
顶部