diff mbox

[FFmpeg-devel] udp: ignore UDP packets without payload

Message ID CAKVPjOaK2GhPxhopC7gpWWkKDquwNCdEyHKUuPLb9xWTRrokbQ@mail.gmail.com
State New
Headers show

Commit Message

Daniel Kucera May 24, 2017, 8:40 a.m. UTC
2017-05-24 10:10 GMT+02:00 Daniel Kučera <daniel.kucera@gmail.com>:
> 2017-05-24 9:02 GMT+02:00 Nicolas George <george@nsup.org>:
>>
>> Le quartidi 4 prairial, an CCXXV, Daniel Kucera a écrit :
>> > Time to time some devices send UDP packets without payload.
>> > ffmpeg previously exited on receiving such packet, this patch
>> > fixes this behaviour.
>> >
>> > Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
>> > ---
>> >  libavformat/udp.c | 6 +++++-
>> >  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> I do not think this is correct: UDP is a packetized protocol, packet
>> with empty payload are still packets, and meaningful for some protocols.
>>
>> Regards,
>>
>> --
>>   Nicolas George
>
>
> Maybe, but in libavformat/async.c is zero treated as EOF:
>
> ret = ring_generic_write(ring, (void *)h, to_copy, wrapped_url_read);
> pthread_mutex_lock(&c->mutex);
> if (ret <= 0) {
> c->io_eof_reached = 1;
> if (c->inner_io_error < 0)
> c->io_error = c->inner_io_error;
> }
>
> So what do you suggest?
>
>
> S pozdravom / Best regards
> Daniel Kucera.

Even this patch works for me, do you think it's more suitable?

                     s->eof_reached = 1;



S pozdravom / Best regards
Daniel Kucera.
diff mbox

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 1667e9f08b..eeb229d45d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -631,7 +631,7 @@  int avio_read(AVIOContext *s, unsigned char *buf, int size)
                 if(s->read_packet)
                     len = s->read_packet(s->opaque, buf, size);

-                if (len <= 0) {
+                if (len < 0) {
                     /* do not modify buffer if EOF reached so that a
seek back can
                     be done without rereading data */