请问一下我希望将不断录制的语音文件传输到其他电脑上,还希望语音文件附带一些文本信息???+(100分)

  • 主题发起人 主题发起人 mike1031
  • 开始时间 开始时间
M

mike1031

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢大家!~~~~
 
最好用流的方式传送,不然只好用ftp方式了
 
可不可以讲具体点啊???
 
自定义UDP数据包,可自定义包类型,然后某些包为文本,某些包为数据(语音)
 
对,用TCP/IP方式传输入,将录制的buffer用自已定义的包头封装发出,再在客户端解开,语音和文本可用不同的包头区别,也可以建不同的socket用不同的port传
 
类似于网络电话
使用了wavemix控件,自己找一下
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, NMUDP, ACMWaveOut, ACMWaveIn, ACMDialog,
ComCtrls, Mmsystem;

type
TForm1 = class(TForm)
ACMDialog1: TACMDialog;
ACMWaveIn1: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
NMUDP1: TNMUDP;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ACMWaveIn1Data(data: Pointer; size: Integer);
procedure NMUDP1DataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: string; Port: Integer);
procedure FormCreate(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
PlayPackets: integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
format: pointer;
begin
NMUDP1.Remotehost := edit1.text;
format := ACMDialog1.OpenDialog;
if format = nil then exit;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
Button1.Enabled := false;
Button2.Enabled := true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ACMWaveIn1.Close;
ACMWaveOut1.Close;
Button1.Enabled := true;
Button2.Enabled := false;
end;

procedure TForm1.ACMWaveIn1Data(data: Pointer; size: Integer);
var
mdata: array[1..15000] of char;
k: integer;
//str: string;
begin
{str := 'send:';
for k := 1 to 10 do str := str + ' ' + inttostr(integer(pchar(dword(data) + k - 1)^));
str := 'send:' + inttostr(size);
memo1.lines.add(str);}
for k := 1 to size do mdata[k] := pchar(dword(data) + k - 1)^;
NMUDP1.SendBuffer(mdata, size);
end;

procedure TForm1.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: string; Port: Integer);
var
mdata: array[1..15000] of char;
data: Pchar;
// str: string;
// k: integer;
begin
NMUDP1.ReadBuffer(mdata, NumberBytes);
data := pchar(dword(@mdata));
// str:='recv:';
// for k:=1 to 10 do str:=str+' '+inttostr(integer(pchar(dword(data)+k-1)^));
// str:='recv:'+inttostr(NumberBytes);
// memo1.lines.add(str);
label1.caption := inttostr(PlayPackets);
inc(PlayPackets);
ACMWaveOut1.PlayBack(data, NumberBytes);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ACMWaveOut1.visible := false;
ACMWaveIn1.visible := false;
NMUDP1.ReportLevel := Status_Basic;
NMUDP1.LocalPort := 6668;
NMUDP1.RemotePort := 6668;
PlayPackets := 0;
label1.caption := inttostr(PlayPackets);
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
var
t, v: Longint;
begin
// if a=0 then Exit;
t := TrackBar1.Position;
v := (t shl 8) or (t shl 24);
waveOutSetVolume(0, v);
end;

end.
 
多人接受答案了。
 
后退
顶部