36 #include <librist/librist.h>
37 #include <librist/version.h>
40 #define MAX_PAYLOAD_SIZE (10000-28)
42 #define FF_LIBRIST_MAKE_VERSION(major, minor, patch) \
43 ((patch) + ((minor)* 0x100) + ((major) *0x10000))
44 #define FF_LIBRIST_VERSION FF_LIBRIST_MAKE_VERSION(LIBRIST_API_VERSION_MAJOR, LIBRIST_API_VERSION_MINOR, LIBRIST_API_VERSION_PATCH)
45 #define FF_LIBRIST_VERSION_41 FF_LIBRIST_MAKE_VERSION(4, 1, 0)
64 #define D AV_OPT_FLAG_DECODING_PARAM
65 #define E AV_OPT_FLAG_ENCODING_PARAM
66 #define OFFSET(x) offsetof(RISTContext, x)
72 {
"buffer_size",
"set buffer_size in ms",
OFFSET(buffer_size),
AV_OPT_TYPE_INT, {.i64=0}, 0, 30000, .flags =
D|
E },
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 #if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
157 ret = rist_parse_address(uri, (
const struct rist_peer_config **)&peer_config);
159 ret = rist_parse_address2(uri, &peer_config);
164 if (((
s->encryption == 128 ||
s->encryption == 256) && !
s->secret) ||
165 ((peer_config->key_size == 128 || peer_config->key_size == 256) && !peer_config->secret[0])) {
171 if (
s->secret && peer_config->secret[0] == 0)
172 av_strlcpy(peer_config->secret,
s->secret, RIST_MAX_STRING_SHORT);
174 if (
s->secret && (
s->encryption == 128 ||
s->encryption == 256))
175 peer_config->key_size =
s->encryption;
177 if (
s->buffer_size) {
178 peer_config->recovery_length_min =
s->buffer_size;
179 peer_config->recovery_length_max =
s->buffer_size;
182 ret = rist_peer_create(
s->ctx, &
s->peer, &
s->peer_config);
186 ret = rist_start(
s->ctx);
203 #if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
204 const struct rist_data_block *data_block;
207 struct rist_data_block *data_block;
218 #if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
219 rist_receiver_data_block_free((
struct rist_data_block**)&data_block);
221 rist_receiver_data_block_free2(&data_block);
226 size = data_block->payload_len;
227 memcpy(buf, data_block->payload,
size);
228 #if FF_LIBRIST_VERSION < FF_LIBRIST_VERSION_41
229 rist_receiver_data_block_free((
struct rist_data_block**)&data_block);
231 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);