diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2003-07-15 16:57:35 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2003-07-15 16:57:35 +0000 |
commit | b689213642724e46b03ab78246c43d7d397c9a09 (patch) | |
tree | 23b4c142c00497dfbb5da7645e978a8c98c3b11b /libavformat/utils.c | |
parent | aa35ccb8e1df62bfb25ec07ad12e0755feac74d2 (diff) | |
download | ffmpeg-b689213642724e46b03ab78246c43d7d397c9a09.tar.gz |
fixed RTP/TCP client support
Originally committed as revision 2045 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 3c54ea4565..90088e1d1d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -312,7 +312,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVFormatParameters *ap) { AVFormatContext *ic = NULL; - int err; + int err, must_open_file; char buf[PROBE_BUF_SIZE]; AVProbeData probe_data, *pd = &probe_data; @@ -331,7 +331,15 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, fmt = av_probe_input_format(pd, 0); } - if (!fmt || !(fmt->flags & AVFMT_NOFILE)) { + /* do not open file if the format does not need it. XXX: specific + hack needed to handle RTSP/TCP */ + must_open_file = 1; + if ((fmt->flags & AVFMT_NOFILE) || + (fmt == &rtp_demux && !strcmp(filename, "null"))) { + must_open_file = 0; + } + + if (!fmt || must_open_file) { /* if no file needed do not try to open one */ if (url_fopen(&ic->pb, filename, URL_RDONLY) < 0) { err = AVERROR_IO; @@ -397,7 +405,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, *ic_ptr = ic; return 0; fail1: - if (!fmt || !(fmt->flags & AVFMT_NOFILE)) { + if (!fmt || must_open_file) { url_fclose(&ic->pb); } fail: @@ -664,7 +672,7 @@ int av_find_stream_info(AVFormatContext *ic) */ void av_close_input_file(AVFormatContext *s) { - int i; + int i, must_open_file; if (s->iformat->read_close) s->iformat->read_close(s); @@ -682,7 +690,12 @@ void av_close_input_file(AVFormatContext *s) } s->packet_buffer = NULL; } - if (!(s->iformat->flags & AVFMT_NOFILE)) { + must_open_file = 1; + if ((s->iformat->flags & AVFMT_NOFILE) || + (s->iformat == &rtp_demux && !strcmp(s->filename, "null"))) { + must_open_file = 0; + } + if (must_open_file) { url_fclose(&s->pb); } av_freep(&s->priv_data); |