Commit 6fc41bb2 authored by bellard's avatar bellard

added rtp port range support


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@792 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 83608eed
...@@ -47,6 +47,10 @@ int rtsp_abort_req = 0; ...@@ -47,6 +47,10 @@ int rtsp_abort_req = 0;
changing this variable */ changing this variable */
int rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_TCP) | (1 << RTSP_PROTOCOL_RTP_UDP) | (1 << RTSP_PROTOCOL_RTP_UDP_MULTICAST); int rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_TCP) | (1 << RTSP_PROTOCOL_RTP_UDP) | (1 << RTSP_PROTOCOL_RTP_UDP_MULTICAST);
/* if non zero, then set a range for RTP ports */
int rtsp_rtp_port_min = 0;
int rtsp_rtp_port_max = 0;
FFRTSPCallback *ff_rtsp_callback = NULL; FFRTSPCallback *ff_rtsp_callback = NULL;
static int rtsp_probe(AVProbeData *p) static int rtsp_probe(AVProbeData *p)
...@@ -486,8 +490,8 @@ static int rtsp_read_header(AVFormatContext *s, ...@@ -486,8 +490,8 @@ static int rtsp_read_header(AVFormatContext *s,
/* XXX: we assume the same server is used for the control of each /* XXX: we assume the same server is used for the control of each
RTSP stream */ RTSP stream */
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
AVInputFormat *fmt;
char transport[2048]; char transport[2048];
AVInputFormat *fmt;
st = s->streams[i]; st = s->streams[i];
rtsp_st = st->priv_data; rtsp_st = st->priv_data;
...@@ -497,12 +501,27 @@ static int rtsp_read_header(AVFormatContext *s, ...@@ -497,12 +501,27 @@ static int rtsp_read_header(AVFormatContext *s,
/* RTP/UDP */ /* RTP/UDP */
if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_UDP)) { if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_UDP)) {
fmt = &rtp_demux; char buf[256];
if (av_open_input_file(&rtsp_st->ic, "rtp://", fmt, 0, NULL) < 0) { int j;
/* first try in specified port range */
if (rtsp_rtp_port_min != 0) {
for(j=rtsp_rtp_port_min;j<=rtsp_rtp_port_max;j++) {
snprintf(buf, sizeof(buf), "rtp://?localport=%d", j);
if (!av_open_input_file(&rtsp_st->ic, buf,
&rtp_demux, 0, NULL))
goto rtp_opened;
}
}
/* then try on any port */
if (av_open_input_file(&rtsp_st->ic, "rtp://",
&rtp_demux, 0, NULL) < 0) {
err = AVERROR_INVALIDDATA; err = AVERROR_INVALIDDATA;
goto fail; goto fail;
} }
rtp_opened:
port = rtp_get_local_port(url_fileno(&rtsp_st->ic->pb)); port = rtp_get_local_port(url_fileno(&rtsp_st->ic->pb));
if (transport[0] != '\0') if (transport[0] != '\0')
pstrcat(transport, sizeof(transport), ","); pstrcat(transport, sizeof(transport), ",");
......
...@@ -79,6 +79,8 @@ void rtsp_parse_line(RTSPHeader *reply, const char *buf); ...@@ -79,6 +79,8 @@ void rtsp_parse_line(RTSPHeader *reply, const char *buf);
extern int rtsp_abort_req; extern int rtsp_abort_req;
extern int rtsp_default_protocols; extern int rtsp_default_protocols;
extern int rtsp_rtp_port_min;
extern int rtsp_rtp_port_max;
extern FFRTSPCallback *ff_rtsp_callback; extern FFRTSPCallback *ff_rtsp_callback;
#endif /* RTSP_H */ #endif /* RTSP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment