[FFmpeg-devel] [PATCH 09/10] avio: avio_ prefixes for url_fopen/fclose/fileno

Anton Khirnov anton
Sat Feb 19 12:42:53 CET 2011


---
 ffmpeg.c                     |    4 ++--
 ffserver.c                   |    4 ++--
 libavformat/applehttp.c      |   16 ++++++++--------
 libavformat/avformat.h       |    2 +-
 libavformat/avio.h           |    9 ++++++---
 libavformat/aviobuf.c        |   18 +++++++++++++++---
 libavformat/img2.c           |   12 ++++++------
 libavformat/mov.c            |    4 ++--
 libavformat/output-example.c |    4 ++--
 libavformat/rtpenc_chain.c   |    2 +-
 libavformat/rtsp.c           |    2 +-
 libavformat/rtspdec.c        |    2 +-
 libavformat/sapenc.c         |    2 +-
 libavformat/utils.c          |    6 +++---
 14 files changed, 51 insertions(+), 36 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 3ec1a4e..0948650 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -508,7 +508,7 @@ static int ffmpeg_exit(int ret)
         AVFormatContext *s = output_files[i];
         int j;
         if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
-            url_fclose(s->pb);
+            avio_fclose(s->pb);
         avformat_free_context(s);
         av_free(output_streams_for_file[i]);
     }
@@ -3789,7 +3789,7 @@ static void opt_output_file(const char *filename)
         }
 
         /* open the file */
-        if ((err = url_fopen(&oc->pb, filename, URL_WRONLY)) < 0) {
+        if ((err = avio_fopen(&oc->pb, filename, URL_WRONLY)) < 0) {
             print_error(filename, err);
             ffmpeg_exit(1);
         }
diff --git a/ffserver.c b/ffserver.c
index afaf958..30b97ad 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3764,7 +3764,7 @@ static void build_feed_streams(void)
             }
 
             /* only write the header of the ffm file */
-            if (url_fopen(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {
+            if (avio_fopen(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {
                 http_log("Could not open output feed file '%s'\n",
                          feed->feed_filename);
                 exit(1);
@@ -3783,7 +3783,7 @@ static void build_feed_streams(void)
             }
             /* XXX: need better api */
             av_freep(&s->priv_data);
-            url_fclose(s->pb);
+            avio_fclose(s->pb);
         }
         /* get feed size and write index */
         fd = open(feed->feed_filename, O_RDONLY);
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 05aafe6..38a07f5 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -154,7 +154,7 @@ static void free_variant_list(AppleHTTPContext *c)
         free_segment_list(var);
         av_free_packet(&var->pkt);
         if (var->pb)
-            url_fclose(var->pb);
+            avio_fclose(var->pb);
         if (var->ctx) {
             var->ctx->pb = NULL;
             av_close_input_file(var->ctx);
@@ -211,7 +211,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
 
     if (!in) {
         close_in = 1;
-        if ((ret = url_fopen(&in, url, URL_RDONLY)) < 0)
+        if ((ret = avio_fopen(&in, url, URL_RDONLY)) < 0)
             return ret;
     }
 
@@ -284,7 +284,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
 
 fail:
     if (close_in)
-        url_fclose(in);
+        avio_fclose(in);
     return ret;
 }
 
@@ -338,7 +338,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
         ret = av_open_input_file(&v->ctx, v->segments[0]->url, NULL, 0, NULL);
         if (ret < 0)
             goto fail;
-        url_fclose(v->ctx->pb);
+        avio_fclose(v->ctx->pb);
         v->ctx->pb = NULL;
         v->stream_offset = stream_offset;
         /* Create new AVStreams for each stream in this variant */
@@ -378,7 +378,7 @@ static int open_variant(AppleHTTPContext *c, struct variant *var, int skip)
     }
     if (c->cur_seq_no - var->start_seq_no >= var->n_segments)
         return c->finished ? AVERROR_EOF : 0;
-    ret = url_fopen(&var->pb,
+    ret = avio_fopen(&var->pb,
                     var->segments[c->cur_seq_no - var->start_seq_no]->url,
                     URL_RDONLY);
     if (ret < 0)
@@ -435,7 +435,7 @@ start:
                    "Closing variant stream %d, no longer needed\n", i);
             av_free_packet(&var->pkt);
             reset_packet(&var->pkt);
-            url_fclose(var->pb);
+            avio_fclose(var->pb);
             var->pb = NULL;
             changed = 1;
         } else if (!var->pb && var->needed) {
@@ -484,7 +484,7 @@ start:
     for (i = 0; i < c->n_variants; i++) {
         struct variant *var = c->variants[i];
         if (var->pb) {
-            url_fclose(var->pb);
+            avio_fclose(var->pb);
             var->pb = NULL;
         }
     }
@@ -558,7 +558,7 @@ static int applehttp_read_seek(AVFormatContext *s, int stream_index,
     for (i = 0; i < c->n_variants; i++) {
         struct variant *var = c->variants[i];
         if (var->pb) {
-            url_fclose(var->pb);
+            avio_fclose(var->pb);
             var->pb = NULL;
         }
         av_free_packet(&var->pkt);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3fd7f75..22e516f 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -261,7 +261,7 @@ typedef struct AVFormatParameters {
 #endif
 } AVFormatParameters;
 
-//! Demuxer will use url_fopen, no opened file should be provided by the caller.
+//! Demuxer will use avio_fopen, no opened file should be provided by the caller.
 #define AVFMT_NOFILE        0x0001
 #define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
 #define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 50f27de..686a157 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -448,6 +448,9 @@ attribute_deprecated int64_t av_url_read_fseek(AVIOContext *h, int stream_index,
 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
+attribute_deprecated int         url_fopen(AVIOContext **s, const char *url, int flags);
+attribute_deprecated int         url_fclose(AVIOContext *s);
+attribute_deprecated URLContext *url_fileno(AVIOContext *s);
 /**
  * @}
  */
@@ -632,10 +635,10 @@ int ff_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size);
  * @return 0 in case of success, a negative value corresponding to an
  * AVERROR code in case of failure
  */
-int url_fopen(AVIOContext **s, const char *url, int flags);
+int avio_fopen(AVIOContext **s, const char *url, int flags);
 
-int url_fclose(AVIOContext *s);
-URLContext *url_fileno(AVIOContext *s);
+int avio_fclose(AVIOContext *s);
+URLContext *avio_fileno(AVIOContext *s);
 
 /**
  * Return the maximum packet size associated to packetized buffered file
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index adcd3c1..506b613 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -398,6 +398,18 @@ int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
 {
     return avio_close_dyn_buf(s, pbuffer);
 }
+int url_fopen(AVIOContext **s, const char *filename, int flags)
+{
+    return avio_fopen(s, filename, flags);
+}
+int url_fclose(AVIOContext *s)
+{
+    return avio_fclose(s);
+}
+URLContext *url_fileno(AVIOContext *s)
+{
+    return avio_fileno(s);
+}
 #endif
 
 int avio_put_str(AVIOContext *s, const char *str)
@@ -885,7 +897,7 @@ int ff_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size)
     return 0;
 }
 
-int url_fopen(AVIOContext **s, const char *filename, int flags)
+int avio_fopen(AVIOContext **s, const char *filename, int flags)
 {
     URLContext *h;
     int err;
@@ -901,7 +913,7 @@ int url_fopen(AVIOContext **s, const char *filename, int flags)
     return 0;
 }
 
-int url_fclose(AVIOContext *s)
+int avio_fclose(AVIOContext *s)
 {
     URLContext *h = s->opaque;
 
@@ -910,7 +922,7 @@ int url_fclose(AVIOContext *s)
     return url_close(h);
 }
 
-URLContext *url_fileno(AVIOContext *s)
+URLContext *avio_fileno(AVIOContext *s)
 {
     return s->opaque;
 }
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 00276b6..e1ad3d1 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -269,7 +269,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 (url_fopen(&f[i], filename, URL_RDONLY) < 0) {
+            if (avio_fopen(&f[i], filename, URL_RDONLY) < 0) {
                 if(i==1)
                     break;
                 av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
@@ -300,7 +300,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
         if(size[i]){
             ret[i]= avio_get_buffer(f[i], pkt->data + pkt->size, size[i]);
             if (!s->is_pipe)
-                url_fclose(f[i]);
+                avio_fclose(f[i]);
             if(ret[i]>0)
                 pkt->size += ret[i];
         }
@@ -353,7 +353,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
             return AVERROR(EIO);
         }
         for(i=0; i<3; i++){
-            if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) {
+            if (avio_fopen(&pb[i], filename, URL_WRONLY) < 0) {
                 av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
                 return AVERROR(EIO);
             }
@@ -373,8 +373,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_put_buffer(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
         put_flush_packet(pb[1]);
         put_flush_packet(pb[2]);
-        url_fclose(pb[1]);
-        url_fclose(pb[2]);
+        avio_fclose(pb[1]);
+        avio_fclose(pb[2]);
     }else{
         if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
             AVStream *st = s->streams[0];
@@ -403,7 +403,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
     }
     put_flush_packet(pb[0]);
     if (!img->is_pipe) {
-        url_fclose(pb[0]);
+        avio_fclose(pb[0]);
     }
 
     img->img_number++;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index f048920..8a5689a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1717,7 +1717,7 @@ static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref)
 
             av_strlcat(filename, ref->path + l + 1, 1024);
 
-            if (!url_fopen(pb, filename, URL_RDONLY))
+            if (!avio_fopen(pb, filename, URL_RDONLY))
                 return 0;
         }
     }
@@ -2545,7 +2545,7 @@ static int mov_read_close(AVFormatContext *s)
         }
         av_freep(&sc->drefs);
         if (sc->pb && sc->pb != s->pb)
-            url_fclose(sc->pb);
+            avio_fclose(sc->pb);
 
         av_freep(&st->codec->palctrl);
     }
diff --git a/libavformat/output-example.c b/libavformat/output-example.c
index edb5c87..d3251a0 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 (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
+        if (avio_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
             fprintf(stderr, "Could not open '%s'\n", filename);
             exit(1);
         }
@@ -545,7 +545,7 @@ int main(int argc, char **argv)
 
     if (!(fmt->flags & AVFMT_NOFILE)) {
         /* close the output file */
-        url_fclose(oc->pb);
+        avio_fclose(oc->pb);
     }
 
     /* free the stream */
diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c
index 6dd0dd5..7b3ceff 100644
--- a/libavformat/rtpenc_chain.c
+++ b/libavformat/rtpenc_chain.c
@@ -60,7 +60,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
 
     if (ret) {
         if (handle) {
-            url_fclose(rtpctx->pb);
+            avio_fclose(rtpctx->pb);
         } else {
             uint8_t *ptr;
             avio_close_dyn_buf(rtpctx->pb, &ptr);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 5e7a363..62ad1cb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -497,7 +497,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s)
                     avio_close_dyn_buf(rtpctx->pb, &ptr);
                     av_free(ptr);
                 } else {
-                    url_fclose(rtpctx->pb);
+                    avio_fclose(rtpctx->pb);
                 }
                 avformat_free_context(rtpctx);
             } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index e484347..29de843 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -382,7 +382,7 @@ static int rtsp_read_close(AVFormatContext *s)
 #if 0
     /* NOTE: it is valid to flush the buffer here */
     if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
-        url_fclose(&rt->rtsp_gb);
+        avio_fclose(&rt->rtsp_gb);
     }
 #endif
     ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c
index 91c1f62..66a5014 100644
--- a/libavformat/sapenc.c
+++ b/libavformat/sapenc.c
@@ -46,7 +46,7 @@ static int sap_write_close(AVFormatContext *s)
         if (!rtpctx)
             continue;
         av_write_trailer(rtpctx);
-        url_fclose(rtpctx->pb);
+        avio_fclose(rtpctx->pb);
         avformat_free_context(rtpctx);
         s->streams[i]->priv_data = NULL;
     }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 741c3df..72dbedb 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -616,7 +616,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=url_fopen(&pb, filename, URL_RDONLY)) < 0) {
+        if ((err=avio_fopen(&pb, filename, URL_RDONLY)) < 0) {
             goto fail;
         }
         if (buf_size > 0) {
@@ -647,7 +647,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  fail:
     av_freep(&pd->buf);
     if (pb)
-        url_fclose(pb);
+        avio_fclose(pb);
     if (ap && ap->prealloced_context)
         av_free(*ic_ptr);
     *ic_ptr = NULL;
@@ -2623,7 +2623,7 @@ void av_close_input_file(AVFormatContext *s)
     AVIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;
     av_close_input_stream(s);
     if (pb)
-        url_fclose(pb);
+        avio_fclose(pb);
 }
 
 AVStream *av_new_stream(AVFormatContext *s, int id)
-- 
1.7.2.3




More information about the ffmpeg-devel mailing list