avio: make url_open() internal.

oldabi
Anton Khirnov 14 years ago
parent 62eaaeacb5
commit 0589da0aa5
  1. 3
      libavformat/applehttpproto.c
  2. 10
      libavformat/avio.c
  3. 14
      libavformat/avio.h
  4. 3
      libavformat/aviobuf.c
  5. 3
      libavformat/concat.c
  6. 3
      libavformat/gopher.c
  7. 3
      libavformat/http.c
  8. 3
      libavformat/md5proto.c
  9. 3
      libavformat/mmst.c
  10. 3
      libavformat/rtmpproto.c
  11. 5
      libavformat/rtpproto.c
  12. 12
      libavformat/rtsp.c
  13. 3
      libavformat/sapdec.c
  14. 5
      libavformat/sapenc.c
  15. 13
      libavformat/url.h

@ -29,6 +29,7 @@
#include "libavutil/avstring.h"
#include "avformat.h"
#include "internal.h"
#include "url.h"
#include <unistd.h>
/*
@ -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;

@ -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;

@ -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.

@ -25,6 +25,7 @@
#include "avio.h"
#include "avio_internal.h"
#include "internal.h"
#include "url.h"
#include <stdarg.h>
#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);

@ -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 */

@ -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;

@ -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;

@ -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);

@ -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;

@ -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;
}

@ -29,6 +29,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "rtpdec.h"
#include "url.h"
#include <unistd.h>
#include <stdarg.h>
@ -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

@ -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;

@ -26,6 +26,7 @@
#include "os_support.h"
#include "internal.h"
#include "avio_internal.h"
#include "url.h"
#if HAVE_POLL_H
#include <poll.h>
#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;

@ -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;

@ -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

Loading…
Cancel
Save