yes... sure...<div>this is still a skeleton, but it's already working...</div><div><br></div><div>In MY CASE, I have a socket already open... sending and receiving some information already... I need to use the same socket to send the output of ffmpeg... everything I do is "equivalent" to type, for example: "ffmpeg -i inputfile <b>socket://8989</b>"</div>

<div><br></div><div>so my application send the output to the socket with handle 8989... the code below is enough... maybe I will do some optmization later, but it works pretty fine.</div><div><br></div>If you want to write do some buffer, you should pass the buffer address with socket_open, save the address in priv_data, as I did, and then use socket_write to write to this buffer... of couse, use appropriate names for it... and I am not completely sure about what you want so I am not sure if this is the best solution for you... but the idea is to make your own URLProtocol... :-)<div>

<div><br></div><div><div><font face="'courier new', monospace">static int socket_write(URLContext *h, const unsigned char *buf, int size)</font></div><div><font face="'courier new', monospace">{</font></div>

<div><font face="'courier new', monospace">    int *socketHandleInt32 = (int*)h->priv_data;</font></div><div><font face="'courier new', monospace">    int r = send(*socketHandleInt32, buf, size, 0);</font></div>

<div><font face="'courier new', monospace">    return (-1 == r) ? AVERROR(errno) : r;</font></div><div><font face="'courier new', monospace">}</font></div><div><font face="'courier new', monospace"><br>

</font></div><div><font face="'courier new', monospace">static int socket_get_handle(URLContext *h)</font></div><div><font face="'courier new', monospace">{</font></div><div><font face="'courier new', monospace">    return *(int*)h->priv_data;</font></div>

<div><font face="'courier new', monospace">}</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">static int socket_check(URLContext *h, int mask)</font></div>

<div><font face="'courier new', monospace">{</font></div><div><font face="'courier new', monospace">    return 0;</font></div><div><font face="'courier new', monospace">}</font></div><div><font face="'courier new', monospace"><br>

</font></div><div><font face="'courier new', monospace">static int socket_open(URLContext *h, const char *socketHandle, int flags)</font></div><div><font face="'courier new', monospace">{</font></div><div>

<font face="'courier new', monospace">    int * socketHandleInt32 = av_malloc( sizeof(int) );</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">    socketHandle += 9; // skip "socket://"    </font></div>

<div><font face="'courier new', monospace">    h->priv_data = socketHandleInt32;</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">    *socketHandleInt32 = atoi( socketHandle );</font></div>

<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">    return 0;</font></div><div><font face="'courier new', monospace">}</font></div><div><font face="'courier new', monospace"><br>

</font></div><div><font face="'courier new', monospace">static int socket_close(URLContext *h)</font></div><div><font face="'courier new', monospace">{</font></div><div><font face="'courier new', monospace">    int *socketHandleInt32 = (int*)h->priv_data;</font></div>

<div><font face="'courier new', monospace">    return !close(*socketHandleInt32);</font></div><div><font face="'courier new', monospace">}</font></div><div><font face="'courier new', monospace"><br>

</font></div><div><font face="'courier new', monospace">URLProtocol ff_socket_protocol = {</font></div><div><font face="'courier new', monospace">    .name                = "socket",</font></div>

<div><font face="'courier new', monospace">    .url_open            = socket_open,</font></div><div><font face="'courier new', monospace">    .url_write           = socket_write,</font></div><div><font face="'courier new', monospace">    .url_close           = socket_close,</font></div>

<div><font face="'courier new', monospace">    .url_get_file_handle = socket_get_handle,</font></div><div><font face="'courier new', monospace">    .url_check           = socket_check,</font></div><div><font face="'courier new', monospace">};</font></div>

<div><br></div><br><div class="gmail_quote">On Thu, May 3, 2012 at 4:54 PM, Denis <span dir="ltr"><<a href="mailto:info@denisgottardello.it" target="_blank">info@denisgottardello.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

In data giovedě 03 maggio 2012 21:39:36, Wagner Patriota ha scritto:<br>
<div class="im">> Hey guys, sorry... but it's VERY VERY simple... I did it in about 10 or 15<br>
> minutes after I figured out how URLProtocol works...<br>
><br>
> I just rewrote the URLProtocol... that's it... I created a new one, based<br>
> on file.c and then I rewrote all the functions to write in my socket... it<br>
> worked right in the first time.<br>
<br>
</div>Can you post an example?<br>
Can this method be used for send not to a socket but to a memory buffer?<br>
<div class="im HOEnZb"><br>
--<br>
<a href="http://www.denisgottardello.it" target="_blank">www.denisgottardello.it</a><br>
Skype: mrdebug<br>
Videosurveillance and home automation!<br>
<a href="http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php" target="_blank">http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php</a><br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</div></div></blockquote></div><br></div></div>