TMyBlock=record
m_username:string[16];
SendToName:string[16];
end;
procedure TClientForm.GrabberBuffer(sender: TObject; SampleTime: Double; pBuffer: Pointer; BufferLen: Integer);
var
Stream: TStream;
MyBlock:TMyBlock;
begin
Stream:=TStream.Create;
MyBlock.m_username:='brucelee';
try
if VideoWindow.VMRGetBitmap(Stream) then image.Picture.Bitmap.LoadFromStream(Stream);
Grabber.GetBitmap(Image1.Picture.Bitmap);
if ConnectForm.TCPClient.Connected then
begin
try
ConnectForm.TCPClient.WriteBuffer(MyBlock,SizeOf(MyBlock),true);
ConnectForm.TCPClient.WriteStream(MyBlock.m_stream,true);
except
end;
end;
finally
Stream.Free;
end;
end;
服务端:
procedure TServerForm.TCPServerExecute(AThread: TIdPeerThread);
var
jpg: TJpegImage;
MyBlock:TMyBlock;
getstream:TStream;
begin
if AThread.Connection.Connected and not AThread.Terminated then
begin
getstream:=TStream.Create;
AThread.Connection.ReadBuffer(MyBlock,SizeOf(MyBlock));
AThread.Connection.ReadStream(getstream,-1,true);
listbox1.Items.Add(MyBlock.m_username);
getstream.Position:=0;
jpg := TJpegImage.Create;
jpg.LoadFromStream(getstream);
Image.Picture.Bitmap.Assign(jpg);
jpg.Free;
getstream.Free;
end;
end;
试试吧,我没法做调试,请谅