summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-18 01:33:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-18 01:54:40 +0200
commitfae714a9fbff876c4cacfe7d437c940d557b44ce (patch)
treea902e7f012153f96582d2eecdfb78def1c0260a1 /libavformat/rtsp.c
parent9be937d38dac1ccf16fa8a7c0f9098bad5bb0431 (diff)
parent3ec344626c4ec2f515169f89bffe95dea92a5982 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: avconv: add presets rtsp: Expose the flag options via private AVOptions for sdp and rtp, too rtsp: Make the rtsp flags avoptions set via a define rtpenc: Set a default video codec avoptions: Fix av_opt_flag_is_set rtp: Fix ff_rtp_get_payload_type doc: Update the documentation on setting options for RTSP rtsp: Remove the separate filter_source variable rtsp: Accept options via private avoptions instead of URL options rtsp: Simplify AVOption definitions rtsp: Merge the AVOption lists lavfi: port libmpcodecs delogo filter lavfi: port boxblur filter from libmpcodecs lavfi: add negate filter lavfi: add LUT (LookUp Table) generic filters AVOptions: don't segfault on NULL parameter in av_set_options_string() avio: Check for invalid buffer length. mpegenc/mpegtsenc: add muxrate private options. lavf: deprecate AVFormatContext.file_size mov: add support for TV metadata atoms tves, tvsn and stik Conflicts: Changelog doc/filters.texi doc/protocols.texi libavfilter/Makefile libavfilter/allfilters.c libavfilter/avfilter.h libavfilter/formats.c libavfilter/internal.h libavfilter/vf_boxblur.c libavfilter/vf_delogo.c libavfilter/vf_lut.c libavformat/mpegtsenc.c libavformat/utils.c libavformat/version.h libavutil/opt.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c75
1 files changed, 70 insertions, 5 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 64e29cc487..cc47f92e69 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -45,6 +45,7 @@
#include "rtpdec_formats.h"
#include "rtpenc_chain.h"
#include "url.h"
+#include "rtpenc.h"
//#define DEBUG
@@ -56,6 +57,36 @@
#define SDP_MAX_SIZE 16384
#define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
+#define OFFSET(x) offsetof(RTSPState, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+#define ENC AV_OPT_FLAG_ENCODING_PARAM
+
+#define RTSP_FLAG_OPTS(name, longname) \
+ { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
+ { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }
+
+const AVOption ff_rtsp_options[] = {
+ { "initial_pause", "Don't start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_INT, {0}, 0, 1, DEC },
+ FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags),
+ { "rtsp_transport", "RTSP transport protocols", OFFSET(lower_transport_mask), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC|ENC, "rtsp_transport" }, \
+ { "udp", "UDP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP}, 0, 0, DEC|ENC, "rtsp_transport" }, \
+ { "tcp", "TCP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_TCP}, 0, 0, DEC|ENC, "rtsp_transport" }, \
+ { "udp_multicast", "UDP multicast", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP_MULTICAST}, 0, 0, DEC, "rtsp_transport" },
+ { "http", "HTTP tunneling", 0, AV_OPT_TYPE_CONST, {(1 << RTSP_LOWER_TRANSPORT_HTTP)}, 0, 0, DEC, "rtsp_transport" },
+ RTSP_FLAG_OPTS("rtsp_flags", "RTSP flags"),
+ { NULL },
+};
+
+static const AVOption sdp_options[] = {
+ RTSP_FLAG_OPTS("sdp_flags", "SDP flags"),
+ { NULL },
+};
+
+static const AVOption rtp_options[] = {
+ RTSP_FLAG_OPTS("rtp_flags", "RTP flags"),
+ { NULL },
+};
+
static void get_word_until_chars(char *buf, int buf_size,
const char *sep, const char **pp)
{
@@ -1218,7 +1249,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
case RTSP_LOWER_TRANSPORT_UDP: {
char url[1024], options[30] = "";
- if (rt->filter_source)
+ if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
av_strlcpy(options, "?connect=1", sizeof(options));
/* Use source address if specified */
if (reply->transports[0].source[0]) {
@@ -1308,8 +1339,17 @@ int ff_rtsp_connect(AVFormatContext *s)
if (!ff_network_init())
return AVERROR(EIO);
-redirect:
+
rt->control_transport = RTSP_MODE_PLAIN;
+ if (rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_HTTP)) {
+ rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP;
+ rt->control_transport = RTSP_MODE_TUNNEL;
+ }
+ /* Only pass through valid flags from here */
+ rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
+
+redirect:
+ lower_transport_mask = rt->lower_transport_mask;
/* extract hostname and port */
av_url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
@@ -1319,6 +1359,7 @@ redirect:
if (port < 0)
port = RTSP_DEFAULT_PORT;
+#if FF_API_RTSP_URL_OPTIONS
/* search for options */
option_list = strrchr(path, '?');
if (option_list) {
@@ -1326,6 +1367,7 @@ redirect:
* the options back into the same string. */
filename = option_list;
while (option_list) {
+ int handled = 1;
/* move the option pointer */
option = ++option_list;
option_list = strchr(option_list, '&');
@@ -1343,7 +1385,7 @@ redirect:
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
} else if (!strcmp(option, "filter_src")) {
- rt->filter_source = 1;
+ rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC;
} else {
/* Write options back into the buffer, using memmove instead
* of strcpy since the strings may overlap. */
@@ -1351,10 +1393,16 @@ redirect:
memmove(++filename, option, len);
filename += len;
if (option_list) *filename = '&';
+ handled = 0;
}
+ if (handled)
+ av_log(s, AV_LOG_WARNING, "Options passed via URL are "
+ "deprecated, use -rtsp_transport "
+ "and -rtsp_flags instead.\n");
}
*filename = 0;
}
+#endif
if (!lower_transport_mask)
lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
@@ -1797,8 +1845,9 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(url, sizeof(url), "rtp", NULL,
namebuf, rtsp_st->sdp_port,
- "?localport=%d&ttl=%d", rtsp_st->sdp_port,
- rtsp_st->sdp_ttl);
+ "?localport=%d&ttl=%d&connect=%d", rtsp_st->sdp_port,
+ rtsp_st->sdp_ttl,
+ rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0);
if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
@@ -1820,6 +1869,13 @@ static int sdp_read_close(AVFormatContext *s)
return 0;
}
+static const AVClass sdp_demuxer_class = {
+ .class_name = "SDP demuxer",
+ .item_name = av_default_item_name,
+ .option = sdp_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_sdp_demuxer = {
.name = "sdp",
.long_name = NULL_IF_CONFIG_SMALL("SDP"),
@@ -1828,6 +1884,7 @@ AVInputFormat ff_sdp_demuxer = {
.read_header = sdp_read_header,
.read_packet = ff_rtsp_fetch_packet,
.read_close = sdp_read_close,
+ .priv_class = &sdp_demuxer_class
};
#endif /* CONFIG_SDP_DEMUXER */
@@ -1924,6 +1981,13 @@ fail:
return ret;
}
+static const AVClass rtp_demuxer_class = {
+ .class_name = "RTP demuxer",
+ .item_name = av_default_item_name,
+ .option = rtp_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_rtp_demuxer = {
.name = "rtp",
.long_name = NULL_IF_CONFIG_SMALL("RTP input format"),
@@ -1933,6 +1997,7 @@ AVInputFormat ff_rtp_demuxer = {
.read_packet = ff_rtsp_fetch_packet,
.read_close = sdp_read_close,
.flags = AVFMT_NOFILE,
+ .priv_class = &rtp_demuxer_class
};
#endif /* CONFIG_RTP_DEMUXER */