diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-11 23:56:02 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-11 23:57:11 +0200 |
commit | 9ca27df52fb4306a8e37c38d1ed9ab40c42a62dc (patch) | |
tree | 2da7168c9b3926d8a6886af3586fafeee41c5f4e /libavformat/rtsp.c | |
parent | 5f298c679107c3607f6f54c1f38eeb1ba36900a9 (diff) | |
parent | 183b1c2268529bbb8389d572deb00083c49682dc (diff) | |
download | ffmpeg-9ca27df52fb4306a8e37c38d1ed9ab40c42a62dc.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
configure: Check for the math function rint
TechSmith Screen Codec 2 decoder
rtsp: Add listen mode
rtsp: Make rtsp_open_transport_ctx() non-static
rtsp: Move rtsp_read_close
rtsp: Parse the mode=receive/record parameter in transport lines
Conflicts:
Changelog
libavcodec/avcodec.h
libavcodec/version.h
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r-- | libavformat/rtsp.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index c3b40aad86..abfdca80db 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -63,7 +63,8 @@ #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" } + { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }, \ + { "listen", "Wait for incoming connections", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_LISTEN}, 0, 0, DEC, "rtsp_flags" } #define RTSP_MEDIATYPE_OPTS(name, longname) \ { name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { (1 << (AVMEDIA_TYPE_DATA+1)) - 1 }, INT_MIN, INT_MAX, DEC, "allowed_media_types" }, \ @@ -83,6 +84,7 @@ const AVOption ff_rtsp_options[] = { RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"), { "min_port", "Minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC }, { "max_port", "Maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC }, + { "timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {-1}, INT_MIN, INT_MAX, DEC }, { NULL }, }; @@ -595,7 +597,7 @@ void ff_rtsp_close_streams(AVFormatContext *s) av_free(rt->recvbuf); } -static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) +int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) { RTSPState *rt = s->priv_data; AVStream *st = NULL; @@ -749,6 +751,14 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p) get_word_sep(buf, sizeof(buf), ";,", &p); av_strlcpy(th->source, buf, sizeof(th->source)); } + } else if (!strcmp(parameter, "mode")) { + if (*p == '=') { + p++; + get_word_sep(buf, sizeof(buf), ";, ", &p); + if (!strcmp(buf, "record") || + !strcmp(buf, "receive")) + th->mode_record = 1; + } } while (*p != ';' && *p != '\0' && *p != ',') @@ -1389,7 +1399,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, } } - if ((err = rtsp_open_transport_ctx(s, rtsp_st))) + if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st))) goto fail; } @@ -1701,14 +1711,24 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, } #if CONFIG_RTSP_DEMUXER if (tcp_fd != -1 && p[0].revents & POLLIN) { - RTSPMessageHeader reply; - - ret = ff_rtsp_read_reply(s, &reply, NULL, 0, NULL); - if (ret < 0) - return ret; - /* XXX: parse message */ - if (rt->state != RTSP_STATE_STREAMING) - return 0; + if (rt->rtsp_flags & RTSP_FLAG_LISTEN) { + if (rt->state == RTSP_STATE_STREAMING) { + if (!ff_rtsp_parse_streaming_commands(s)) + return AVERROR_EOF; + else + av_log(s, AV_LOG_WARNING, + "Unable to answer to TEARDOWN\n"); + } else + return 0; + } else { + RTSPMessageHeader reply; + ret = ff_rtsp_read_reply(s, &reply, NULL, 0, NULL); + if (ret < 0) + return ret; + /* XXX: parse message */ + if (rt->state != RTSP_STATE_STREAMING) + return 0; + } } #endif } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) { @@ -1912,7 +1932,7 @@ static int sdp_read_header(AVFormatContext *s) err = AVERROR_INVALIDDATA; goto fail; } - if ((err = rtsp_open_transport_ctx(s, rtsp_st))) + if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st))) goto fail; } return 0; |