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>
This commit is contained in:
@@ -714,6 +714,9 @@ This one is default.
|
|||||||
@item buffer_size
|
@item buffer_size
|
||||||
Set internal RIST buffer size for retransmission of data.
|
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
|
@item log_level
|
||||||
Set loglevel for RIST logging messages.
|
Set loglevel for RIST logging messages.
|
||||||
|
|
||||||
|
@@ -34,11 +34,15 @@
|
|||||||
|
|
||||||
#include <librist/librist.h>
|
#include <librist/librist.h>
|
||||||
|
|
||||||
|
// RIST_MAX_PACKET_SIZE - 28 minimum protocol overhead
|
||||||
|
#define MAX_PAYLOAD_SIZE (10000-28)
|
||||||
|
|
||||||
typedef struct RISTContext {
|
typedef struct RISTContext {
|
||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
|
|
||||||
int profile;
|
int profile;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
|
int packet_size;
|
||||||
int log_level;
|
int log_level;
|
||||||
int encryption;
|
int encryption;
|
||||||
char *secret;
|
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" },
|
{ "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" },
|
{ "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 },
|
{ "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 },
|
{ "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 },
|
{ "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 },
|
{ "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)
|
if (ret < 0)
|
||||||
return risterr2ret(ret);
|
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);
|
ret = rist_sender_create(&s->ctx, s->profile, 0, logging_settings);
|
||||||
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
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);
|
ret = rist_receiver_create(&s->ctx, s->profile, logging_settings);
|
||||||
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@@ -167,8 +176,6 @@ static int librist_open(URLContext *h, const char *uri, int flags)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
h->max_packet_size = 9968;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@@ -190,7 +197,7 @@ static int librist_read(URLContext *h, uint8_t *buf, int size)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return AVERROR(EAGAIN);
|
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);
|
rist_receiver_data_block_free((struct rist_data_block**)&data_block);
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user