From patchwork Sun Jun 14 16:56:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Levis X-Patchwork-Id: 20349 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EA7AA449E51 for ; Sun, 14 Jun 2020 19:56:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C457068B765; Sun, 14 Jun 2020 19:56:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 089E868B727 for ; Sun, 14 Jun 2020 19:56:24 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id j10so14687655wrw.8 for ; Sun, 14 Jun 2020 09:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2/TCj6E+Sh7dHScXFGRfwDa9q1voOBNFHWxwFR8gJpc=; b=EFaS+hO8hvF56AlKYXFo05ybYfUGV9vFlB09Yv2pc/TUabBKzzooS+lut4XzqQwEXA Xq9EU48+uiz+QOSXR4/ywSs7Uf+SSOwwfBWcDxsNpa3CnukBE3wiAtqi5LJSNxUt1oGV pSygFBencIp9rTigqvSZWETpQdnMi65zC5DHRoc4kyX2BkbRExb7Ybm6/xov866Qt5kq KQZpnZysqHniDJj9gVI3R6OC3fUZlm+nOD3LGoOKHKEa6gHzveS0quH6sIF49H5zxRTQ 6VCBQ2dEQvjI4UY+Wtvx9suy1aToj55SD1ViNOjsm1quLnzljBckPiCRA6RdIYoojAAR 3Phg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2/TCj6E+Sh7dHScXFGRfwDa9q1voOBNFHWxwFR8gJpc=; b=a/OLLjeI4VLTMDDPajZphkkyLD2MQ4rkFVy+F6K/kg3rSA/3nC29ttpPOBs//tKOpU K2JClYdo1jjmet0F1uvxQtaepMw35Sf7tKen4Kk0mcZCwxTra38qOtwGvD6o39TEmQht f7shaSPzUVXJ1+p3wDO0x47M0ZZzLGfluJAdYOirgh9NJsYK1E3ZL+2cTbPEuWUpYLk5 Au+40z2Bo4H3AHAANgEVgSU8vGI/p8WcGjVH+8zqc/GkTekIdSWZZ8f5M2C/XXGmT8Hs qmUd2/r1AJB+mM01mOHlCA1DM+gcodT/GxqlbisPow8sddPlheOAlxOZ0P0SPq99qpBm h0RA== X-Gm-Message-State: AOAM531IOjKGPdjiaZT131KsANssSe7fiRvMscIOIobq8XC7z25PAUFD 0uKdJPyDaa3hB5jH230QyqcFq9waqj0= X-Google-Smtp-Source: ABdhPJwWzTi10xLk0N9U0KwKpdiHc54NzIinBDWCckBi+HBepJOrBh4yZPVAaKynixgbQJ+RkuNqYA== X-Received: by 2002:adf:eec2:: with SMTP id a2mr23726156wrp.136.1592153783051; Sun, 14 Jun 2020 09:56:23 -0700 (PDT) Received: from localhost.localdomain (82-64-71-170.subs.proxad.net. [82.64.71.170]) by smtp.gmail.com with ESMTPSA id g3sm22716014wrb.46.2020.06.14.09.56.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jun 2020 09:56:22 -0700 (PDT) From: Levis Florian To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Jun 2020 18:56:06 +0200 Message-Id: <20200614165606.36659-1-levis.florian@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200614131237.21188-1-levis.florian@gmail.com> References: <20200614131237.21188-1-levis.florian@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat: AMQP: add option delivery_mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Levis Florian Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi, I hope this reply will go to the correct thread. I reworked my patch after Marton Balint review. * fix: missing documentation * fix: use AV_OPT_TYPE_CONST Signed-off-by: Levis Florian --- doc/protocols.texi | 13 +++++++++++++ libavformat/libamqp.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 7aa758541c..336246e67a 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -109,6 +109,19 @@ the received message may be truncated causing decoding errors. The timeout in seconds during the initial connection to the broker. The default value is rw_timeout, or 5 seconds if rw_timeout is not set. +@item delivery_mode @var{mode} +Sets the delivery mode. + +The following values are recognized: +@table @samp +@item persistent +Delivery mode set to "persistent" (2). This is the default value. + +@item non-persistent +Delivery mode set to "non-persistent" (1) + +@end table + @end table @section async diff --git a/libavformat/libamqp.c b/libavformat/libamqp.c index aaf0e51152..f966edbed1 100644 --- a/libavformat/libamqp.c +++ b/libavformat/libamqp.c @@ -39,6 +39,7 @@ typedef struct AMQPContext { int pkt_size; int64_t connection_timeout; int pkt_size_overflow; + int delivery_mode; } AMQPContext; #define STR_LEN 1024 @@ -52,6 +53,9 @@ static const AVOption options[] = { { "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, INT64_MAX, .flags = D | E}, + { "delivery_mode", "Delivery more (non-persistent: 1/persistent: 2)", OFFSET(delivery_mode), AV_OPT_TYPE_INT, { .i64 = AMQP_DELIVERY_PERSISTENT }, 1, 2, .flags = E, "delivery_mode"}, + { "persistent", "persistent delivery mode", 0, AV_OPT_TYPE_CONST, {.i64=AMQP_DELIVERY_PERSISTENT }, 0, 0, E, "delivery_mode" }, + { "non-persistent", "non-persistent delivery mode", 0, AV_OPT_TYPE_CONST, {.i64=AMQP_DELIVERY_NONPERSISTENT }, 0, 0, E, "delivery_mode" }, { NULL } }; @@ -222,7 +226,7 @@ static int amqp_proto_write(URLContext *h, const unsigned char *buf, int size) props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG; props.content_type = amqp_cstring_bytes("octet/stream"); - props.delivery_mode = 2; /* persistent delivery mode */ + props.delivery_mode = s->delivery_mode; ret = amqp_basic_publish(s->conn, DEFAULT_CHANNEL, amqp_cstring_bytes(s->exchange), amqp_cstring_bytes(s->routing_key), 0, 0,