문제

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);

도움이 되었습니까?

해결책

You can either:

  1. Use RawToBytes() to copy the buffer data to a TIdBytes and then pass that to TIdIOHandler.Write(TIdBytes):

    Connection.IOHandler.Write(RawToBytes(Buffer^, BufferSize));
    
  2. 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;
    
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top