[FFmpeg-cvslog] avformat/librist: rework librist_read

Marton Balint git at videolan.org
Sat Mar 13 20:43:41 EET 2021


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Mar  6 21:48:57 2021 +0100| [4b1e387e259ab0d6e7c4f7f010736b64938c4939] | committer: Marton Balint

avformat/librist: rework librist_read

Queue tracking makes no difference so remove it, return EAGAIN of no data is
available and rist data block needs to be freed even for zero sized packets.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b1e387e259ab0d6e7c4f7f010736b64938c4939
---

 libavformat/librist.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavformat/librist.c b/libavformat/librist.c
index 789cefda36..c4ba1192e9 100644
--- a/libavformat/librist.c
+++ b/libavformat/librist.c
@@ -37,7 +37,6 @@
 typedef struct RISTContext {
     const AVClass *class;
 
-    int queue_count;
     int profile;
     int buffer_size;
     int log_level;
@@ -184,16 +183,19 @@ static int librist_read(URLContext *h, uint8_t *buf, int size)
     const struct rist_data_block *data_block;
     int ret;
 
-    ret = rist_receiver_data_read(s->ctx, &data_block, s->queue_count <= 0 ? POLLING_TIME : 0);
+    ret = rist_receiver_data_read(s->ctx, &data_block, POLLING_TIME);
     if (ret < 0)
         return risterr2ret(ret);
 
-    if (ret == 0 || data_block->payload_len <= 0)
-        return 0;
+    if (ret == 0)
+        return AVERROR(EAGAIN);
 
-    s->queue_count = ret - 1;
-    size = data_block->payload_len;
+    if (data_block->payload_len > 9968) {
+        rist_receiver_data_block_free((struct rist_data_block**)&data_block);
+        return AVERROR_EXTERNAL;
+    }
 
+    size = data_block->payload_len;
     memcpy(buf, data_block->payload, size);
     rist_receiver_data_block_free((struct rist_data_block**)&data_block);
 



More information about the ffmpeg-cvslog mailing list