[FFmpeg-devel] [PATCH] libavformat: add librist protocol

James Almer jamrial at gmail.com
Thu Dec 24 15:10:26 EET 2020


On 12/24/2020 8:08 AM, Paul B Mahol wrote:
> +typedef struct RISTContext {
> +    const AVClass *class;
> +
> +    int profile;
> +    int buffer_size;
> +    int packet_size;
> +    int log_level;
> +    int encryption;
> +    char *secret;
> +
> +    struct rist_logging_settings logging_settings;
> +    struct rist_peer_config peer_config;
> +
> +    struct rist_peer *peer;
> +    struct rist_ctx *rist_ctx;
> +} RISTContext;

[...]

> +static int librist_open(URLContext *h, const char *uri, int flags)
> +{
> +    RISTContext *s = h->priv_data;
> +    struct rist_logging_settings *logging_settings = &s->logging_settings;
> +    struct rist_peer_config *peer_config = &s->peer_config;
> +    int ret;
> +
> +    ret = rist_logging_set(&logging_settings, s->log_level, log_cb, h, NULL, NULL);
> +    if (ret < 0)
> +        return risterr2ret(ret);
> +
> +    if (flags & AVIO_FLAG_WRITE) {
> +        ret = rist_sender_create(&s->rist_ctx, s->profile, 0, logging_settings);
> +    } else {
> +        ret = rist_receiver_create(&s->rist_ctx, s->profile, logging_settings);
> +    }
> +    if (ret < 0)
> +        goto err;
> +
> +    ret = rist_parse_address(uri, (const struct rist_peer_config **)&peer_config);
> +    if (ret < 0)
> +        goto err;

Look at 
https://code.videolan.org/rist/librist/-/blob/4fd217662cee398f4706c815958a1efe48b2093f/src/rist.c#L637
rist_parse_address() does not fill peer_config with default values if it 
doesn't allocate it itself. It assumes it was allocated during a 
previous call and not by the caller.

Unless the library provides a defaults()/reset() kind of function, it 
doesn't look like you can really use your own rist_peer_config struct.
Can you talk with the devs about it? Or even just submit a PR yourself. 
It should be very trivial to implement.


More information about the ffmpeg-devel mailing list