avformat/tls_mbedtls: Pass FLAG_NONBLOCK to underlying transport

This fix rtmps failure since rtmps requires nonblocking read.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili 2024-04-08 21:26:13 +08:00
parent 2a7d622ddd
commit 65c1c83ca4
1 changed files with 4 additions and 0 deletions

View File

@ -310,6 +310,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;
@ -323,6 +325,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;