---
libavformat/applehttp.c | 4 ++--
libavformat/applehttpproto.c | 6 +++---
libavformat/avio.c | 12 ++++++------
libavformat/avio.h | 29 ++++++++++++++++++++++++++++-
libavformat/aviobuf.c | 14 +++++++-------
libavformat/img2.c | 4 ++--
libavformat/matroskadec.c | 2 +-
libavformat/mmsh.c | 4 ++--
libavformat/mov.c | 2 +-
libavformat/rtsp.c | 16 ++++++++--------
libavformat/sapdec.c | 2 +-
libavformat/utils.c | 2 +-
12 files changed, 62 insertions(+), 35 deletions(-)
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 93f928a..9e11fca 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -169,7 +169,7 @@ static int parse_playlist(AppleHTTPContext *c, const char
*url,
if (!in) {
close_in = 1;
- if ((ret = avio_open(&in, url, URL_RDONLY)) < 0)
+ if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0)
return ret;
}
@@ -292,7 +292,7 @@ reload:
ret = url_open(&v->input,
v->segments[v->cur_seq_no - v->start_seq_no]->url,
- URL_RDONLY);
+ AVIO_RDONLY);
if (ret < 0)
return ret;
}
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index c7e12a9..757c5f7 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -115,7 +115,7 @@ static int parse_playlist(URLContext *h, const char *url)
char line[1024];
const char *ptr;
- if ((ret = avio_open(&in, url, URL_RDONLY)) < 0)
+ if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0)
return ret;
read_chomp_line(in, line, sizeof(line));
@@ -180,7 +180,7 @@ static int applehttp_open(URLContext *h, const char *uri,
int flags)
int ret, i;
const char *nested_url;
- if (flags & (URL_WRONLY | URL_RDWR))
+ if (flags & (AVIO_WRONLY | AVIO_RDWR))
return AVERROR_NOTSUPP;
s = av_mallocz(sizeof(AppleHTTPContext));
@@ -275,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 = ffurl_open(&s->seg_hd, url, URL_RDONLY);
+ ret = ffurl_open(&s->seg_hd, url, AVIO_RDONLY);
if (ret < 0) {
if (url_interrupt_cb())
return AVERROR_EXIT;
diff --git a/libavformat/avio.c b/libavformat/avio.c
index d986941..b3c44f4 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -151,7 +151,7 @@ int ffurl_connect(URLContext* uc)
return err;
uc->is_connected = 1;
//We must be careful here as ffurl_seek() could be slow, for example for
http
- if( (uc->flags & (URL_WRONLY | URL_RDWR))
+ if( (uc->flags & (AVIO_WRONLY | AVIO_RDWR))
|| !strcmp(uc->prot->name, "file"))
if(!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
uc->is_streamed= 1;
@@ -282,7 +282,7 @@ static inline int retry_transfer_wrapper(URLContext *h,
unsigned char *buf, int
ret = transfer_func(h, buf+len, size-len);
if (ret == AVERROR(EINTR))
continue;
- if (h->flags & URL_FLAG_NONBLOCK)
+ if (h->flags & AVIO_FLAG_NONBLOCK)
return ret;
if (ret == AVERROR(EAGAIN)) {
ret = 0;
@@ -303,21 +303,21 @@ static inline int retry_transfer_wrapper(URLContext *h,
unsigned char *buf, int
int ffurl_read(URLContext *h, unsigned char *buf, int size)
{
- if (h->flags & URL_WRONLY)
+ if (h->flags & AVIO_WRONLY)
return AVERROR(EIO);
return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
}
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
{
- if (h->flags & URL_WRONLY)
+ if (h->flags & AVIO_WRONLY)
return AVERROR(EIO);
return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
}
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
{
- if (!(h->flags & (URL_WRONLY | URL_RDWR)))
+ if (!(h->flags & (AVIO_WRONLY | AVIO_RDWR)))
return AVERROR(EIO);
/* avoid sending too big packets */
if (h->max_packet_size && size > h->max_packet_size)
@@ -355,7 +355,7 @@ int ffurl_close(URLContext *h)
int url_exist(const char *filename)
{
URLContext *h;
- if (ffurl_open(&h, filename, URL_RDONLY) < 0)
+ if (ffurl_open(&h, filename, AVIO_RDONLY) < 0)
return 0;
ffurl_close(h);
return 1;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 409e3b8..a3f0331 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -63,7 +63,6 @@ typedef struct URLPollEntry {
int events;
int revents;
} URLPollEntry;
-#endif
/**
* @defgroup open_modes URL open modes
@@ -91,6 +90,7 @@ typedef struct URLPollEntry {
* silently ignored.
*/
#define URL_FLAG_NONBLOCK 4
+#endif
typedef int URLInterruptCB(void);
@@ -512,6 +512,33 @@ int url_resetbuf(AVIOContext *s, int flags);
#endif
/**
+ * @defgroup open_modes URL open modes
+ * The flags argument to avio_open must be one of the following
+ * constants, optionally ORed with other flags.
+ * @{
+ */
+#define AVIO_RDONLY 0 /**< read-only */
+#define AVIO_WRONLY 1 /**< write-only */
+#define AVIO_RDWR 2 /**< read-write */
+/**
+ * @}
+ */
+
+/**
+ * Use non-blocking mode.
+ * If this flag is set, operations on the context will return
+ * AVERROR(EAGAIN) if they can not be performed immediately.
+ * If this flag is not set, operations on the context will never return
+ * AVERROR(EAGAIN).
+ * Note that this flag does not affect the opening/connecting of the
+ * context. Connecting a protocol will always block if necessary (e.g. on
+ * network protocols) but never hang (e.g. on busy devices).
+ * Warning: non-blocking protocols is work-in-progress; this flag may be
+ * silently ignored.
+ */
+#define AVIO_FLAG_NONBLOCK 4
+
+/**
* Create and initialize a AVIOContext for accessing the
* resource indicated by url.
* @note When the resource indicated by url has been opened in
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index dd25027..5b94b00 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -55,7 +55,7 @@ int ffio_init_context(AVIOContext *s,
s->buffer_size = buffer_size;
s->buf_ptr = buffer;
s->opaque = opaque;
- url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
+ url_resetbuf(s, write_flag ? AVIO_WRONLY : AVIO_RDONLY);
s->write_packet = write_packet;
s->read_packet = read_packet;
s->seek = seek;
@@ -845,7 +845,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
}
if (ffio_init_context(*s, buffer, buffer_size,
- (h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
+ (h->flags & AVIO_WRONLY || h->flags & AVIO_RDWR), h,
ffurl_read, ffurl_write, ffurl_seek) < 0) {
av_free(buffer);
av_freep(s);
@@ -874,7 +874,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
s->buffer = buffer;
s->buffer_size = buf_size;
s->buf_ptr = buffer;
- url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY);
+ url_resetbuf(s, s->write_flag ? AVIO_WRONLY : AVIO_RDONLY);
return 0;
}
@@ -885,13 +885,13 @@ static int url_resetbuf(AVIOContext *s, int flags)
#endif
{
#if FF_API_URL_RESETBUF
- if (flags & URL_RDWR)
+ if (flags & AVIO_RDWR)
return AVERROR(EINVAL);
#else
- assert(flags == URL_WRONLY || flags == URL_RDONLY);
+ assert(flags == AVIO_WRONLY || flags == AVIO_RDONLY);
#endif
- if (flags & URL_WRONLY) {
+ if (flags & AVIO_WRONLY) {
s->buf_end = s->buffer + s->buffer_size;
s->write_flag = 1;
} else {
@@ -1052,7 +1052,7 @@ int url_open_buf(AVIOContext **s, uint8_t *buf, int
buf_size, int flags)
if(!*s)
return AVERROR(ENOMEM);
ret = ffio_init_context(*s, buf, buf_size,
- (flags & URL_WRONLY || flags & URL_RDWR),
+ (flags & AVIO_WRONLY || flags & AVIO_RDWR),
NULL, NULL, NULL, NULL);
if(ret != 0)
av_freep(s);
diff --git a/libavformat/img2.c b/libavformat/img2.c
index bad5855..59d9150 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -270,7 +270,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
s->path, s->img_number)<0 && s->img_number >
1)
return AVERROR(EIO);
for(i=0; i<3; i++){
- if (avio_open(&f[i], filename, URL_RDONLY) < 0) {
+ if (avio_open(&f[i], filename, AVIO_RDONLY) < 0) {
if(i==1)
break;
av_log(s1, AV_LOG_ERROR, "Could not open file :
%s\n",filename);
@@ -354,7 +354,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
}
for(i=0; i<3; i++){
- if (avio_open(&pb[i], filename, URL_WRONLY) < 0) {
+ if (avio_open(&pb[i], filename, AVIO_WRONLY) < 0) {
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
}
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index fb8c3e9..d1567e7 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1330,7 +1330,7 @@ static int matroska_read_header(AVFormatContext *s,
AVFormatParameters *ap)
&& track->codec_priv.size >= 14
&& track->codec_priv.data != NULL) {
ffio_init_context(&b, track->codec_priv.data,
track->codec_priv.size,
- URL_RDONLY, NULL, NULL, NULL, NULL);
+ AVIO_RDONLY, NULL, NULL, NULL, NULL);
ff_get_wav_header(&b, st->codec, track->codec_priv.size);
codec_id = st->codec->codec_id;
extradata_offset = FFMIN(track->codec_priv.size, 18);
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index bf872b3..1b9b494 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -233,7 +233,7 @@ static int mmsh_open(URLContext *h, const char *uri, int
flags)
port = 80; // default mmsh protocol port
ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, path);
- if (ffurl_alloc(&mms->mms_hd, httpname, URL_RDONLY) < 0) {
+ if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_RDONLY) < 0) {
return AVERROR(EIO);
}
@@ -261,7 +261,7 @@ static int mmsh_open(URLContext *h, const char *uri, int
flags)
// close the socket and then reopen it for sending the second play request.
ffurl_close(mms->mms_hd);
memset(headers, 0, sizeof(headers));
- if (ffurl_alloc(&mms->mms_hd, httpname, URL_RDONLY) < 0) {
+ if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_RDONLY) < 0) {
return AVERROR(EIO);
}
stream_selection = av_mallocz(mms->stream_num * 19 + 1);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2194dc9..61ceaac 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1722,7 +1722,7 @@ static int mov_open_dref(AVIOContext **pb, char *src,
MOVDref *ref)
av_strlcat(filename, ref->path + l + 1, 1024);
- if (!avio_open(pb, filename, URL_RDONLY))
+ if (!avio_open(pb, filename, AVIO_RDONLY))
return 0;
}
}
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d314453..62c9d35 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 (ffurl_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0)
+ if (ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_RDWR) == 0)
goto rtp_opened;
}
}
#if 0
/* then try on any port */
- if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", URL_RDONLY) < 0) {
+ if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_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 (ffurl_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
+ if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
@@ -1396,7 +1396,7 @@ redirect:
av_get_random_seed(), av_get_random_seed());
/* GET requests */
- if (ffurl_alloc(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) {
+ if (ffurl_alloc(&rt->rtsp_hd, httpname, AVIO_RDONLY) < 0) {
err = AVERROR(EIO);
goto fail;
}
@@ -1417,7 +1417,7 @@ redirect:
}
/* POST requests */
- if (ffurl_alloc(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
+ if (ffurl_alloc(&rt->rtsp_hd_out, httpname, AVIO_WRONLY) < 0 ) {
err = AVERROR(EIO);
goto fail;
}
@@ -1460,7 +1460,7 @@ redirect:
} else {
/* open the tcp connection */
ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
- if (ffurl_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) {
+ if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_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 (ffurl_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
+ if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_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 = ffurl_open(&in, s->filename, URL_RDONLY);
+ ret = ffurl_open(&in, s->filename, AVIO_RDONLY);
if (ret)
goto fail;
diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c
index ed22e0b..1eb40b7 100644
--- a/libavformat/sapdec.c
+++ b/libavformat/sapdec.c
@@ -85,7 +85,7 @@ static int sap_read_header(AVFormatContext *s,
ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d",
port);
- ret = ffurl_open(&sap->ann_fd, url, URL_RDONLY);
+ ret = ffurl_open(&sap->ann_fd, url, AVIO_RDONLY);
if (ret)
goto fail;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 31eddec..6790155 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -620,7 +620,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char
*filename,
hack needed to handle RTSP/TCP */
if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
/* if no file needed do not try to open one */
- if ((err=avio_open(&pb, filename, URL_RDONLY)) < 0) {
+ if ((err=avio_open(&pb, filename, AVIO_RDONLY)) < 0) {
goto fail;
}
if (buf_size > 0) {
--
1.7.4.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel