来自他们的例子http://www.delphiarea.com/products/delphi-packages/waveaudio/(TLiveAudioRecorder)
//sender
procedure TMainForm.LiveAudioRecorderData(Sender: TObject;
const Buffer: Pointer; BufferSize: Cardinal; var FreeIt: Boolean);
var
I: Integer;
begin
FreeIt := True;
for I := tcpServer.Socket.ActiveConnections - 1 downto 0 do
with tcpServer.Socket.Connections[I] do
if Data = Self then // the client is ready
SendBuf(Buffer^, BufferSize);
end;
如何使用TCP indy10发送音频流?
像Connection.IOHandler.Write(Buffer, 0, true);
答案 0 :(得分:2)
你可以:
使用RawToBytes()
将缓冲区数据复制到TIdBytes
,然后将其传递给TIdIOHandler.Write(TIdBytes)
:
Connection.IOHandler.Write(RawToBytes(Buffer^, BufferSize));
使用TIdMemoryBufferStream
将缓冲区换成TStream
并将其传递给TIdIOHandler.Write(TStream)
:
Strm := TIdMemoryBufferStream.Create(Buffer, BufferSize);
Connection.IOHandler.Write(Strm);
Strm.Free;