On Mon, Jul 6, 2015 at 7:58 PM, Nicolas George <geo...@nsup.org> wrote:
> Le sextidi 16 messidor, an CCXXIII, Stephan Holljes a écrit :
>> Signed-off-by: Stephan Holljes <klaxa1...@googlemail.com>
>> ---
>>  libavformat/tcp.c | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
>> index f24cad2..71dff7a 100644
>> --- a/libavformat/tcp.c
>> +++ b/libavformat/tcp.c
>> @@ -19,6 +19,7 @@
>>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
>> USA
>>   */
>>  #include "avformat.h"
>> +#include "libavutil/avassert.h"
>>  #include "libavutil/parseutils.h"
>>  #include "libavutil/opt.h"
>>  #include "libavutil/time.h"
>> @@ -163,6 +164,22 @@ static int tcp_open(URLContext *h, const char *uri, int 
>> flags)
>>      return ret;
>>  }
>>
>> +static int tcp_accept(URLContext *s, URLContext **c)
>> +{
>> +    TCPContext *sc = s->priv_data;
>> +    TCPContext *cc;
>> +    int ret;
>> +    av_assert0(sc->listen);
>
>> +    if ((ret = ffurl_alloc(c, s->filename, AVIO_FLAG_READ_WRITE, 
>> &s->interrupt_callback)) < 0)
>> +        return ret;
>
> My previous comment said: "Maybe c->flags instead of hardcoding
> AVIO_FLAG_READ_WRITE?", what happened to it? It is ok to not agree with it,
> but not to ignore it entirely.

Sorry, I must have missed that remark. Fixed in attached patch.

>
>> +    cc = (*c)->priv_data;
>> +    ret = ff_accept(sc->fd, sc->listen_timeout, s);
>> +    if (ret < 0)
>> +        return ff_neterrno();
>> +    cc->fd = ret;
>> +    return 0;
>> +}
>> +
>>  static int tcp_read(URLContext *h, uint8_t *buf, int size)
>>  {
>>      TCPContext *s = h->priv_data;
>> @@ -223,6 +240,7 @@ static int tcp_get_file_handle(URLContext *h)
>>  URLProtocol ff_tcp_protocol = {
>>      .name                = "tcp",
>>      .url_open            = tcp_open,
>> +    .url_accept          = tcp_accept,
>>      .url_read            = tcp_read,
>>      .url_write           = tcp_write,
>>      .url_close           = tcp_close,
>
> Regards,
>
> --
>   Nicolas George

Regards,
Stephan
From d796bbc8160af59995d10d17779f3909a7ee62e5 Mon Sep 17 00:00:00 2001
From: Stephan Holljes <klaxa1...@googlemail.com>
Date: Fri, 3 Jul 2015 02:27:09 +0200
Subject: [PATCH] lavf/tcp: add tcp_accept

Signed-off-by: Stephan Holljes <klaxa1...@googlemail.com>
---
 libavformat/tcp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index f24cad2..6f5e175 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
+#include "libavutil/avassert.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
@@ -163,6 +164,22 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     return ret;
 }
 
+static int tcp_accept(URLContext *s, URLContext **c)
+{
+    TCPContext *sc = s->priv_data;
+    TCPContext *cc;
+    int ret;
+    av_assert0(sc->listen);
+    if ((ret = ffurl_alloc(c, s->filename, s->flags & AVIO_FLAG_READ_WRITE, &s->interrupt_callback)) < 0)
+        return ret;
+    cc = (*c)->priv_data;
+    ret = ff_accept(sc->fd, sc->listen_timeout, s);
+    if (ret < 0)
+        return ff_neterrno();
+    cc->fd = ret;
+    return 0;
+}
+
 static int tcp_read(URLContext *h, uint8_t *buf, int size)
 {
     TCPContext *s = h->priv_data;
@@ -223,6 +240,7 @@ static int tcp_get_file_handle(URLContext *h)
 URLProtocol ff_tcp_protocol = {
     .name                = "tcp",
     .url_open            = tcp_open,
+    .url_accept          = tcp_accept,
     .url_read            = tcp_read,
     .url_write           = tcp_write,
     .url_close           = tcp_close,
-- 
2.1.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to