<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 style="color: rgb(0, 0, 0);">
<div>
<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 size="2"><span style="font-size:10pt;">
<div class="PlainText">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>
<div id="LPBorder_GT_14865770637440.5459170104642415" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14865770637340.4960845874650479" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14865770637360.44762732585288934" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14865770637370.6956535867769114"></div>
<div id="LPTitle_14865770637370.583596299126232" style="top: 0px; color: rgb(0, 114, 57); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14865770637390.16244331471002793" href="https://en.wikipedia.org/wiki/Real-time_Transport_Protocol" target="_blank" style="text-decoration: none;">Real-time Transport Protocol - Wikipedia</a></div>
<div id="LPMetadata_14865770637390.98559122199955" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
en.wikipedia.org</div>
<div id="LPDescription_14865770637420.7224374894446315" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
The Real-time Transport Protocol (RTP) is a network protocol for delivering audio and video over IP networks. RTP is used extensively in communication and ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<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>
<div id="LPBorder_GT_14865770638580.2023853917033407" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14865770638500.6135524741758689" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14865770638520.2490512766299926" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14865770638520.32282045923916214"></div>
<div id="LPTitle_14865770638520.3869851903006303" style="top: 0px; color: rgb(0, 114, 57); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14865770638540.0037777219197363543" href="https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol" target="_blank" style="text-decoration: none;">Real Time Streaming Protocol - Wikipedia</a></div>
<div id="LPMetadata_14865770638540.8943991345119744" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
en.wikipedia.org</div>
<div id="LPDescription_14865770638560.25583504291982795" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
The Real Time Streaming Protocol (RTSP) is a network control protocol designed for use in entertainment and communications systems to control streaming media servers.</div>
</td>
</tr>
</tbody>
</table>
</div>
<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"><br>
</div>
<div class="PlainText">Hello Jose.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">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"><br>
</div>
<div class="PlainText">Many, many thanks.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Write you (much) later when all is in the head.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">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"><br>
</div>
<div class="PlainText">Fre;D</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><br>
</div>
</span></font></div>
</div>
</body>
</html>