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

Stephan Holljes klaxa1337 at googlemail.com
Thu Jul 9 16:06:40 CEST 2015


On Thu, Jul 9, 2015 at 3:31 PM, Nicolas George <george at nsup.org> wrote:
> Le decadi 20 messidor, an CCXXIII, Stephan Holljes a écrit :
>> Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
>> ---
>>  libavformat/tcp.c | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>     Changes since first version:
>>       - Add av_assert0() check for sc->listen
>>       - Add bitmask for s->flags in ffurl_alloc
>>       - Use ff_accept() instead of accept()
>>
>>
>> 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;
>
> Any reason to remove the other flags? Since it is not possible to add flags
> on a context afterwards, setting the flags on the server to have them on the
> clients is the most obvious solution. AVIO_FLAG_NONBLOCK does not work, but
> AVIO_FLAG_DIRECT does and makes sense for network protocols.
>

No reason at all, I wasn't aware of that. What other flags should be
kept? Since you suggested filtering s->flags I'm assuming not all
flags from s should be kept?
Should the same filtering then be applied in http_accept() too?

>> +    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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Regards,
Stephan


More information about the ffmpeg-devel mailing list