Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am making a simple chat application where it has already a webcam or live video stream, now I want to add a live audio streaming from microphone. I am currently using TCP indy 10. I heard that you can do this using ACMout.pas / ACMin.pas etc(ACM). Problem is I can't find any example online, I already have the ACM headers.

If somebody can share any example of this, or could make one, please. Thank you so much.

EDIT:
I am using ACM Components v.1.6 from torry.net[^]
in the demo it is using UDP,I tried to convert it to TCP, here is my code

Delphi
//sending 

procedure TSendFrm.ACMIn1Data(Sender: TACMComponent; aDataPtr: Pointer;
  aDataSize: Cardinal);
begin
  //Sock.SendBuffer(aDataPtr^,aDataSize);  // <-udp
  //IdTCPClient1.IOHandler.WriteBufferOpen;
  try
    IdTCPClient1.IOHandler.Write( RawToBytes(aDataPtr^,aDataSize ) );
  finally
   //IdTCPClient1.IOHandler.WriteBufferClose;
  end;

  Bytes:=Bytes+aDataSize;
  BytesLbl.Caption:=Format ('%u',[Bytes]);
  UpDate;
end;

//receiving end

procedure TRecvFrm.IdTCPServer1Execute(AContext: TIdContext);
var
  Ms : TMemoryStream;
  //Ms : TStream;
begin

  Ms := TMemoryStream.Create;
  
  AContext.Connection.IOHandler.ReadStream(Ms);
  Ms.Position := 0;
  ACMOut1.PlayBack(Ms);
  Bytes:=Bytes+Ms.Size;
  BytesLbl.Caption:=Format ('%u',[Bytes]);
  UpDate;

  Ms.Free;
end;


Still not working well for me. I am using indy 10
Posted
Updated 7-Jan-14 1:12am
v4
Comments
Maciej Los 5-Jan-14 11:50am    
I would like to say what have been said here: delphi-indy10-tcp-audio-streaming[^] ;)
Conclusio: there is no differ between sending audio and any other type of data.
Ronni2013 5-Jan-14 12:27pm    
I thought you need an third party program or component to do this ? I ain't that skillful.

Have a look at: https://code.google.com/p/siapen/[^]

You'll find VFrames.pas[^] if you dig into the code.

[Update]
1. Get raw data from ACM
2. Write the data to a MemoryStream
3. Send the MemoryStream using Indy.

Somthing similar to this:
with Owner.PeerThread.Connection do 
 begin 
  if Connected then 
  begin 
   OpenWriteBuffer; 
  try 
   WriteStream(memoryStream,True,True,LStreamPacket.Size); 
  finally
   CloseWriteBuffer; 
  end; 
 end;
end;


Best regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Maciej Los 5-Jan-14 11:47am    
Looks promising ;)
Espen Harlinn 5-Jan-14 11:57am    
I guess so, at least it shows how to access the web camera.
Maciej Los 5-Jan-14 12:13pm    
I'm not familiar with tcp programming, but - as i wrote in comment to the question - it's no differ between sending audio and any other data type. Of course, it's no so easy to access to the web camera. Above is good, promising example. ;)
Ronni2013 5-Jan-14 12:26pm    
I'm already using directx in capturing webcam images, i just need a live audio streaming demo(w/ source) using indy tcp
Ok i finally made it work with indy tcp

Delphi
if not InputBufferIsEmpty then
    begin
      Ms := TMemoryStream.Create;

      InputBuffer.ExtractToStream(Ms);
      Ms.Position := 0;
      ACMOut1.PlayBack(Ms);

      Bytes:=Bytes+Ms.Size;
      BytesLbl.Caption:=Format ('%u',[Bytes]);
      UpDate;

      Ms.Free;
    end;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900