Reputation: 3
From their example 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;
How can I send the audio stream using TCP indy10 ?
something like Connection.IOHandler.Write(Buffer, 0, true);
Upvotes: 0
Views: 1786
Reputation: 597036
You can either:
Use RawToBytes()
to copy the buffer data to a TIdBytes
and then pass that to TIdIOHandler.Write(TIdBytes)
:
Connection.IOHandler.Write(RawToBytes(Buffer^, BufferSize));
Use TIdMemoryBufferStream
to wrap the buffer in a TStream
and pass that to TIdIOHandler.Write(TStream)
:
Strm := TIdMemoryBufferStream.Create(Buffer, BufferSize);
Connection.IOHandler.Write(Strm);
Strm.Free;
Upvotes: 2