[FFmpeg-devel] [PATCH 4/9] lavf/tcp: add tcp_accept

Nicolas George george at nsup.org
Fri Jul 3 15:58:18 CEST 2015


Le quintidi 15 messidor, an CCXXIII, Stephan Holljes a écrit :
> Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
> ---
>  libavformat/tcp.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index f24cad2..875da50 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,23 @@ 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)

Maybe c->flags instead of hardcoding AVIO_FLAG_READ_WRITE?

> +        return ret;
> +    cc = (*c)->priv_data;

> +    ret = accept(sc->fd, NULL, NULL);

I suspect you should ne using ff_accept() here, not accept() directly.

> +    if (ret < 0) {
> +        return ff_neterrno();
> +    }

Nit: the braces are not needed.

> +    cc->fd = ret;
> +    return 0;
> +}
> +
>  static int tcp_read(URLContext *h, uint8_t *buf, int size)
>  {
>      TCPContext *s = h->priv_data;
> @@ -223,6 +241,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,

(Patches 1-3 look good to me for now.)

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150703/1a7b4884/attachment.asc>


More information about the ffmpeg-devel mailing list