diff mbox

[FFmpeg-devel] avformat/librtmp: fix returning EOF from Read/Write

Message ID 20180726102043.16777-1-timo@rothenpieler.org
State Accepted
Commit ed647ab79f9a54d8d3a8e345f6a1643b60b849f4
Headers show

Commit Message

Timo Rothenpieler July 26, 2018, 10:20 a.m. UTC
---
 libavformat/librtmp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Timo Rothenpieler July 27, 2018, 11:42 a.m. UTC | #1
I did a 24h test with this, and it seems to fix the issue.
Will apply and backport to 4.0 in 24h if nobody objects.
Timo Rothenpieler July 27, 2018, 11:12 p.m. UTC | #2
applied
Jan Ekström July 28, 2018, 9:48 a.m. UTC | #3
On Thu, Jul 26, 2018 at 1:20 PM, Timo Rothenpieler
<timo@rothenpieler.org> wrote:
> ---
>  libavformat/librtmp.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
> index f3cfa9a8e2..43013e46e0 100644
> --- a/libavformat/librtmp.c
> +++ b/libavformat/librtmp.c
> @@ -261,7 +261,10 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
>      LibRTMPContext *ctx = s->priv_data;
>      RTMP *r = &ctx->rtmp;
>
> -    return RTMP_Write(r, buf, size);
> +    int ret = RTMP_Write(r, buf, size);
> +    if (!ret)
> +        return AVERROR_EOF;
> +    return ret;
>  }
>
>  static int rtmp_read(URLContext *s, uint8_t *buf, int size)
> @@ -269,7 +272,10 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
>      LibRTMPContext *ctx = s->priv_data;
>      RTMP *r = &ctx->rtmp;
>
> -    return RTMP_Read(r, buf, size);
> +    int ret = RTMP_Read(r, buf, size);
> +    if (!ret)
> +        return AVERROR_EOF;
> +    return ret;
>  }
>
>  static int rtmp_read_pause(URLContext *s, int pause)
> --
> 2.18.0
>

Cheers, these things just keep popping up it seems :) . Generally I've
done something along the lines of return ret ? ret : AVERROR_EOF; ,
but that's just a stylistic thing.

Jan
Timo Rothenpieler July 31, 2018, 10:56 a.m. UTC | #4
Am 28.07.2018 um 11:48 schrieb Jan Ekström:
> On Thu, Jul 26, 2018 at 1:20 PM, Timo Rothenpieler
> <timo@rothenpieler.org> wrote:
>> ---
>>   libavformat/librtmp.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
>> index f3cfa9a8e2..43013e46e0 100644
>> --- a/libavformat/librtmp.c
>> +++ b/libavformat/librtmp.c
>> @@ -261,7 +261,10 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
>>       LibRTMPContext *ctx = s->priv_data;
>>       RTMP *r = &ctx->rtmp;
>>
>> -    return RTMP_Write(r, buf, size);
>> +    int ret = RTMP_Write(r, buf, size);
>> +    if (!ret)
>> +        return AVERROR_EOF;
>> +    return ret;
>>   }
>>
>>   static int rtmp_read(URLContext *s, uint8_t *buf, int size)
>> @@ -269,7 +272,10 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
>>       LibRTMPContext *ctx = s->priv_data;
>>       RTMP *r = &ctx->rtmp;
>>
>> -    return RTMP_Read(r, buf, size);
>> +    int ret = RTMP_Read(r, buf, size);
>> +    if (!ret)
>> +        return AVERROR_EOF;
>> +    return ret;
>>   }
>>
>>   static int rtmp_read_pause(URLContext *s, int pause)
>> --
>> 2.18.0
>>
> 
> Cheers, these things just keep popping up it seems :) . Generally I've
> done something along the lines of return ret ? ret : AVERROR_EOF; ,
> but that's just a stylistic thing.
> 
> Jan

I'm starting to wonder if adding it to the write function is even 
correct. The only way I see the function returning 0 is when it actually 
did not write anything because the size was < 11.
diff mbox

Patch

diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index f3cfa9a8e2..43013e46e0 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -261,7 +261,10 @@  static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
     LibRTMPContext *ctx = s->priv_data;
     RTMP *r = &ctx->rtmp;
 
-    return RTMP_Write(r, buf, size);
+    int ret = RTMP_Write(r, buf, size);
+    if (!ret)
+        return AVERROR_EOF;
+    return ret;
 }
 
 static int rtmp_read(URLContext *s, uint8_t *buf, int size)
@@ -269,7 +272,10 @@  static int rtmp_read(URLContext *s, uint8_t *buf, int size)
     LibRTMPContext *ctx = s->priv_data;
     RTMP *r = &ctx->rtmp;
 
-    return RTMP_Read(r, buf, size);
+    int ret = RTMP_Read(r, buf, size);
+    if (!ret)
+        return AVERROR_EOF;
+    return ret;
 }
 
 static int rtmp_read_pause(URLContext *s, int pause)