[FFmpeg-cvslog] avformat/librist: replace deprecated functions
Gijs Peskens
git at videolan.org
Sun Oct 10 18:43:38 EEST 2021
ffmpeg | branch: master | Gijs Peskens <gijs at peskens.net> | Tue Sep 28 10:22:39 2021 +0200| [5274f2f7f8c5e40d18b84055fbb232752bd24f2f] | committer: Marton Balint
avformat/librist: replace deprecated functions
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>
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5274f2f7f8c5e40d18b84055fbb232752bd24f2f
---
libavformat/librist.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/libavformat/librist.c b/libavformat/librist.c
index 8f51050c3e..6eae90cc2f 100644
--- a/libavformat/librist.c
+++ b/libavformat/librist.c
@@ -34,10 +34,16 @@
#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)
+#define FF_LIBRIST_VERSION_41 FF_LIBRIST_MAKE_VERSION(4, 1, 0)
+
typedef struct RISTContext {
const AVClass *class;
@@ -146,7 +152,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 +197,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 +214,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;
}
More information about the ffmpeg-cvslog
mailing list