From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C196A494E8 for ; Tue, 11 Jun 2024 13:11:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1E9B968D834; Tue, 11 Jun 2024 16:11:03 +0300 (EEST) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4892968D77D for ; Tue, 11 Jun 2024 16:10:56 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 61B1827FFCC1E for ; Tue, 11 Jun 2024 15:10:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1718111455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XREZPSF+GhZAbL1t5NG+/iMnIb/d/7wmCKTZe08Vw3M=; b=W2kEuPblVRrXnVCbtAE7YE+ddMfnvZW9zBFwKE+jd7hc7kynI+A1w1ckn6ooPlx2nGjnbb GXXs2n9aZd3V58CVFQDtewPUqWvy4HQOcb64Lw1ttAQqYedn/rhN/MS1FNxzYtVS+mwpTg 4TGCGcCL9erI5RJGgobCyXQaWlfccaU+XeHi7bI7ePE4PaObWsE0pZk0UiYixXPAExH0cZ 7kK/+eA2sXcxAUmKOZrsCowSU4ymVEbAuFxYkPOYtPaBZ0xaDmsXowL3ullcBsLW4cZd3w rYNFdslglPnSgZEC5Tidn30I30FtIQ6PpDEI7/PsrecGAN29iOHIAVIdU0323g== Message-ID: <7f862faf-2efd-4222-9245-9a8a7799ce19@rothenpieler.org> Date: Tue, 11 Jun 2024 15:10:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20240603202811.137136-1-timo@rothenpieler.org> Content-Language: en-US From: Timo Rothenpieler In-Reply-To: <20240603202811.137136-1-timo@rothenpieler.org> Subject: Re: [FFmpeg-devel] [PATCH] avformat/tls_schannel: forward AVIO_FLAG_NONBLOCK to tcp stream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 03.06.2024 22:28, Timo Rothenpieler wrote: > From: BtbN 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".