[FFmpeg-cvslog] Add "prefer_tcp" flag to "rtsp_flags"

Andrey Utkin git at videolan.org
Tue Mar 4 23:14:24 CET 2014


ffmpeg | branch: master | Andrey Utkin <andrey.utkin at corp.bluecherry.net> | Tue Mar  4 15:43:59 2014 +0200| [bc764d786fe6d6eda2e1621acfaa08b8aebb0cac] | committer: Michael Niedermayer

Add "prefer_tcp" flag to "rtsp_flags"

If set, and if TCP is available as RTSP RTP transport, then TCP will be
tried first as RTP transport.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 doc/protocols.texi |    2 ++
 libavformat/rtsp.c |    5 +++++
 libavformat/rtsp.h |    1 +
 3 files changed, 8 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 2c84265..36aecff 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -733,6 +733,8 @@ The following values are accepted:
 Accept packets only from negotiated peer address and port.
 @item listen
 Act as a server, listening for an incoming connection.
+ at item prefer_tcp
+Try TCP for RTP transport first, if TCP is available as RTSP RTP transport.
 @end table
 
 Default value is @samp{none}.
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 82ae3bd..d89af62 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -86,6 +86,7 @@ const AVOption ff_rtsp_options[] = {
     { "http", "HTTP tunneling", 0, AV_OPT_TYPE_CONST, {.i64 = (1 << RTSP_LOWER_TRANSPORT_HTTP)}, 0, 0, DEC, "rtsp_transport" },
     RTSP_FLAG_OPTS("rtsp_flags", "set RTSP flags"),
     { "listen", "wait for incoming connections", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_LISTEN}, 0, 0, DEC, "rtsp_flags" },
+    { "prefer_tcp", "try RTP via TCP first, if available", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_PREFER_TCP}, 0, 0, DEC|ENC, "rtsp_flags" },
     RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"),
     { "min_port", "set minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
     { "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
@@ -1766,6 +1767,10 @@ redirect:
         int lower_transport = ff_log2_tab[lower_transport_mask &
                                   ~(lower_transport_mask - 1)];
 
+        if ((lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_TCP))
+                && (rt->rtsp_flags & RTSP_FLAG_PREFER_TCP))
+            lower_transport = RTSP_LOWER_TRANSPORT_TCP;
+
         err = ff_rtsp_make_setup_request(s, host, port, lower_transport,
                                  rt->server_type == RTSP_SERVER_REAL ?
                                      real_challenge : NULL);
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 76c7f18..d159793 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -413,6 +413,7 @@ typedef struct RTSPState {
 #define RTSP_FLAG_CUSTOM_IO   0x4    /**< Do all IO via the AVIOContext. */
 #define RTSP_FLAG_RTCP_TO_SOURCE 0x8 /**< Send RTCP packets to the source
                                           address of received packets. */
+#define RTSP_FLAG_PREFER_TCP  0x10   /**< Try RTP via TCP first if possible. */
 
 typedef struct RTSPSource {
     char addr[128]; /**< Source-specific multicast include source IP address (from SDP content) */



More information about the ffmpeg-cvslog mailing list