#include "libavutil/avstring.h"
#include "avformat.h"
#include "internal.h"
+#include "url.h"
#include <unistd.h>
/*
}
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;
{
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 \
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)
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);
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;
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.
*
#include "avio.h"
#include "avio_internal.h"
#include "internal.h"
+#include "url.h"
#include <stdarg.h>
#define IO_BUFFER_SIZE 32768
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);
#include "avformat.h"
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
+#include "url.h"
#define AV_CAT_SEPARATOR "|"
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 */
#include "avformat.h"
#include "internal.h"
#include "network.h"
+#include "url.h"
typedef struct {
URLContext *hd;
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;
#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
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;
#include "libavutil/error.h"
#include "avformat.h"
#include "avio.h"
+#include "url.h"
#define PRIV_SIZE 128
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);
#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.
// 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;
#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
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;
}
#include "avformat.h"
#include "avio_internal.h"
#include "rtpdec.h"
+#include "url.h"
#include <unistd.h>
#include <stdarg.h>
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;
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
"?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;
}
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;
}
} 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;
}
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;
}
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;
#include "os_support.h"
#include "internal.h"
#include "avio_internal.h"
+#include "url.h"
#if HAVE_POLL_H
#include <poll.h>
#endif
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;
#include "network.h"
#include "os_support.h"
#include "rtpenc_chain.h"
+#include "url.h"
struct SAPState {
uint8_t *ann;
"?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;
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;
*/
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