Link to home
Start Free TrialLog in
Avatar of selas
selas

asked on

How to stream mic audio through network?

i want to stream mic-in audio through network
how to do it?
that i need to use?
ASKER CERTIFIED SOLUTION
Avatar of Lee_Nover
Lee_Nover

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lee_Nover
Lee_Nover

lol .. 'you CAN check my example ..' :D
oh . the binaries are in the VoIP.zip file :) VoIP_src.zip are only the sources
Well you could use indy IdTCPClient IdTCPServer and the readstream writestream functions

procedure SendToServer;
var
  Client: TIdTCPClient;
  AudioStream: TMemoryStream;
begin
  AudioStream := TMemoryStream.Create;
 
  While Playing do
  begin
    AudioStream.Position := 0;
    ....Code to put Audio into stream...

   Client := TIdTCPClient.Create(nil);
   Client.Host := SERVER_HOST;
   Client.Port := SERVER_PORT;

   Client.WriteStream(AudioStream, True, True);
  end;
  AudioStream.Free;
end;

procedure OnExecute(AThread: TIdThread);
var
  AudioStream: TMemoryStream;
  iSize: Integer;
begin
  AudioStream := TMemoryStream.Create;
 
  iSize := AThread.Connection.ReadInteger;
  AThread.Connection.ReadStream(AudioStream, iSize);
 
  ...Code the move the streamed audio into a buffer..
  AudioStream.Free;
end;

Its probably not an ideal solution, but would do the job. you could tell to write directly to a audio buffer of type TMemoryStream and when the buffer reaches a predetermined size the player started reading from the buffer until the end is reached or the buffer is empty and it needs to wait
alc4emy5t: you haven't checked my example :P
Avatar of selas

ASKER

//   ....Code to put Audio into stream...

what code should be to add mic audio to stream?

and i get error on -> While Playing do
my example for streaming audio is the exact thing he asked about .. a working example that's been used by many :)