summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2021-03-06 22:26:13 +0100
committerMarton Balint <cus@passwd.hu>2021-03-13 17:36:48 +0100
commitdeffb5ddce5cc09ec1f29d2255276483d07b7725 (patch)
tree4b7c34251b25de928c23f9477f597abd8034028b
parent4b1e387e259ab0d6e7c4f7f010736b64938c4939 (diff)
avformat/librist: make packet size adjustable for writing, fix it for reading
Maximum packet size is 10000 (RIST_MAX_PACKET_SIZE, which is unfortunately private) minus the RIST protocol overhead which is 28 bytes for the unencrypted case, 36 for the encrypted case. Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r--doc/protocols.texi3
-rw-r--r--libavformat/librist.c17
2 files changed, 15 insertions, 5 deletions
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 4f4a4b4a3a..11005b0849 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -714,6 +714,9 @@ This one is default.
@item buffer_size
Set internal RIST buffer size for retransmission of data.
+@item pkt_size
+Set maximum packet size for sending data. 1316 by default.
+
@item log_level
Set loglevel for RIST logging messages.
diff --git a/libavformat/librist.c b/libavformat/librist.c
index c4ba1192e9..3f74521cb4 100644
--- a/libavformat/librist.c
+++ b/libavformat/librist.c
@@ -34,11 +34,15 @@
#include <librist/librist.h>
+// RIST_MAX_PACKET_SIZE - 28 minimum protocol overhead
+#define MAX_PAYLOAD_SIZE (10000-28)
+
typedef struct RISTContext {
const AVClass *class;
int profile;
int buffer_size;
+ int packet_size;
int log_level;
int encryption;
char *secret;
@@ -59,6 +63,7 @@ static const AVOption librist_options[] = {
{ "main", NULL, 0, AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_MAIN}, 0, 0, .flags = D|E, "profile" },
{ "advanced", NULL, 0, AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_ADVANCED}, 0, 0, .flags = D|E, "profile" },
{ "buffer_size", "set buffer_size", OFFSET(buffer_size), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, .flags = D|E },
+ { "pkt_size", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64=1316}, 1, MAX_PAYLOAD_SIZE, .flags = D|E },
{ "log_level", "set loglevel", OFFSET(log_level), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = D|E },
{ "secret", "set encryption secret",OFFSET(secret), AV_OPT_TYPE_STRING,{.str=NULL}, 0, 0, .flags = D|E },
{ "encryption","set encryption type",OFFSET(encryption), AV_OPT_TYPE_INT ,{.i64=0}, 0, INT_MAX, .flags = D|E },
@@ -123,13 +128,17 @@ static int librist_open(URLContext *h, const char *uri, int flags)
if (ret < 0)
return risterr2ret(ret);
- if (flags & AVIO_FLAG_WRITE)
+ if (flags & AVIO_FLAG_WRITE) {
+ h->max_packet_size = s->packet_size;
ret = rist_sender_create(&s->ctx, s->profile, 0, logging_settings);
+ }
if (ret < 0)
goto err;
- if (flags & AVIO_FLAG_READ)
+ if (flags & AVIO_FLAG_READ) {
+ h->max_packet_size = MAX_PAYLOAD_SIZE;
ret = rist_receiver_create(&s->ctx, s->profile, logging_settings);
+ }
if (ret < 0)
goto err;
@@ -167,8 +176,6 @@ static int librist_open(URLContext *h, const char *uri, int flags)
if (ret < 0)
goto err;
- h->max_packet_size = 9968;
-
return 0;
err:
@@ -190,7 +197,7 @@ static int librist_read(URLContext *h, uint8_t *buf, int size)
if (ret == 0)
return AVERROR(EAGAIN);
- if (data_block->payload_len > 9968) {
+ if (data_block->payload_len > MAX_PAYLOAD_SIZE) {
rist_receiver_data_block_free((struct rist_data_block**)&data_block);
return AVERROR_EXTERNAL;
}