From dcd4a7b62f16793c33fa459889e581286d6ccdd6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:36:18 +0100 Subject: lavf: remove FF_API_REGISTER_PROTOCOL cruft --- libavformat/avio.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'libavformat/avio.c') diff --git a/libavformat/avio.c b/libavformat/avio.c index cb923a726e..c1c2027d5d 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -84,29 +84,6 @@ int ffurl_register_protocol(URLProtocol *protocol, int size) return 0; } -#if FF_API_REGISTER_PROTOCOL -/* The layout of URLProtocol as of when major was bumped to 52 */ -struct URLProtocol_compat { - const char *name; - int (*url_open)(URLContext *h, const char *filename, int flags); - int (*url_read)(URLContext *h, unsigned char *buf, int size); - int (*url_write)(URLContext *h, unsigned char *buf, int size); - int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); - int (*url_close)(URLContext *h); - struct URLProtocol *next; -}; - -int av_register_protocol(URLProtocol *protocol) -{ - return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat)); -} - -int register_protocol(URLProtocol *protocol) -{ - return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat)); -} -#endif - static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, const char *filename, int flags) { -- cgit v1.2.3 From 7f804085f1be53fac1a28a962c1e34873981b131 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:53:28 +0100 Subject: lavf: remove FF_API_URL_CLASS cruft. --- libavformat/avio.c | 4 ---- libavformat/avio.h | 2 -- libavformat/rtmpproto.c | 59 ++++++++++++++++++++++--------------------------- libavformat/version.h | 3 --- 4 files changed, 26 insertions(+), 42 deletions(-) (limited to 'libavformat/avio.c') diff --git a/libavformat/avio.c b/libavformat/avio.c index c1c2027d5d..4f8acb01ff 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -31,7 +31,6 @@ #endif #include "url.h" -#if FF_API_URL_CLASS /** @name Logging context. */ /*@{*/ static const char *urlcontext_to_name(void *ptr) @@ -44,7 +43,6 @@ static const AVOption options[] = {{NULL}}; static const AVClass urlcontext_class = { "URLContext", urlcontext_to_name, options, LIBAVUTIL_VERSION_INT }; /*@}*/ -#endif static int default_interrupt_cb(void); @@ -99,9 +97,7 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, err = AVERROR(ENOMEM); goto fail; } -#if FF_API_URL_CLASS uc->av_class = &urlcontext_class; -#endif uc->filename = (char *) &uc[1]; strcpy(uc->filename, filename); uc->prot = up; diff --git a/libavformat/avio.h b/libavformat/avio.h index 2502711be5..62ea42ca96 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -101,9 +101,7 @@ typedef struct { * @deprecated This struct will be made private */ typedef struct URLContext { -#if FF_API_URL_CLASS const AVClass *av_class; ///< information for av_log(). Set by url_open(). -#endif struct URLProtocol *prot; int flags; int is_streamed; /**< true if streamed (no seek possible), default = false */ diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 9fc5196b2c..3413b62c8b 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -38,13 +38,6 @@ #include "rtmppkt.h" #include "url.h" -/* we can't use av_log() with URLContext yet... */ -#if FF_API_URL_CLASS -#define LOG_CONTEXT s -#else -#define LOG_CONTEXT NULL -#endif - //#define DEBUG /** RTMP protocol handler state */ @@ -166,7 +159,7 @@ static void gen_release_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 29 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Releasing stream...\n"); + av_log(s, AV_LOG_DEBUG, "Releasing stream...\n"); p = pkt.data; ff_amf_write_string(&p, "releaseStream"); ff_amf_write_number(&p, 2.0); @@ -189,7 +182,7 @@ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 25 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "FCPublish stream...\n"); + av_log(s, AV_LOG_DEBUG, "FCPublish stream...\n"); p = pkt.data; ff_amf_write_string(&p, "FCPublish"); ff_amf_write_number(&p, 3.0); @@ -212,7 +205,7 @@ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 27 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "UnPublishing stream...\n"); + av_log(s, AV_LOG_DEBUG, "UnPublishing stream...\n"); p = pkt.data; ff_amf_write_string(&p, "FCUnpublish"); ff_amf_write_number(&p, 5.0); @@ -232,7 +225,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Creating stream...\n"); + av_log(s, AV_LOG_DEBUG, "Creating stream...\n"); ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 25); p = pkt.data; @@ -254,7 +247,7 @@ static void gen_delete_stream(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Deleting stream...\n"); + av_log(s, AV_LOG_DEBUG, "Deleting stream...\n"); ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 34); p = pkt.data; @@ -276,7 +269,7 @@ static void gen_play(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending play command for '%s'\n", rt->playpath); + av_log(s, AV_LOG_DEBUG, "Sending play command for '%s'\n", rt->playpath); ff_rtmp_packet_create(&pkt, RTMP_VIDEO_CHANNEL, RTMP_PT_INVOKE, 0, 20 + strlen(rt->playpath)); pkt.extra = rt->main_channel_id; @@ -310,7 +303,7 @@ static void gen_publish(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending publish command for '%s'\n", rt->playpath); + av_log(s, AV_LOG_DEBUG, "Sending publish command for '%s'\n", rt->playpath); ff_rtmp_packet_create(&pkt, RTMP_SOURCE_CHANNEL, RTMP_PT_INVOKE, 0, 30 + strlen(rt->playpath)); pkt.extra = rt->main_channel_id; @@ -478,7 +471,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) int server_pos, client_pos; uint8_t digest[32]; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Handshaking...\n"); + av_log(s, AV_LOG_DEBUG, "Handshaking...\n"); av_lfg_init(&rnd, 0xDEADC0DE); // generate handshake packet - 1536 bytes of pseudorandom data @@ -489,16 +482,16 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1); i = ffurl_read_complete(rt->stream, serverdata, RTMP_HANDSHAKE_PACKET_SIZE + 1); if (i != RTMP_HANDSHAKE_PACKET_SIZE + 1) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); + av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); return -1; } i = ffurl_read_complete(rt->stream, clientdata, RTMP_HANDSHAKE_PACKET_SIZE); if (i != RTMP_HANDSHAKE_PACKET_SIZE) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); + av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n", + av_log(s, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n", serverdata[5], serverdata[6], serverdata[7], serverdata[8]); if (rt->is_input && serverdata[5] >= 3) { @@ -506,7 +499,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) if (!server_pos) { server_pos = rtmp_validate_digest(serverdata + 1, 8); if (!server_pos) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server response validating failed\n"); + av_log(s, AV_LOG_ERROR, "Server response validating failed\n"); return -1; } } @@ -518,7 +511,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) digest, 32, digest); if (memcmp(digest, clientdata + RTMP_HANDSHAKE_PACKET_SIZE - 32, 32)) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Signature mismatch\n"); + av_log(s, AV_LOG_ERROR, "Signature mismatch\n"); return -1; } @@ -552,13 +545,13 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) const uint8_t *data_end = pkt->data + pkt->data_size; #ifdef DEBUG - ff_rtmp_packet_dump(LOG_CONTEXT, pkt); + ff_rtmp_packet_dump(s, pkt); #endif switch (pkt->type) { case RTMP_PT_CHUNK_SIZE: if (pkt->data_size != 4) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Chunk size change packet is not 4 bytes long (%d)\n", pkt->data_size); return -1; } @@ -566,10 +559,10 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, rt->prev_pkt[1]); rt->chunk_size = AV_RB32(pkt->data); if (rt->chunk_size <= 0) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size); + av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size); + av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size); break; case RTMP_PT_PING: t = AV_RB16(pkt->data); @@ -578,12 +571,12 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) break; case RTMP_PT_CLIENT_BW: if (pkt->data_size < 4) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Client bandwidth report packet is less than 4 bytes long (%d)\n", pkt->data_size); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data)); + av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data)); rt->client_report_size = AV_RB32(pkt->data) >> 1; break; case RTMP_PT_INVOKE: @@ -593,7 +586,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (!ff_amf_get_field_value(pkt->data + 9, data_end, "description", tmpstr, sizeof(tmpstr))) - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server error: %s\n",tmpstr); + av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); return -1; } else if (!memcmp(pkt->data, "\002\000\007_result", 10)) { switch (rt->state) { @@ -624,7 +617,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) case STATE_CONNECTING: //extract a number from the result if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) { - av_log(LOG_CONTEXT, AV_LOG_WARNING, "Unexpected reply on connect()\n"); + av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n"); } else { rt->main_channel_id = (int) av_int2dbl(AV_RB64(pkt->data + 21)); } @@ -651,7 +644,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (!t && !strcmp(tmpstr, "error")) { if (!ff_amf_get_field_value(ptr, data_end, "description", tmpstr, sizeof(tmpstr))) - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server error: %s\n",tmpstr); + av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); return -1; } t = ff_amf_get_field_value(ptr, data_end, @@ -701,7 +694,7 @@ static int get_packet(URLContext *s, int for_header) } rt->bytes_read += ret; if (rt->bytes_read > rt->last_bytes_read + rt->client_report_size) { - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending bytes read report\n"); + av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n"); gen_bytes_read(s, rt, rpkt.timestamp + 1); rt->last_bytes_read = rt->bytes_read; } @@ -822,7 +815,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); if (ffurl_open(&rt->stream, buf, AVIO_RDWR) < 0) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot open connection %s\n", buf); + av_log(s, AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } @@ -866,7 +859,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) rt->bytes_read = 0; rt->last_bytes_read = 0; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", + av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", proto, path, rt->app, rt->playpath); gen_connect(s, rt, proto, hostname, port); @@ -933,7 +926,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) const uint8_t *buf_temp = buf; if (size < 11) { - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "FLV packet too small %d\n", size); + av_log(s, AV_LOG_DEBUG, "FLV packet too small %d\n", size); return 0; } diff --git a/libavformat/version.h b/libavformat/version.h index 735891a1eb..6396164212 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -44,9 +44,6 @@ #ifndef FF_API_OLD_METADATA2 #define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_URL_CLASS -#define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) -#endif #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -- cgit v1.2.3 From 59d96941f0285a501989d5f2c9b69be0a1393ed5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 15 Apr 2011 16:42:09 +0200 Subject: 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 breaks API. --- ffmpeg.c | 2 +- ffserver.c | 4 ++-- libavformat/applehttp.c | 4 ++-- libavformat/applehttpproto.c | 6 +++--- libavformat/avio.c | 10 +++++----- libavformat/avio.h | 8 ++++---- libavformat/aviobuf.c | 12 ++++++------ libavformat/file.c | 11 +++++------ libavformat/gopher.c | 2 +- libavformat/http.c | 6 +++--- libavformat/img2.c | 4 ++-- 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 | 6 +++--- libavformat/rtpproto.c | 2 +- libavformat/rtsp.c | 16 ++++++++-------- libavformat/sapdec.c | 2 +- libavformat/sapenc.c | 4 ++-- libavformat/udp.c | 12 ++++++------ libavformat/utils.c | 2 +- 25 files changed, 65 insertions(+), 66 deletions(-) (limited to 'libavformat/avio.c') diff --git a/ffmpeg.c b/ffmpeg.c index f5244d98fd..5b6e3eae67 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3750,7 +3750,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 ec8b773c26..5defd40847 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3422,7 +3422,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); @@ -3762,7 +3762,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 35759be3cb..df4494a785 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 8842bd4dcf..8a9bcb1ade 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 4f8acb01ff..074d3eeb86 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -129,7 +129,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; @@ -289,21 +289,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) @@ -342,7 +342,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 c63b545d33..a4ab5ae28c 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -347,7 +347,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. @@ -527,9 +527,9 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); * constants, optionally ORed with other flags. * @{ */ -#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 */ /** * @} */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 2bacedbaa7..2b14d48ff5 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -53,7 +53,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; @@ -843,7 +843,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); @@ -872,15 +872,15 @@ 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; } static int url_resetbuf(AVIOContext *s, int flags) { - assert(flags == AVIO_WRONLY || flags == AVIO_RDONLY); + assert(flags == AVIO_FLAG_WRITE || flags == AVIO_FLAG_READ); - if (flags & AVIO_WRONLY) { + if (flags & AVIO_FLAG_WRITE) { s->buf_end = s->buffer + s->buffer_size; s->write_flag = 1; } else { @@ -1038,7 +1038,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 1dcb2c8ac5..6a3ed5acb0 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_WRITE && flags & AVIO_FLAG_READ) { access = O_CREAT | O_TRUNC | O_RDWR; - } else if (flags & AVIO_WRONLY) { + } else if (flags & AVIO_FLAG_WRITE) { access = O_CREAT | O_TRUNC | O_WRONLY; } else { access = O_RDONLY; @@ -102,9 +102,8 @@ static int file_check(URLContext *h, int mask) if (ret < 0) return AVERROR(errno); - ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0; - ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0; - ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0; + ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0; + ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0; return ret; } @@ -132,7 +131,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags) fd = strtol(filename, &final, 10); if((filename == final) || *final ) {/* No digits found, or something like 10ab */ - if (flags & AVIO_WRONLY) { + if (flags & AVIO_FLAG_WRITE) { fd = 1; } else { fd = 0; diff --git a/libavformat/gopher.c b/libavformat/gopher.c index cfc07e79cf..1d38cd232f 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -100,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 = ffurl_open(&s->hd, buf, AVIO_RDWR); + err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE); if (err < 0) goto fail; diff --git a/libavformat/http.c b/libavformat/http.c index bcfce80bff..190f844ea1 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -124,7 +124,7 @@ static int http_open_cnx(URLContext *h) port = 80; ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); - err = ffurl_open(&hd, buf, AVIO_RDWR); + err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE); if (err < 0) goto fail; @@ -296,7 +296,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, /* send http header */ - post = h->flags & AVIO_WRONLY; + post = h->flags & AVIO_FLAG_WRITE; authstr = ff_http_auth_create_response(&s->auth_state, auth, path, post ? "POST" : "GET"); @@ -451,7 +451,7 @@ static int http_close(URLContext *h) HTTPContext *s = h->priv_data; /* signal end of chunked encoding if used */ - if ((h->flags & AVIO_WRONLY) && s->chunksize != -1) { + if ((h->flags & AVIO_FLAG_WRITE) && s->chunksize != -1) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; } diff --git a/libavformat/img2.c b/libavformat/img2.c index 2b5d63b0bd..84d841f0ed 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -278,7 +278,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, AVIO_RDONLY) < 0) { + if (avio_open(&f[i], filename, AVIO_FLAG_READ) < 0) { if(i==1) break; av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); @@ -362,7 +362,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } for(i=0; i<3; i++){ - if (avio_open(&pb[i], filename, AVIO_WRONLY) < 0) { + if (avio_open(&pb[i], filename, AVIO_FLAG_WRITE) < 0) { av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename); return AVERROR(EIO); } diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index db5cc9858b..30fe8a196b 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -94,7 +94,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) goto fail; } - if (flags & AVIO_WRONLY) + if (flags & AVIO_FLAG_WRITE) RTMP_EnableWrite(r); if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) { diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 19c7ca6384..0fa94a16d5 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1331,7 +1331,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) && track->codec_priv.data != NULL) { int ret; ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, - AVIO_RDONLY, NULL, NULL, NULL, NULL); + AVIO_FLAG_READ, NULL, NULL, NULL, NULL); ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size); if (ret < 0) return ret; diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c index 8b811ec3d6..4630c49f5c 100644 --- a/libavformat/md5proto.c +++ b/libavformat/md5proto.c @@ -36,7 +36,7 @@ static int md5_open(URLContext *h, const char *filename, int flags) return -1; } - if (flags != AVIO_WRONLY) + if (!flags & AVIO_FLAG_WRITE) return AVERROR(EINVAL); av_md5_init(h->priv_data); @@ -65,7 +65,7 @@ static int md5_close(URLContext *h) av_strstart(filename, "md5:", &filename); if (*filename) { - err = ffurl_open(&out, filename, AVIO_WRONLY); + err = ffurl_open(&out, filename, AVIO_FLAG_WRITE); if (err) return err; err = ffurl_write(out, buf, i*2+1); diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index 1b9b494f57..203691e2fc 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, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 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, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 0) { return AVERROR(EIO); } stream_selection = av_mallocz(mms->stream_num * 19 + 1); diff --git a/libavformat/mmst.c b/libavformat/mmst.c index a3f260939d..e1904de1e2 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -523,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 = ffurl_open(&mms->mms_hd, tcpname, AVIO_RDWR); + err = ffurl_open(&mms->mms_hd, tcpname, AVIO_FLAG_READ_WRITE); if (err) goto fail; diff --git a/libavformat/mov.c b/libavformat/mov.c index bd8cf031e0..76dc8a13af 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1721,7 +1721,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, AVIO_RDONLY)) + if (!avio_open(pb, filename, AVIO_FLAG_READ)) return 0; } } diff --git a/libavformat/output-example.c b/libavformat/output-example.c index 27db78c658..ddd16f1eed 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -492,7 +492,7 @@ int main(int argc, char **argv) /* open the output file, if needed */ if (!(fmt->flags & AVFMT_NOFILE)) { - if (avio_open(&oc->pb, filename, AVIO_WRONLY) < 0) { + if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Could not open '%s'\n", filename); exit(1); } diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 3413b62c8b..70e4b142d6 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -805,7 +805,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) if (!rt) return AVERROR(ENOMEM); s->priv_data = rt; - rt->is_input = !(flags & AVIO_WRONLY); + rt->is_input = !(flags & AVIO_FLAG_WRITE); av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); @@ -814,8 +814,8 @@ 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 (ffurl_open(&rt->stream, buf, AVIO_RDWR) < 0) { - av_log(s, AV_LOG_ERROR, "Cannot open connection %s\n", buf); + if (ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE) < 0) { + av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index b92b2e7ace..e1659ee02d 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -145,7 +145,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) char path[1024]; const char *p; - is_output = (flags & AVIO_WRONLY); + is_output = (flags & AVIO_FLAG_WRITE); s = av_mallocz(sizeof(RTPContext)); if (!s) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 62c9d3543e..58f7ddc1a6 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, AVIO_RDWR) == 0) + if (ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_FLAG_READ_WRITE) == 0) goto rtp_opened; } } #if 0 /* then try on any port */ - if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_RDONLY) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_FLAG_READ) < 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, AVIO_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 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, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&rt->rtsp_hd, httpname, AVIO_FLAG_READ) < 0) { err = AVERROR(EIO); goto fail; } @@ -1417,7 +1417,7 @@ redirect: } /* POST requests */ - if (ffurl_alloc(&rt->rtsp_hd_out, httpname, AVIO_WRONLY) < 0 ) { + if (ffurl_alloc(&rt->rtsp_hd_out, httpname, AVIO_FLAG_WRITE) < 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, AVIO_RDWR) < 0) { + if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE) < 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, AVIO_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 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, AVIO_RDONLY); + ret = ffurl_open(&in, s->filename, AVIO_FLAG_READ); if (ret) goto fail; diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 1eb40b7ee5..88150fc772 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, AVIO_RDONLY); + ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ); if (ret) goto fail; diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 455e65341f..3abd79e4e8 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -146,7 +146,7 @@ static int sap_write_header(AVFormatContext *s) "?ttl=%d", ttl); if (!same_port) base_port += 2; - ret = ffurl_open(&fd, url, AVIO_WRONLY); + ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE); if (ret) { ret = AVERROR(EIO); goto fail; @@ -158,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 = ffurl_open(&sap->ann_fd, url, AVIO_WRONLY); + ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE); if (ret) { ret = AVERROR(EIO); goto fail; diff --git a/libavformat/udp.c b/libavformat/udp.c index e16dc4c7e0..76e3f1a4a2 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -315,7 +315,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) h->is_streamed = 1; h->max_packet_size = 1472; - is_output = (flags & AVIO_WRONLY); + is_output = (flags & AVIO_FLAG_WRITE); s = av_mallocz(sizeof(UDPContext)); if (!s) @@ -358,14 +358,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* XXX: fix av_url_split */ if (hostname[0] == '\0' || hostname[0] == '?') { /* only accepts null hostname if input */ - if (flags & AVIO_WRONLY) + if (flags & AVIO_FLAG_WRITE) goto fail; } else { if (ff_udp_set_remote_url(h, uri) < 0) goto fail; } - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) s->local_port = port; udp_fd = udp_socket_create(s, &my_addr, &len); if (udp_fd < 0) @@ -382,7 +382,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* the bind is needed to give a port to the socket now */ /* if multicast, try the multicast address bind first */ - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) { + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) { bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len); } /* bind to the local address if not multicast or if the multicast @@ -395,7 +395,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->local_port = udp_port(&my_addr, len); if (s->is_multicast) { - if (h->flags & AVIO_WRONLY) { + if (h->flags & AVIO_FLAG_WRITE) { /* output */ if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) goto fail; @@ -478,7 +478,7 @@ static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); closesocket(s->udp_fd); av_free(s); diff --git a/libavformat/utils.c b/libavformat/utils.c index 1e70b4f592..0c80ff618e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -561,7 +561,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, AVIO_RDONLY)) < 0) { + if ((err=avio_open(&pb, filename, AVIO_FLAG_READ)) < 0) { goto fail; } if (buf_size > 0) { -- cgit v1.2.3