[FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
Andriy Gelman
andriy.gelman at gmail.com
Sun Mar 8 22:41:05 EET 2020
On Sun, 08. Mar 12:25, Marton Balint wrote:
>
> > Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
> >
> > From: Andriy Gelman <andriy.gelman at gmail.com>
> >
> > Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.
> >
> > Signed-off-by: Andriy Gelman <andriy.gelman at gmail.com>
> > ---
> >
> > Changes in v2:
> > - Addressed comments from Marton
> > - Updated documentation
> >
> > Compilation notes:
> > - Requires librabbitmq-dev package (on ubuntu).
> > - The pkg-config libprabbitmq.pc has a corrupt entry.
> > **update: fixed on the github master branch**
> > The line "Libs.private: rt; -lpthread" should be changed to
> > "Libs.private: -lrt -pthread".
> > - Compile FFmpeg with --enable-librabbitmq
> >
>
> [...]
>
> > + at item connection_timeout
> > +The timeout in microseconds during the initial connection to the broker. The
>
> In *seconds* (because it is an AV_OPT_TYPE_DURATION)
>
> > +default value is rw_timeout, or 5000000 microseconds if rw_timeout is not set.
>
> 5 seconds
>
> [...]
>
> > +static const AVOption options[] = {
> > + { "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = 131072 }, 4096, INT_MAX, .flags = D | E },
> > + { "exchange", "Exchange to send/read packets", OFFSET(exchange), AV_OPT_TYPE_STRING, { .str = "amq.direct" }, 0, 0, .flags = D | E },
> > + { "routing_key", "Key to filter streams", OFFSET(routing_key), AV_OPT_TYPE_STRING, { .str = "amqp" }, 0, 0, .flags = D | E },
> > + { "connection_timeout", "Initial connection timeout", OFFSET(connection_timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = D | E},
>
> INT64_MAX can be the maximum.
>
> > + { NULL }
> > +};
> > +
> > +static int amqp_proto_open(URLContext *h, const char *uri, int flags)
> > +{
> > + int ret, server_msg;
> > + char hostname[STR_LEN], credentials[STR_LEN];
> > + char *credentials_decoded;
> > + int port;
> > + const char *user, *password = NULL;
> > + char *p;
> > + amqp_rpc_reply_t broker_reply;
> > + struct timeval tval = { 0 };
> > +
> > + AMQPContext *s = h->priv_data;
> > +
> > + h->is_streamed = 1;
> > + h->max_packet_size = s->pkt_size;
> > +
> > + av_url_split(NULL, 0, credentials, sizeof(credentials),
> > + hostname, sizeof(hostname), &port, NULL, 0, uri);
> > +
> > + if (port < 0)
> > + port = 5672;
> > +
> > + if (hostname[0] == '\0' || port <= 0 || port > 65535 ) {
> > + av_log(h, AV_LOG_ERROR, "Invalid hostname/port\n");
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + credentials_decoded = ff_urldecode(credentials, 0);
>
> This is not entirely correct, becase the username may contain ':'
> characters... So you should split first and urldecode the splitted
> components...
>
Thanks for reviewing and catching these two.
--
Andriy
More information about the ffmpeg-devel
mailing list