[FFmpeg-devel] [PATCH] libavformat: add librist protocol
Marton Balint
cus at passwd.hu
Mon Mar 1 00:13:32 EET 2021
On Sun, 28 Feb 2021, Paul B Mahol wrote:
> This work is sponsored by Open Broadcast Systems.
>
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> configure | 5 +
> doc/protocols.texi | 29 +++++
> libavformat/Makefile | 1 +
> libavformat/librist.c | 236 ++++++++++++++++++++++++++++++++++++++++
> libavformat/protocols.c | 1 +
> 5 files changed, 272 insertions(+)
> create mode 100644 libavformat/librist.c
>
[...]
> +static int librist_read(URLContext *h, uint8_t *buf, int size)
> +{
> + RISTContext *s = h->priv_data;
> + const struct rist_data_block *data_block;
> + int ret;
> +
> + ret = rist_receiver_data_read(s->ctx, &data_block, s->queue_count <= 0 ? POLLING_TIME : 0);
Use POLLING_TIME unconditionally. If there are packets in the queue,
POLLING_TIME should not matter. This also means that keeping track of
queue_count is useless.
> + if (ret < 0)
> + return risterr2ret(ret);
> +
> + if (ret == 0 || data_block->payload_len <= 0)
> + return 0;
You should return EAGAIN if ret == 0, as in the previous version of the
patch. Otherwise you are "making up" a 0 sized packet.
Yet again, this should not make a difference, because
retry_transfer_wrapper in libavformat/avio.c fast retries EAGAIN
immedietly for the first five times. So the user will only see an EAGAIN
if the queue was empty for 5 * POLLING_TIME, which is 0.5 sec. If a
librist stream receives no packets for 0.5 secs, then something is wrong.
Regards,
Marton
More information about the ffmpeg-devel
mailing list