diff mbox series

[FFmpeg-devel] avformat/tls_schannel: forward AVIO_FLAG_NONBLOCK to tcp stream

Message ID 20240603202811.137136-1-timo@rothenpieler.org
State New
Headers show
Series [FFmpeg-devel] avformat/tls_schannel: forward AVIO_FLAG_NONBLOCK to tcp stream | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Timo Rothenpieler June 3, 2024, 8:28 p.m. UTC
From: BtbN <btbn@btbn.de>

Fixes for example rtmps streaming over schannel.
---
 libavformat/tls_schannel.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Timo Rothenpieler June 11, 2024, 1:10 p.m. UTC | #1
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.
Timo Rothenpieler June 18, 2024, 4:30 p.m. UTC | #2
On 11.06.2024 15:10, Timo Rothenpieler wrote:
> 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.

ping
Gyan Doshi June 18, 2024, 4:56 p.m. UTC | #3
On 2024-06-18 10:00 pm, Timo Rothenpieler wrote:
> On 11.06.2024 15:10, Timo Rothenpieler wrote:
>> 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.

FWIW, I had to do the same for securetransport on a project a couple of 
years back to get rtmps working. Worked fine, and did not get any 
reports of ill-effects.

Regards,
Gyan
Timo Rothenpieler June 18, 2024, 6:23 p.m. UTC | #4
On 18.06.2024 18:56, Gyan Doshi wrote:
> FWIW, I had to do the same for securetransport on a project a couple of 
> years back to get rtmps working. Worked fine, and did not get any 
> reports of ill-effects.

You mean the FFmpeg implementation of rtmps?
Cause if so, I think that only makes use of nonblocking mode for 
receiving, not sending.
So it wouldn't run into this if it was wrong.

Just making the reading side support non-blocking would definitely also 
be an option, it would at least fix rtmps.
Gyan Doshi June 19, 2024, 4:38 a.m. UTC | #5
On 2024-06-18 11:53 pm, Timo Rothenpieler wrote:
> On 18.06.2024 18:56, Gyan Doshi wrote:
>> FWIW, I had to do the same for securetransport on a project a couple 
>> of years back to get rtmps working. Worked fine, and did not get any 
>> reports of ill-effects.
>
> You mean the FFmpeg implementation of rtmps?
> Cause if so, I think that only makes use of nonblocking mode for 
> receiving, not sending.
> So it wouldn't run into this if it was wrong.

IIRC, the setup/handshake phase would never complete.

Adding this fixed it

--------
+    TLSShared *s = &c->tls_shared;
+    int set_flag_nonblock = 0;
+
+    if (h->flags & AVIO_FLAG_NONBLOCK && !(s->tcp->flags & 
AVIO_FLAG_NONBLOCK)) {
+        s->tcp->flags |= AVIO_FLAG_NONBLOCK;
+        set_flag_nonblock = 1;
+    }
+
      int read = ffurl_read(c->tls_shared.tcp, data, requested);
+
+    if (set_flag_nonblock)
+        s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
--------

Regards,
Gyan
Timo Rothenpieler June 23, 2024, 10:07 p.m. UTC | #6
On 03.06.2024 22:28, Timo Rothenpieler wrote:
> From: BtbN <btbn@btbn.de>
> 
> 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;

will apply soon
Timo Rothenpieler June 24, 2024, 1:06 p.m. UTC | #7
On 24/06/2024 00:07, Timo Rothenpieler wrote:
> On 03.06.2024 22:28, Timo Rothenpieler wrote:
>> From: BtbN <btbn@btbn.de>
>>
>> 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;
> 
> will apply soon

applied
diff mbox series

Patch

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;