[FFmpeg-cvslog] Merge commit 'ea8ae27a5e112d06fd5625f640e40849e6313f0c'

James Almer git at videolan.org
Mon Sep 3 01:17:43 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Sep  2 19:11:23 2018 -0300| [b1b0e532583e26f18ba27f3cc8775dbd62f3bc2b] | committer: James Almer

Merge commit 'ea8ae27a5e112d06fd5625f640e40849e6313f0c'

* commit 'ea8ae27a5e112d06fd5625f640e40849e6313f0c':
  avformat/libsrt: add payload size option

Merged-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1b0e532583e26f18ba27f3cc8775dbd62f3bc2b
---

 doc/protocols.texi    | 21 +++++++++++++++------
 libavformat/libsrt.c  | 27 ++++++++++++++++++++-------
 libavformat/version.h |  2 +-
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 4c5e972a04..6322581c86 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1255,6 +1255,21 @@ only if @option{pbkeylen} is non-zero. It is used on
 the receiver only if the received data is encrypted.
 The configured passphrase cannot be recovered (write-only).
 
+ at item payload_size=@var{bytes}
+Sets the maximum declared size of a packet transferred
+during the single call to the sending function in Live
+mode. Use 0 if this value isn't used (which is default in
+file mode).
+Default is -1 (automatic), which typically means MPEG-TS;
+if you are going to use SRT
+to send any different kind of payload, such as, for example,
+wrapping a live stream in very small frames, then you can
+use a bigger maximum frame size, though not greater than
+1456 bytes.
+
+ at item pkt_size=@var{bytes}
+Alias for @samp{payload_size}.
+
 @item pbkeylen=@var{bytes}
 Sender encryption key length, in bytes.
 Only can be set to 0, 16, 24 and 32.
@@ -1263,12 +1278,6 @@ Not required on receiver (set to 0),
 key size obtained from sender in HaiCrypt handshake.
 Default value is 0.
 
- at item pkt_size=@var{bytes}
-Set maximum SRT payload size, expressed in bytes. Default is -1 (automatic),
-which typically means 1316 as that is the libsrt default for live mode. Libsrt
-can also support payload sizes up to 1456 bytes. (MTU(1500) - UDP.hdr(28) -
-SRT.hdr(16))
-
 @item recv_buffer_size=@var{bytes}
 Set receive buffer size, expressed in bytes.
 
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 2b7e4cb247..cb30f23eb3 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -34,6 +34,16 @@
 #include "os_support.h"
 #include "url.h"
 
+/* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS packets) */
+#ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE
+#define SRT_LIVE_DEFAULT_PAYLOAD_SIZE 1316
+#endif
+
+/* This is the maximum payload size for Live mode, should you have a different payload type than MPEG-TS */
+#ifndef SRT_LIVE_MAX_PAYLOAD_SIZE
+#define SRT_LIVE_MAX_PAYLOAD_SIZE 1456
+#endif
+
 enum SRTMode {
     SRT_MODE_CALLER = 0,
     SRT_MODE_LISTENER = 1,
@@ -48,7 +58,6 @@ typedef struct SRTContext {
     int64_t listen_timeout;
     int recv_buffer_size;
     int send_buffer_size;
-    int pkt_size;
 
     int64_t maxbw;
     int pbkeylen;
@@ -63,6 +72,7 @@ typedef struct SRTContext {
     int tlpktdrop;
     int nakreport;
     int64_t connect_timeout;
+    int payload_size;
     enum SRTMode mode;
 } SRTContext;
 
@@ -74,7 +84,10 @@ static const AVOption libsrt_options[] = {
     { "listen_timeout", "Connection awaiting timeout",                                          OFFSET(listen_timeout),   AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
     { "send_buffer_size", "Socket send buffer size (in bytes)",                                 OFFSET(send_buffer_size), AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
     { "recv_buffer_size", "Socket receive buffer size (in bytes)",                              OFFSET(recv_buffer_size), AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
-    { "pkt_size",       "Maximum SRT packet size",                                              OFFSET(pkt_size),         AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
+    { "pkt_size",       "Maximum SRT packet size",                                              OFFSET(payload_size),     AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E, "payload_size" },
+    { "payload_size",   "Maximum SRT packet size",                                              OFFSET(payload_size),     AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E, "payload_size" },
+    { "ts_size",        NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRT_LIVE_DEFAULT_PAYLOAD_SIZE }, INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
+    { "max_size",       NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRT_LIVE_MAX_PAYLOAD_SIZE },     INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
     { "maxbw",          "Maximum bandwidth (bytes per second) that the connection can use",     OFFSET(maxbw),            AV_OPT_TYPE_INT64,    { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
     { "pbkeylen",       "Crypto key len in bytes {16,24,32} Default: 16 (128-bit)",             OFFSET(pbkeylen),         AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, 32,        .flags = D|E },
     { "passphrase",     "Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto",             OFFSET(passphrase),       AV_OPT_TYPE_STRING,   { .str = NULL },              .flags = D|E },
@@ -287,8 +300,8 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
         (tsbpddelay >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDDELAY, "SRTO_TSBPDELAY", &tsbpddelay, sizeof(tsbpddelay)) < 0) ||
         (s->tlpktdrop >= 0 && libsrt_setsockopt(h, fd, SRTO_TLPKTDROP, "SRTO_TLPKDROP", &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) ||
         (s->nakreport >= 0 && libsrt_setsockopt(h, fd, SRTO_NAKREPORT, "SRTO_NAKREPORT", &s->nakreport, sizeof(s->nakreport)) < 0) ||
-        (s->pkt_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->pkt_size, sizeof(s->pkt_size)) < 0) ||
-        (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 )) {
+        (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 )) ||
+        (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) {
         return AVERROR(EIO);
     }
     return 0;
@@ -464,9 +477,6 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         if (av_find_info_tag(buf, sizeof(buf), "oheadbw", p)) {
             s->oheadbw = strtoll(buf, NULL, 10);
         }
-        if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
-            s->pkt_size = strtol(buf, NULL, 10);
-        }
         if (av_find_info_tag(buf, sizeof(buf), "tsbpddelay", p)) {
             s->tsbpddelay = strtol(buf, NULL, 10);
         }
@@ -479,6 +489,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         if (av_find_info_tag(buf, sizeof(buf), "connect_timeout", p)) {
             s->connect_timeout = strtol(buf, NULL, 10);
         }
+        if (av_find_info_tag(buf, sizeof(buf), "payload_size", p)) {
+            s->payload_size = strtol(buf, NULL, 10);
+        }
         if (av_find_info_tag(buf, sizeof(buf), "mode", p)) {
             if (!strcmp(buf, "caller")) {
                 s->mode = SRT_MODE_CALLER;
diff --git a/libavformat/version.h b/libavformat/version.h
index da292d4242..b65ba19f3c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  17
-#define LIBAVFORMAT_VERSION_MICRO 104
+#define LIBAVFORMAT_VERSION_MICRO 105
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \


======================================================================

diff --cc doc/protocols.texi
index 4c5e972a04,5b625e571b..6322581c86
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@@ -1255,6 -755,17 +1255,21 @@@ only if @option{pbkeylen} is non-zero. 
  the receiver only if the received data is encrypted.
  The configured passphrase cannot be recovered (write-only).
  
 - at item payloadsize=@var{bytes}
++ at item payload_size=@var{bytes}
+ Sets the maximum declared size of a packet transferred
+ during the single call to the sending function in Live
+ mode. Use 0 if this value isn't used (which is default in
+ file mode).
 -Default value is for MPEG-TS; if you are going to use SRT
++Default is -1 (automatic), which typically means MPEG-TS;
++if you are going to use SRT
+ to send any different kind of payload, such as, for example,
+ wrapping a live stream in very small frames, then you can
+ use a bigger maximum frame size, though not greater than
+ 1456 bytes.
+ 
++ at item pkt_size=@var{bytes}
++Alias for @samp{payload_size}.
++
  @item pbkeylen=@var{bytes}
  Sender encryption key length, in bytes.
  Only can be set to 0, 16, 24 and 32.
diff --cc libavformat/libsrt.c
index 2b7e4cb247,ec209c236d..cb30f23eb3
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@@ -74,7 -84,6 +84,10 @@@ static const AVOption libsrt_options[] 
      { "listen_timeout", "Connection awaiting timeout",                                          OFFSET(listen_timeout),   AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
      { "send_buffer_size", "Socket send buffer size (in bytes)",                                 OFFSET(send_buffer_size), AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
      { "recv_buffer_size", "Socket receive buffer size (in bytes)",                              OFFSET(recv_buffer_size), AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
-     { "pkt_size",       "Maximum SRT packet size",                                              OFFSET(pkt_size),         AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, INT_MAX,   .flags = D|E },
++    { "pkt_size",       "Maximum SRT packet size",                                              OFFSET(payload_size),     AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E, "payload_size" },
++    { "payload_size",   "Maximum SRT packet size",                                              OFFSET(payload_size),     AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E, "payload_size" },
++    { "ts_size",        NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRT_LIVE_DEFAULT_PAYLOAD_SIZE }, INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
++    { "max_size",       NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = SRT_LIVE_MAX_PAYLOAD_SIZE },     INT_MIN, INT_MAX, .flags = D|E, "payload_size" },
      { "maxbw",          "Maximum bandwidth (bytes per second) that the connection can use",     OFFSET(maxbw),            AV_OPT_TYPE_INT64,    { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
      { "pbkeylen",       "Crypto key len in bytes {16,24,32} Default: 16 (128-bit)",             OFFSET(pbkeylen),         AV_OPT_TYPE_INT,      { .i64 = -1 }, -1, 32,        .flags = D|E },
      { "passphrase",     "Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto",             OFFSET(passphrase),       AV_OPT_TYPE_STRING,   { .str = NULL },              .flags = D|E },
@@@ -287,8 -290,8 +300,8 @@@ static int libsrt_set_options_pre(URLCo
          (tsbpddelay >= 0 && libsrt_setsockopt(h, fd, SRTO_TSBPDDELAY, "SRTO_TSBPDELAY", &tsbpddelay, sizeof(tsbpddelay)) < 0) ||
          (s->tlpktdrop >= 0 && libsrt_setsockopt(h, fd, SRTO_TLPKTDROP, "SRTO_TLPKDROP", &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) ||
          (s->nakreport >= 0 && libsrt_setsockopt(h, fd, SRTO_NAKREPORT, "SRTO_NAKREPORT", &s->nakreport, sizeof(s->nakreport)) < 0) ||
-         (s->pkt_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->pkt_size, sizeof(s->pkt_size)) < 0) ||
-         (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 )) {
 -        (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) < 0) ||
 -        (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0)) {
++        (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 )) ||
++        (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) {
          return AVERROR(EIO);
      }
      return 0;
diff --cc libavformat/version.h
index da292d4242,016f266f1f..b65ba19f3c
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@@ -29,11 -29,9 +29,11 @@@
  
  #include "libavutil/version.h"
  
 -#define LIBAVFORMAT_VERSION_MAJOR 58
 -#define LIBAVFORMAT_VERSION_MINOR  2
 -#define LIBAVFORMAT_VERSION_MICRO  0
 +// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 +// Also please add any ticket numbers that you believe might be affected here
 +#define LIBAVFORMAT_VERSION_MAJOR  58
 +#define LIBAVFORMAT_VERSION_MINOR  17
- #define LIBAVFORMAT_VERSION_MICRO 104
++#define LIBAVFORMAT_VERSION_MICRO 105
  
  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                 LIBAVFORMAT_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list