diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c index ac518dcd7c..7e89534f88 100644 --- a/libavformat/applehttpproto.c +++ b/libavformat/applehttpproto.c @@ -29,6 +29,7 @@ #include "libavutil/avstring.h" #include "avformat.h" #include "internal.h" +#include "url.h" #include /* @@ -274,7 +275,7 @@ retry: } url = s->segments[s->cur_seq_no - s->start_seq_no]->url, av_log(NULL, AV_LOG_DEBUG, "opening %s\n", url); - ret = url_open(&s->seg_hd, url, URL_RDONLY); + ret = ffurl_open(&s->seg_hd, url, URL_RDONLY); if (ret < 0) { if (url_interrupt_cb()) return AVERROR_EXIT; diff --git a/libavformat/avio.c b/libavformat/avio.c index 5a6c53ba23..a14ea767bc 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -176,6 +176,10 @@ int url_connect(URLContext* uc) { return ffurl_connect(uc); } +int url_open(URLContext **puc, const char *filename, int flags) +{ + return ffurl_open(puc, filename, flags); +} #endif #define URL_SCHEME_CHARS \ @@ -211,7 +215,7 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags) return AVERROR(ENOENT); } -int url_open(URLContext **puc, const char *filename, int flags) +int ffurl_open(URLContext **puc, const char *filename, int flags) { int ret = ffurl_alloc(puc, filename, flags); if (ret) @@ -292,7 +296,7 @@ int64_t url_seek(URLContext *h, int64_t pos, int whence) int url_close(URLContext *h) { int ret = 0; - if (!h) return 0; /* can happen when url_open fails */ + if (!h) return 0; /* can happen when ffurl_open fails */ if (h->is_connected && h->prot->url_close) ret = h->prot->url_close(h); @@ -308,7 +312,7 @@ int url_close(URLContext *h) int url_exist(const char *filename) { URLContext *h; - if (url_open(&h, filename, URL_RDONLY) < 0) + if (ffurl_open(&h, filename, URL_RDONLY) < 0) return 0; url_close(h); return 1; diff --git a/libavformat/avio.h b/libavformat/avio.h index 311a51f8c4..02d05f64cb 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -104,21 +104,9 @@ attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol const char *url, int flags); attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags); attribute_deprecated int url_connect(URLContext *h); +attribute_deprecated int url_open(URLContext **h, const char *url, int flags); #endif -/** - * Create an URLContext for accessing to the resource indicated by - * url, and open it. - * - * @param puc pointer to the location where, in case of success, the - * function puts the pointer to the created URLContext - * @param flags flags which control how the resource indicated by url - * is to be opened - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int url_open(URLContext **h, const char *url, int flags); - /** * Read up to size bytes from the resource accessed by h, and store * the read bytes in buf. diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d126fa8b0f..1ae104942c 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -25,6 +25,7 @@ #include "avio.h" #include "avio_internal.h" #include "internal.h" +#include "url.h" #include #define IO_BUFFER_SIZE 32768 @@ -944,7 +945,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags) URLContext *h; int err; - err = url_open(&h, filename, flags); + err = ffurl_open(&h, filename, flags); if (err < 0) return err; err = ffio_fdopen(s, h); diff --git a/libavformat/concat.c b/libavformat/concat.c index 92cc2c8a4b..e99ded2edf 100644 --- a/libavformat/concat.c +++ b/libavformat/concat.c @@ -24,6 +24,7 @@ #include "avformat.h" #include "libavutil/avstring.h" #include "libavutil/mem.h" +#include "url.h" #define AV_CAT_SEPARATOR "|" @@ -100,7 +101,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) uri += len + strspn(uri+len, AV_CAT_SEPARATOR); /* creating URLContext */ - if ((err = url_open(&uc, node_uri, flags)) < 0) + if ((err = ffurl_open(&uc, node_uri, flags)) < 0) break; /* creating size */ diff --git a/libavformat/gopher.c b/libavformat/gopher.c index 4681c8e194..c2e290d077 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -26,6 +26,7 @@ #include "avformat.h" #include "internal.h" #include "network.h" +#include "url.h" typedef struct { URLContext *hd; @@ -99,7 +100,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); s->hd = NULL; - err = url_open(&s->hd, buf, URL_RDWR); + err = ffurl_open(&s->hd, buf, URL_RDWR); if (err < 0) goto fail; diff --git a/libavformat/http.c b/libavformat/http.c index 9b3d606d72..b02de279f2 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -28,6 +28,7 @@ #include "http.h" #include "os_support.h" #include "httpauth.h" +#include "url.h" #include "libavutil/opt.h" /* XXX: POST protocol is not completely implemented because ffmpeg uses @@ -123,7 +124,7 @@ static int http_open_cnx(URLContext *h) port = 80; ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); - err = url_open(&hd, buf, URL_RDWR); + err = ffurl_open(&hd, buf, URL_RDWR); if (err < 0) goto fail; diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c index 47e34ebb24..23815095d1 100644 --- a/libavformat/md5proto.c +++ b/libavformat/md5proto.c @@ -25,6 +25,7 @@ #include "libavutil/error.h" #include "avformat.h" #include "avio.h" +#include "url.h" #define PRIV_SIZE 128 @@ -64,7 +65,7 @@ static int md5_close(URLContext *h) av_strstart(filename, "md5:", &filename); if (*filename) { - err = url_open(&out, filename, URL_WRONLY); + err = ffurl_open(&out, filename, URL_WRONLY); if (err) return err; err = url_write(out, buf, i*2+1); diff --git a/libavformat/mmst.c b/libavformat/mmst.c index ba29b9e05b..fa17fe524b 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -35,6 +35,7 @@ #include "libavutil/intreadwrite.h" #include "libavcodec/bytestream.h" #include "network.h" +#include "url.h" #define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address. #define LOCAL_PORT 1037 // as above. @@ -522,7 +523,7 @@ static int mms_open(URLContext *h, const char *uri, int flags) // establish tcp connection. ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, mmst->host, port, NULL); - err = url_open(&mms->mms_hd, tcpname, URL_RDWR); + err = ffurl_open(&mms->mms_hd, tcpname, URL_RDWR); if (err) goto fail; diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index d74dfac794..7c21ff7bfe 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -36,6 +36,7 @@ #include "flv.h" #include "rtmp.h" #include "rtmppkt.h" +#include "url.h" /* we can't use av_log() with URLContext yet... */ #if FF_API_URL_CLASS @@ -820,7 +821,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) port = RTMP_DEFAULT_PORT; ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); - if (url_open(&rt->stream, buf, URL_RDWR) < 0) { + if (ffurl_open(&rt->stream, buf, URL_RDWR) < 0) { av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 6b537c88ec..1691f3cb48 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -29,6 +29,7 @@ #include "avformat.h" #include "avio_internal.h" #include "rtpdec.h" +#include "url.h" #include #include @@ -189,7 +190,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) build_udp_url(buf, sizeof(buf), hostname, rtp_port, local_rtp_port, ttl, max_packet_size, connect); - if (url_open(&s->rtp_hd, buf, flags) < 0) + if (ffurl_open(&s->rtp_hd, buf, flags) < 0) goto fail; if (local_rtp_port>=0 && local_rtcp_port<0) local_rtcp_port = ff_udp_get_local_port(s->rtp_hd) + 1; @@ -197,7 +198,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) build_udp_url(buf, sizeof(buf), hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size, connect); - if (url_open(&s->rtcp_hd, buf, flags) < 0) + if (ffurl_open(&s->rtcp_hd, buf, flags) < 0) goto fail; /* just to ease handle access. XXX: need to suppress direct handle diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 0f7b11edcc..30deeccf93 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1116,14 +1116,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, "?localport=%d", j); /* we will use two ports per rtp stream (rtp and rtcp) */ j += 2; - if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) + if (ffurl_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) goto rtp_opened; } } #if 0 /* then try on any port */ - if (url_open(&rtsp_st->rtp_handle, "rtp://", URL_RDONLY) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", URL_RDONLY) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1269,7 +1269,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); ff_url_join(url, sizeof(url), "rtp", NULL, namebuf, port, "?ttl=%d", ttl); - if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1460,7 +1460,7 @@ redirect: } else { /* open the tcp connection */ ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); - if (url_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) { + if (ffurl_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) { err = AVERROR(EIO); goto fail; } @@ -1807,7 +1807,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap) namebuf, rtsp_st->sdp_port, "?localport=%d&ttl=%d", rtsp_st->sdp_port, rtsp_st->sdp_ttl); - if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1863,7 +1863,7 @@ static int rtp_read_header(AVFormatContext *s, if (!ff_network_init()) return AVERROR(EIO); - ret = url_open(&in, s->filename, URL_RDONLY); + ret = ffurl_open(&in, s->filename, URL_RDONLY); if (ret) goto fail; diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index e79594bc28..c85039f4da 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -26,6 +26,7 @@ #include "os_support.h" #include "internal.h" #include "avio_internal.h" +#include "url.h" #if HAVE_POLL_H #include #endif @@ -84,7 +85,7 @@ static int sap_read_header(AVFormatContext *s, ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d", port); - ret = url_open(&sap->ann_fd, url, URL_RDONLY); + ret = ffurl_open(&sap->ann_fd, url, URL_RDONLY); if (ret) goto fail; diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 091d11b84b..c811d2f001 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -28,6 +28,7 @@ #include "network.h" #include "os_support.h" #include "rtpenc_chain.h" +#include "url.h" struct SAPState { uint8_t *ann; @@ -145,7 +146,7 @@ static int sap_write_header(AVFormatContext *s) "?ttl=%d", ttl); if (!same_port) base_port += 2; - ret = url_open(&fd, url, URL_WRONLY); + ret = ffurl_open(&fd, url, URL_WRONLY); if (ret) { ret = AVERROR(EIO); goto fail; @@ -157,7 +158,7 @@ static int sap_write_header(AVFormatContext *s) ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port, "?ttl=%d&connect=1", ttl); - ret = url_open(&sap->ann_fd, url, URL_WRONLY); + ret = ffurl_open(&sap->ann_fd, url, URL_WRONLY); if (ret) { ret = AVERROR(EIO); goto fail; diff --git a/libavformat/url.h b/libavformat/url.h index 30fbf62aec..af7dc5c4b6 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -45,4 +45,17 @@ int ffurl_alloc(URLContext **h, const char *url, int flags); */ int ffurl_connect(URLContext *h); +/** + * Create an URLContext for accessing to the resource indicated by + * url, and open it. + * + * @param puc pointer to the location where, in case of success, the + * function puts the pointer to the created URLContext + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int ffurl_open(URLContext **h, const char *url, int flags); + #endif //AVFORMAT_URL_H