El 16/01/2017 a las 23:10, fredvs escribió:
Hello,
What must be done to make:
- a url-mp3-file like 1) on server
That's just a file, you send it like a file with the proper MIME type,
is the client that reads information from the stream as needed.
- a url-mp3-chunk like 2) on server
This is a chuncked send, you start to send information, in the header
you do not express the length, so the client will read the file up to to
the socket close (and play it).
From the send side you must write to the socket instead to a file as
you are sampling from the media input. MP3 is not a stateless
compression format, this means that each audio frame may need several
previous frames to be able to play the current one. This need is the
reason that you sometimes ears a "bleep" sound at broadcast start (non
professional). Also this dependency means that you can not compress each
source audio chunck in an mp3 and broadcast it, you must compress audio
portion in chuncks as part of a single stream.
Pseudocode:
AcceptRemoteSocket(SocketID);
mp3compress:=TMP3Compressor.Create;
mp3compress.Open;
while SocketID.Active do begin
XBytes:=AudioGrabber.Grab(RawAudio,MaxRawAudio,250 millisec);
CompressedSize:=mp3Compress(RawAudio,XBytes,Mp3Output,Mp3OutBufferSize);
SocketID.Send(Mp3Output,CompressedSize);
end;
mp3compress.Close;
mp3compress.Free;
SocketID.Close;
This is a very basic guide as this code will need checks to avoid remote
contention and audiograbber overflow (usually handled by the audio
grabber library).
In the other side, mp3 is not a suitable format for voIP, as it have a
big latency.
This usable for uos_AddFromURL()?
I do not know, you need a chuncked send data, something that let you
send an amount of data unknown while sending, and usually you will need
at least one thread plus the main one if you need to handle more
requests at the same time.
--
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal