[FFmpeg-devel] [PATCH 1/3] librist: replace deprecated functions.

Gijs Peskens gijs at peskens.net
Tue Sep 28 11:22:39 EEST 2021


This gets rid of of rist_receiver_data_read, rist_receiver_data_block_free and rist_parse_address
these functions have been deprecated since librist release v0.2.1 and are replaced with functions
suffixed with 2.
I added a version macro check at the top of the file to ensure ffmpeg can still be compiled against
older versions.

Signed-off-by: Gijs Peskens <gijs at peskens.net>
---
 libavformat/librist.c | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/libavformat/librist.c b/libavformat/librist.c
index 8f51050c3e..b120346f48 100644
--- a/libavformat/librist.c
+++ b/libavformat/librist.c
@@ -34,10 +34,24 @@
 #include "url.h"
 
 #include <librist/librist.h>
-
+#include <librist/version.h>
 // RIST_MAX_PACKET_SIZE - 28 minimum protocol overhead
 #define MAX_PAYLOAD_SIZE (10000-28)
 
+#define FF_LIBRIST_MAKE_VERSION(major, minor, patch) \
+    ((patch) + ((minor)* 0x100) + ((major) *0x10000))
+#define FF_LIBRIST_VERSION FF_LIBRIST_MAKE_VERSION(LIBRIST_API_VERSION_MAJOR, LIBRIST_API_VERSION_MINOR, LIBRIST_API_VERSION_PATCH)
+//API version 4.1 deprecated:
+// rist_receiver_data_read
+// rist_receiver_data_callback_set
+// rist_receiver_data_block_free
+// rist_parse_address
+// rist_parse_udp_address
+// rist_peer_config_free
+// rist_logging_settings_free
+// rist_udp_config_free
+//And replaced them with functions suffixed with 2
+#define FF_LIBRIST_VERSION_41 FF_LIBRIST_MAKE_VERSION(4, 1, 0)
 typedef struct RISTContext {
     const AVClass *class;
 
@@ -146,7 +160,11 @@ static int librist_open(URLContext *h, const char *uri, int flags)
     if (ret < 0)
         goto err;
 
+#if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
     ret = rist_parse_address(uri, (const struct rist_peer_config **)&peer_config);
+#else
+    ret = rist_parse_address2(uri, &peer_config);
+#endif
     if (ret < 0)
         goto err;
 
@@ -187,10 +205,16 @@ err:
 static int librist_read(URLContext *h, uint8_t *buf, int size)
 {
     RISTContext *s = h->priv_data;
-    const struct rist_data_block *data_block;
     int ret;
 
+#if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
+    const struct rist_data_block *data_block;
     ret = rist_receiver_data_read(s->ctx, &data_block, POLLING_TIME);
+#else
+    struct rist_data_block *data_block;
+    ret = rist_receiver_data_read2(s->ctx, &data_block, POLLING_TIME);
+#endif
+
     if (ret < 0)
         return risterr2ret(ret);
 
@@ -198,14 +222,21 @@ static int librist_read(URLContext *h, uint8_t *buf, int size)
         return AVERROR(EAGAIN);
 
     if (data_block->payload_len > MAX_PAYLOAD_SIZE) {
+#if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
         rist_receiver_data_block_free((struct rist_data_block**)&data_block);
+#else
+        rist_receiver_data_block_free2(&data_block);
+#endif
         return AVERROR_EXTERNAL;
     }
 
     size = data_block->payload_len;
     memcpy(buf, data_block->payload, size);
+#if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
     rist_receiver_data_block_free((struct rist_data_block**)&data_block);
-
+#else
+    rist_receiver_data_block_free2(&data_block);
+#endif
     return size;
 }
 
-- 
2.30.2



More information about the ffmpeg-devel mailing list