[FFmpeg-devel] [PATCH] avformat/tls_mbedtls: Pass FLAG_NONBLOCK to underlying transport

Dennis Mungai dmngaie at gmail.com
Mon Apr 8 16:32:42 EEST 2024


On Mon, 8 Apr 2024 at 16:26, Zhao Zhili <quinkblack at foxmail.com> wrote:

> From: Zhao Zhili <zhilizhao at tencent.com>
>
> This fix rtmps failure since rtmps requires nonblocking read.
>
> Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> ---
>  libavformat/tls_mbedtls.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
> index 8503523b6d..f51cf43b1c 100644
> --- a/libavformat/tls_mbedtls.c
> +++ b/libavformat/tls_mbedtls.c
> @@ -309,6 +309,8 @@ static int tls_read(URLContext *h, uint8_t *buf, int
> size)
>      TLSContext *tls_ctx = h->priv_data;
>      int ret;
>
> +    tls_ctx->tls_shared.tcp->flags &= ~AVIO_FLAG_NONBLOCK;
> +    tls_ctx->tls_shared.tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
>      if ((ret = mbedtls_ssl_read(&tls_ctx->ssl_context, buf, size)) > 0) {
>          // return read length
>          return ret;
> @@ -322,6 +324,8 @@ static int tls_write(URLContext *h, const uint8_t
> *buf, int size)
>      TLSContext *tls_ctx = h->priv_data;
>      int ret;
>
> +    tls_ctx->tls_shared.tcp->flags &= ~AVIO_FLAG_NONBLOCK;
> +    tls_ctx->tls_shared.tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
>      if ((ret = mbedtls_ssl_write(&tls_ctx->ssl_context, buf, size)) > 0) {
>          // return written length
>          return ret;
> --
> 2.25.1
>

Are other TLS layers affected, say OpenSSL, etc?


More information about the ffmpeg-devel mailing list