diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-23 01:05:20 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-23 01:05:20 +0100 |
commit | feb997577b66367a0c4269100888640699ee890d (patch) | |
tree | b6ff06f8d443ea963d082f97f51d07520833ae7e /libavformat/rtsp.c | |
parent | 9bf9c314a093db16a009829bfe874bf03ffaecc9 (diff) | |
parent | 15cea3695daf3f6363794594982e3816ddc8d90b (diff) | |
download | ffmpeg-feb997577b66367a0c4269100888640699ee890d.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits)
riff: fix invalid av_freep() calls on EOF in ff_read_riff_info
pam: Fix a typo that broke writing and reading PAM files.
mxfdec: fix memleak on av_realloc failures
mxfdec: Do not parse slices or DeltaEntryArrays.
mxfdec: hybrid demuxing/seeking solution
mxfdec: Add Avid's essence element key.
mfxdec: Separate mxf_essence_container_uls for audio and video.
mxfdec: Compute packet offsets properly.
mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack.
mxfdec: use av_dlog() for 'no corresponding source package found'
mxfdec: Make mxf->partitions sorted by offset.
mxfdec: parse ThisPartition
mxfdec: Speed up metadata and index parsing.
mxfdec: Make sure DataDefinition is consistent between material track and source track.
mxfdec: add EssenceContainer UL found in 0001GL00.MXF.A1.mxf_opatom.mxf
mxfdec: Add hack that adjusts the n_delta calculation when system items are present.
mxfdec: Parse IndexTableSegments and convert them into AVIndexEntry arrays.
mxfdec: Move FooterPartition to MXFContext and make sure it is never zero.
mxfdec: check return value of avio_seek
mxfdec: skip to end of structural sets
...
Conflicts:
configure
libavcodec/pnm.c
libavformat/mxfdec.c
libavformat/riff.c
libavformat/rtsp.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r-- | libavformat/rtsp.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 56e5de27f8..c2a0d26e5e 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -81,6 +81,8 @@ const AVOption ff_rtsp_options[] = { { "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"), 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 }, { NULL }, }; @@ -1117,14 +1119,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, /* default timeout: 1 minute */ rt->timeout = 60; - /* for each stream, make the setup request */ - /* XXX: we assume the same server is used for the control of each - * RTSP stream */ - port_off = av_get_random_seed() % (RTSP_RTP_PORT_MAX - RTSP_RTP_PORT_MIN); + /* Choose a random starting offset within the first half of the + * port range, to allow for a number of ports to try even if the offset + * happens to be at the end of the random range. */ + port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2); /* even random offset */ port_off -= port_off & 0x01; - for (j = RTSP_RTP_PORT_MIN + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) { + for (j = rt->rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) { char transport[2048]; /* @@ -1161,7 +1163,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, } /* first try in specified port range */ - while (j <= RTSP_RTP_PORT_MAX) { + while (j <= rt->rtp_port_max) { ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1, "?localport=%d", j); /* we will use two ports per rtp stream (rtp and rtcp) */ @@ -1358,6 +1360,13 @@ int ff_rtsp_connect(AVFormatContext *s) struct sockaddr_storage peer; socklen_t peer_len = sizeof(peer); + if (rt->rtp_port_max < rt->rtp_port_min) { + av_log(s, AV_LOG_ERROR, "Invalid UDP port range, max port %d less " + "than min port %d\n", rt->rtp_port_max, + rt->rtp_port_min); + return AVERROR(EINVAL); + } + if (!ff_network_init()) return AVERROR(EIO); |