Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Timo Rothenpieler <timo@rothenpieler.org>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avformat/tls_schannel: forward AVIO_FLAG_NONBLOCK to tcp stream
Date: Tue, 11 Jun 2024 15:10:53 +0200
Message-ID: <7f862faf-2efd-4222-9245-9a8a7799ce19@rothenpieler.org> (raw)
In-Reply-To: <20240603202811.137136-1-timo@rothenpieler.org>

On 03.06.2024 22:28, Timo Rothenpieler wrote:
> From: BtbN <btbn@btbn.de>

This is fixed locally

> Fixes for example rtmps streaming over schannel.
> ---
>   libavformat/tls_schannel.c | 15 ++++++++++++++-
>   1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c
> index 214a47a218..7265a9794d 100644
> --- a/libavformat/tls_schannel.c
> +++ b/libavformat/tls_schannel.c
> @@ -113,6 +113,7 @@ static int tls_shutdown_client(URLContext *h)
>                                                c->request_flags, 0, 0, NULL, 0, &c->ctxt_handle,
>                                                &outbuf_desc, &c->context_flags, &c->ctxt_timestamp);
>           if (sspi_ret == SEC_E_OK || sspi_ret == SEC_I_CONTEXT_EXPIRED) {
> +            s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
>               ret = ffurl_write(s->tcp, outbuf.pvBuffer, outbuf.cbBuffer);
>               FreeContextBuffer(outbuf.pvBuffer);
>               if (ret < 0 || ret != outbuf.cbBuffer)
> @@ -316,6 +317,7 @@ static int tls_client_handshake(URLContext *h)
>           goto fail;
>       }
>   
> +    s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
>       ret = ffurl_write(s->tcp, outbuf.pvBuffer, outbuf.cbBuffer);
>       FreeContextBuffer(outbuf.pvBuffer);
>       if (ret < 0 || ret != outbuf.cbBuffer) {
> @@ -416,11 +418,16 @@ static int tls_read(URLContext *h, uint8_t *buf, int len)
>               }
>           }
>   
> +        s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
> +        s->tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
> +
>           ret = ffurl_read(s->tcp, c->enc_buf + c->enc_buf_offset,
>                            c->enc_buf_size - c->enc_buf_offset);
>           if (ret == AVERROR_EOF) {
>               c->connection_closed = 1;
>               ret = 0;
> +        } else if (ret == AVERROR(EAGAIN)) {
> +            ret = 0;
>           } else if (ret < 0) {
>               av_log(h, AV_LOG_ERROR, "Unable to read from socket\n");
>               return ret;
> @@ -564,8 +571,14 @@ static int tls_write(URLContext *h, const uint8_t *buf, int len)
>       sspi_ret = EncryptMessage(&c->ctxt_handle, 0, &outbuf_desc, 0);
>       if (sspi_ret == SEC_E_OK)  {
>           len = outbuf[0].cbBuffer + outbuf[1].cbBuffer + outbuf[2].cbBuffer;
> +
> +        s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
> +        s->tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
> +
>           ret = ffurl_write(s->tcp, data, len);
> -        if (ret < 0 || ret != len) {
> +        if (ret == AVERROR(EAGAIN)) {
> +            goto done;
> +        } else if (ret < 0 || ret != len) {
>               ret = AVERROR(EIO);
>               av_log(h, AV_LOG_ERROR, "Writing encrypted data to socket failed\n");
>               goto done;

ping


I'm specifically unsure if implementing the sending-side like this is 
valid and would appreciate review from someone familiar with the code 
and schannel.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-06-11 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03 20:28 Timo Rothenpieler
2024-06-11 13:10 ` Timo Rothenpieler [this message]
2024-06-18 16:30   ` Timo Rothenpieler
2024-06-18 16:56     ` Gyan Doshi
2024-06-18 18:23       ` Timo Rothenpieler
2024-06-19  4:38         ` Gyan Doshi
2024-06-23 22:07 ` Timo Rothenpieler
2024-06-24 13:06   ` Timo Rothenpieler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f862faf-2efd-4222-9245-9a8a7799ce19@rothenpieler.org \
    --to=timo@rothenpieler.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git