[英]Live audio stream using tcp indy10
From their example http://www.delphiarea.com/products/delphi-packages/waveaudio/ (TLiveAudioRecorder) 从他们的例子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 ? 如何使用TCP indy10发送音频流? something like
Connection.IOHandler.Write(Buffer, 0, true);
像
Connection.IOHandler.Write(Buffer, 0, true);
You can either: 你可以:
Use RawToBytes()
to copy the buffer data to a TIdBytes
and then pass that to TIdIOHandler.Write(TIdBytes)
: 使用
RawToBytes()
将缓冲区数据复制到TIdBytes
,然后将其传递给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)
: 使用
TIdMemoryBufferStream
将缓冲区包装在TStream
并将其传递给TIdIOHandler.Write(TStream)
:
Strm := TIdMemoryBufferStream.Create(Buffer, BufferSize); Connection.IOHandler.Write(Strm); Strm.Free;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.