<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p><br>
</p>
<div>
<div id="divRplyFwdMsg" dir="ltr" style="color: rgb(0, 0, 0);"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>e :</b> fpc-other-bounces@lists.freepascal.org <fpc-other-bounces@lists.freepascal.org> de la part de Fred van Stappen
 <fiens@hotmail.com><br>
<b>Envoyé :</b> mercredi 8 février 2017 19:11<br>
<b>À :</b> Other FPC related discussions<br>
<b>Objet :</b> Re: [fpc-other] fpc and voip.</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" dir="ltr">
<p style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</p>
<div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>De :</b> fpc-other-bounces@lists.freepascal.org <fpc-other-bounces@lists.freepascal.org> de la part de José Mejuto <joshyfun@gmail.com><br>
<b>Envoyé :</b> mercredi 8 février 2017 14:55<br>
<b>À :</b> fpc-other@lists.freepascal.org<br>
<b>Objet :</b> Re: [fpc-other] fpc and voip.</font>
<div> </div>
</div>
</div>
<font>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
El 08/02/2017 a las 14:25, Fred van Stappen escribió:<br>
<br>
> My knowledge in web-server things are too poor to attack the<br>
> streaming-server part of voip.<br>
><br>
<br>
Hello,<br>
<br>
Streaming is different (when well done) than simple http file send. To <br>
send audio as a regular http transfer the web engine must provide an API <br>
(callback or alike) call in which you can return a data block, the last <br>
encoded audio chunk, or finish the transfer.<br>
<br>
For a simple job, you just need a thread that is constantly encoding the <br>
audio input and buffering the encoded audio in a queue. This buffer is <br>
not unlimited, usually from 1 to 60 seconds. Once you receive an http <br>
request for data (the http engine callback) you start to send from the <br>
beginning of the audio queue and take note of client identifier (maybe <br>
only the port is needed) and the amount of data sent, not all buffer, <br>
you must send small chunks, probably less than 32K. Once you receive <br>
another callback request you take the identifier and with it you start <br>
to sending data from queue beginning + already sent size. Of course the <br>
queue beginning, at byte zero, has an absolute counter which is <br>
incremented since the start of compression. If client new position, once <br>
calculated, if located before the queue start the client is slow than <br>
encoding speed so you decide, drop connection or restart to send from <br>
zero offset in the queue, the client will try to resync probably with <br>
some audio artifacts.<br>
<br>
This job involves several threads and careful synchronization, it is not <br>
a trivial task. The base job can be tested with files, so you not need <br>
to be really coding audio.<br>
<br>
A "good" streaming service is usually coding audio in several queues and <br>
qualities, start to send in medium quality and jump from queue to queue <br>
in function of the client bandwidth. In this case you can not use the <br>
absolute byte position in the stream, but frame compressed position, or <br>
time position but the choose is encoder dependent. Also in the streaming <br>
engine you must fully understand how frames are encoded in the stream <br>
and the engine must send only complete frames (logically encoded frames, <br>
usually a bunch of audio samples) because the quality change can only be <br>
performed at frames boundaries for the codecs that support it, old ones <br>
like mp3 does not support arbitrary quality change, nor at frame <br>
boundaries (without an audible bleeepssseees).<br>
<br>
To better understand the caveats take a look to this wikipedia pages:<br>
<br>
<a href="https://en.wikipedia.org/wiki/Real-time_Transport_Protocol" id="LPlnk248149" previewremoved="true">https://en.wikipedia.org/wiki/Real-time_Transport_Protocol</a><br>
<br>
<br>
<a href="https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol" id="LPlnk768042" previewremoved="true">https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol</a><br>
<br>
<br>
And a list of common streaming engines.<br>
<br>
<a href="https://en.wikipedia.org/wiki/Comparison_of_streaming_media_systems#Protocol_support" id="LPlnk878813" previewremoved="true">https://en.wikipedia.org/wiki/Comparison_of_streaming_media_systems#Protocol_support</a><br>
<br>
<br>
-- <br>
<br>
_______________________________________________<br>
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Hello Jose.</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Ooops, that is more than some explanations, it is all what I need to understand and become the king of audio-streaming.</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Many, many thanks.</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Write you (much) later when all is in the head.</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Huh, last question, do you think that fpc has the tools to do web-server-<span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:13.3333px">streaming</span>
 ?</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Fre;D</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
___________________________</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
Re-hello Jose.</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
> <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">Write you (much) later when all is in the head.</span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"><br>
</span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">Sorry, I am already there. ;-)</span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"><br>
</span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">Maybe a solution would be to use some <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">existing streaming engine before to reinvent
 the hot-water ?</span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"><br>
</span></span></div>
<div class="PlainText"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size: 13.3333px;">I see IceCast that is from the same developer <a href="https://en.wikipedia.org/wiki/Xiph.Org_Foundation" title="Xiph.Org Foundation" style="text-decoration: none; color: rgb(11, 0, 128); background: none rgb(248, 249, 250); font-family: sans-serif; font-size: 11.9px; text-align: center;">Xiph.Org
 Foundation</a> than Opus codec and there is also a fpc-icecast package.</span></font></div>
<div class="PlainText"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size: 13.3333px;"><br>
</span></font></div>
<div class="PlainText"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size: 13.3333px;">But of course, your advice about
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">
existing</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"> streaming engines will be extremely appreciated.</span></span></font></div>
<div class="PlainText"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size: 13.3333px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;"><br>
</span></span></font></div>
<div class="PlainText"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size: 13.3333px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333px;">Fre;D</span></span></font></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
</font></div>
</div>
</div>
</div>
</div>
</body>
</html>