On Sat, 16 Apr 2011 12:02:27 +0200, Stefano Sabatini <[email protected]> wrote: > Hi all, > > the attached patch is intended to be applied just after the major > bump, togheter with the url_exist() -> avio_check() replacement patch > by Anton. > > Note that in the attached patch I'm bumping lavf major only for > simplifying patch testing. > > Passes regression here, I just had to do make testclean after applying > the patches since some tool program was generating empty files because > of some flag mismatch due to the change (which I wasn't able to > track). > > Please comment. > From 4661591752b17cdc33bbb6f2a045fa8e25bd8e89 Mon Sep 17 00:00:00 2001 > From: Stefano Sabatini <[email protected]> > Date: Fri, 15 Apr 2011 16:42:09 +0200 > Subject: [PATCH] avio: remove AVIO_* access symbols in favor of new > AVIO_FLAG_* symbols > > Make AVIO_FLAG_ access constants work as flags, and in particular fix > the behavior of functions (such as avio_check()) which expect them to > be flags rather than modes. > > *THIS SHOULD BE APPLIED ONLY AFTER THE LIBAVFORMAT MAJOR BUMP*. > --- > ffmpeg.c | 2 +- > ffserver.c | 8 ++++---- > libavformat/applehttp.c | 4 ++-- > libavformat/applehttpproto.c | 6 +++--- > libavformat/avio.c | 10 +++++----- > libavformat/avio.h | 8 ++++---- > libavformat/aviobuf.c | 14 +++++++------- > libavformat/file.c | 11 +++++------ > libavformat/gopher.c | 2 +- > libavformat/http.c | 6 +++--- > libavformat/img2.c | 10 +++++----- > libavformat/librtmp.c | 2 +- > libavformat/matroskadec.c | 2 +- > libavformat/md5proto.c | 4 ++-- > libavformat/mmsh.c | 4 ++-- > libavformat/mmst.c | 2 +- > libavformat/mov.c | 2 +- > libavformat/output-example.c | 2 +- > libavformat/rtmpproto.c | 4 ++-- > libavformat/rtpproto.c | 2 +- > libavformat/rtsp.c | 16 ++++++++-------- > libavformat/sapdec.c | 2 +- > libavformat/sapenc.c | 4 ++-- > libavformat/udp.c | 12 ++++++------ > libavformat/utils.c | 2 +- > libavformat/version.h | 4 ++-- > 26 files changed, 72 insertions(+), 73 deletions(-) > > diff --git a/ffmpeg.c b/ffmpeg.c > index f7a2a3d..add4ddc 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -3894,7 +3894,7 @@ static void opt_output_file(const char *filename) > } > > /* open the file */ > - if ((err = avio_open(&oc->pb, filename, AVIO_WRONLY)) < 0) { > + if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { > print_error(filename, err); > ffmpeg_exit(1); > } > diff --git a/ffserver.c b/ffserver.c > index af9ec63..c92ea82 100644 > --- a/ffserver.c > +++ b/ffserver.c > @@ -3428,7 +3428,7 @@ static int rtp_new_av_stream(HTTPContext *c, > "rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port)); > } > > - if (url_open(&h, ctx->filename, AVIO_WRONLY) < 0) > + if (url_open(&h, ctx->filename, AVIO_FLAG_WRITE) < 0) > goto fail; > c->rtp_handles[stream_index] = h; > max_packet_size = url_get_max_packet_size(h); > @@ -3685,7 +3685,7 @@ static void build_feed_streams(void) > for(feed = first_feed; feed != NULL; feed = feed->next_feed) { > int fd; > > - if (avio_check(feed->feed_filename, AVIO_RDONLY|AVIO_RDWR) > 0) { > + if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) { > /* See if it matches */ > AVFormatContext *s; > int matches = 0; > @@ -3758,7 +3758,7 @@ static void build_feed_streams(void) > unlink(feed->feed_filename); > } > } > - if (avio_check(feed->feed_filename, AVIO_WRONLY|AVIO_RDWR) <= 0) { > + if (avio_check(feed->feed_filename, AVIO_FLAG_READ_WRITE) <= 0) { > AVFormatContext s1 = {0}, *s = &s1; > > if (feed->readonly) { > @@ -3768,7 +3768,7 @@ static void build_feed_streams(void) > } > > /* only write the header of the ffm file */ > - if (avio_open(&s->pb, feed->feed_filename, AVIO_WRONLY) < 0) { > + if (avio_open(&s->pb, feed->feed_filename, AVIO_FLAG_WRITE) < 0) > { > http_log("Could not open output feed file '%s'\n", > feed->feed_filename); > exit(1); > diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c > index 7e6d2d7..2b22cd4 100644 > --- a/libavformat/applehttp.c > +++ b/libavformat/applehttp.c > @@ -170,7 +170,7 @@ static int parse_playlist(AppleHTTPContext *c, const char > *url, > > if (!in) { > close_in = 1; > - if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0) > + if ((ret = avio_open(&in, url, AVIO_FLAG_READ)) < 0) > return ret; > } > > @@ -293,7 +293,7 @@ reload: > > ret = ffurl_open(&v->input, > v->segments[v->cur_seq_no - v->start_seq_no]->url, > - AVIO_RDONLY); > + AVIO_FLAG_READ); > if (ret < 0) > return ret; > } > diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c > index 4871ccc..f908584 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, AVIO_RDONLY)) < 0) > + if ((ret = avio_open(&in, url, AVIO_FLAG_READ)) < 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 & (AVIO_WRONLY | AVIO_RDWR)) > + if (flags & AVIO_FLAG_WRITE) > return AVERROR(ENOSYS); > > 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, AVIO_RDONLY); > + ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ); > if (ret < 0) { > if (url_interrupt_cb()) > return AVERROR_EXIT; > diff --git a/libavformat/avio.c b/libavformat/avio.c > index 725a95f..66ce333 100644 > --- a/libavformat/avio.c > +++ b/libavformat/avio.c > @@ -154,7 +154,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 & (AVIO_WRONLY | AVIO_RDWR)) > + if( (uc->flags & AVIO_FLAG_WRITE) > || !strcmp(uc->prot->name, "file")) > if(!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0) > uc->is_streamed= 1; > @@ -314,21 +314,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 & AVIO_WRONLY) > + if (h->flags & AVIO_FLAG_WRITE) > 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 & AVIO_WRONLY) > + if (h->flags & AVIO_FLAG_WRITE) > 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 & (AVIO_WRONLY | AVIO_RDWR))) > + if (!(h->flags & AVIO_FLAG_WRITE)) > return AVERROR(EIO); > /* avoid sending too big packets */ > if (h->max_packet_size && size > h->max_packet_size) > @@ -367,7 +367,7 @@ int ffurl_close(URLContext *h) > int url_exist(const char *filename) > { > URLContext *h; > - if (ffurl_open(&h, filename, AVIO_RDONLY) < 0) > + if (ffurl_open(&h, filename, AVIO_FLAG_READ) < 0) > return 0; > ffurl_close(h); > return 1; > diff --git a/libavformat/avio.h b/libavformat/avio.h > index 9d80582..f6852ed 100644 > --- a/libavformat/avio.h > +++ b/libavformat/avio.h > @@ -346,7 +346,7 @@ attribute_deprecated int url_exist(const char *url); > #endif // FF_API_OLD_AVIO > > /** > - * Return AVIO_* access flags corresponding to the access permissions > + * Return AVIO_FLAG_* access flags corresponding to the access permissions > * of the resource in url, or a negative value corresponding to an > * AVERROR code in case of failure. The returned access flags are > * masked by the value in flags. > @@ -561,9 +561,9 @@ int url_resetbuf(AVIOContext *s, int flags); > #define AVIO_WRONLY 1 /**< write-only */ > #define AVIO_RDWR 2 /**< read-write */ > #else > -#define AVIO_RDONLY 1 /**< read-only */ > -#define AVIO_WRONLY 2 /**< write-only */ > -#define AVIO_RDWR 4 /**< read-write */ > +#define AVIO_FLAG_READ 1 /**< > read-only */ > +#define AVIO_FLAG_WRITE 2 /**< > write-only */ > +#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< > read-write pseudo flag */ > #endif > /** > * @} > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > index 70084e9..7636837 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 ? AVIO_WRONLY : AVIO_RDONLY); > + url_resetbuf(s, write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); > s->write_packet = write_packet; > s->read_packet = read_packet; > s->seek = seek; > @@ -854,7 +854,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) > } > > if (ffio_init_context(*s, buffer, buffer_size, > - (h->flags & AVIO_WRONLY || h->flags & AVIO_RDWR), h, > + h->flags & AVIO_FLAG_WRITE, h, > ffurl_read, ffurl_write, ffurl_seek) < 0) { > av_free(buffer); > av_freep(s); > @@ -883,7 +883,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 ? AVIO_WRONLY : AVIO_RDONLY); > + url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); > return 0; > } > > @@ -894,13 +894,13 @@ static int url_resetbuf(AVIOContext *s, int flags) > #endif > { > #if FF_API_URL_RESETBUF > - if (flags & AVIO_RDWR) > + if (flags & AVIO_FLAG_READ_WRITE) > return AVERROR(EINVAL); > #else > - assert(flags == AVIO_WRONLY || flags == AVIO_RDONLY); > + assert(flags == AVIO_FLAG_WRITE || flags == AVIO_FLAG_READ); > #endif > > - if (flags & AVIO_WRONLY) { > + if (flags & AVIO_FLAG_WRITE) { > s->buf_end = s->buffer + s->buffer_size; > s->write_flag = 1; > } else { > @@ -1058,7 +1058,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 & AVIO_WRONLY || flags & AVIO_RDWR), > + flags & AVIO_FLAG_WRITE, > NULL, NULL, NULL, NULL); > if(ret != 0) > av_freep(s); > diff --git a/libavformat/file.c b/libavformat/file.c > index 9d28a89..39f784c 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -60,9 +60,9 @@ static int file_open(URLContext *h, const char *filename, > int flags) > > av_strstart(filename, "file:", &filename); > > - if (flags & AVIO_RDWR) { > + if (flags & AVIO_FLAG_READ && flags & AVIO_FLAG_WRITE) {
flags & AVIO_FLAG_READ_WRITE ? Otherwise looks fine to me. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
