36 #include <librist/librist.h>
37 #include <librist/version.h>
40 #define MAX_PAYLOAD_SIZE (10000-28)
41 #define FIFO_SIZE_DEFAULT 8192
62 #define D AV_OPT_FLAG_DECODING_PARAM
63 #define E AV_OPT_FLAG_ENCODING_PARAM
64 #define OFFSET(x) offsetof(RISTContext, x)
70 {
"buffer_size",
"set buffer_size in ms",
OFFSET(buffer_size),
AV_OPT_TYPE_INT, {.i64=0}, 0, 30000, .flags =
D|
E },
72 {
"overrun_nonfatal",
"survive in case of receiving fifo buffer overrun",
OFFSET(overrun_nonfatal),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
D },
74 {
"log_level",
"set loglevel",
OFFSET(log_level),
AV_OPT_TYPE_INT, {.i64=RIST_LOG_INFO}, -1, INT_MAX, .flags =
D|
E },
90 static int log_cb(
void *
arg,
enum rist_log_level log_level,
const char *msg)
117 ret = rist_destroy(
s->ctx);
126 struct rist_logging_settings *logging_settings = &
s->logging_settings;
127 struct rist_peer_config *peer_config = &
s->peer_config;
133 s->logging_settings = (
struct rist_logging_settings)LOGGING_SETTINGS_INITIALIZER;
139 h->max_packet_size =
s->packet_size;
140 ret = rist_sender_create(&
s->ctx,
s->profile, 0, logging_settings);
147 ret = rist_receiver_create(&
s->ctx,
s->profile, logging_settings);
152 ret = rist_peer_config_defaults_set(peer_config);
156 ret = rist_parse_address2(uri, &peer_config);
161 ret = rist_receiver_set_output_fifo_size(
s->ctx,
s->fifo_size);
166 if (((
s->encryption == 128 ||
s->encryption == 256) && !
s->secret) ||
167 ((peer_config->key_size == 128 || peer_config->key_size == 256) && !peer_config->secret[0])) {
173 if (
s->secret && peer_config->secret[0] == 0)
174 av_strlcpy(peer_config->secret,
s->secret, RIST_MAX_STRING_SHORT);
176 if (
s->secret && (
s->encryption == 128 ||
s->encryption == 256))
177 peer_config->key_size =
s->encryption;
179 if (
s->buffer_size) {
180 peer_config->recovery_length_min =
s->buffer_size;
181 peer_config->recovery_length_max =
s->buffer_size;
184 ret = rist_peer_create(
s->ctx, &
s->peer, &
s->peer_config);
188 ret = rist_start(
s->ctx);
205 struct rist_data_block *data_block;
215 rist_receiver_data_block_free2(&data_block);
219 if (data_block->flags & RIST_DATA_FLAGS_OVERFLOW) {
220 if (!
s->overrun_nonfatal) {
222 "To avoid, increase fifo_size option. "
223 "To survive in such case, use overrun_nonfatal option\n");
229 size = data_block->payload_len;
230 memcpy(buf, data_block->payload,
size);
232 rist_receiver_data_block_free2(&data_block);
239 struct rist_data_block data_block = { 0 };
242 data_block.ts_ntp = 0;
243 data_block.payload = buf;
244 data_block.payload_len =
size;
246 ret = rist_sender_data_write(
s->ctx, &data_block);