unit ipunit;
interface
uses
Windows, SysUtils, Classes, Controls, Forms,
ACMWaveOut,mmsystem, ACMWaveIn, ACMDialog, StdCtrls,
Graphics, ExtCtrls, ComCtrls, Sockets, IdBaseComponent,
IdComponent, IdUDPBase, IdUDPServer,IdSocketHandle, IdUDPClient;
type
TForm1 = class(TForm)
ACMDialog1: TACMDialog;
ACMWaveIn1: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
IdUDPServer1: TIdUDPServer;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ACMWaveIn1Data(data: Pointer;
size: Integer);
procedure IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var format
ointer;
begin
format:=ACMDialog1.OpenDialog;
if format=nil then
exit;
IdUDPServer1.Active:=true;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
Button1.Enabled:=false;
Button2.Enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ACMWaveIn1.Close;
ACMWaveOut1.Close;
IdUDPServer1.Active:=false;
Button1.Enabled:=true;
Button2.Enabled:=false;
end;
procedure TForm1.ACMWaveIn1Data(data: Pointer;
size: Integer);
var
mdata:array[1..400000] of char;
k:integer;
begin
for k:=1 to sizedo
mdata[k]:=pchar(dword(data)+dword(k-1))^;
IdudpServer1.SendBuffer('192.168.245.11',5623,mdata,size);
end;
{var
mdata:array[1..10000] of char;
begin
IdUDPServer1.SendBuffer('192.168.245.11',5623,data,size);
end;
}
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
begin
DataStringStream := TStringStream.Create('');
try
DataStringStream.CopyFrom(AData, AData.Size);
ACMWaveOut1.PlayBack(AData,AData.Size);
finally
DataStringStream.Free;
end;
end;
end.