Browse code

avio: make url_close() internal.

Anton Khirnov authored on 2011/04/01 00:36:06
Showing 16 changed files
... ...
@@ -246,7 +246,7 @@ start:
246 246
             return ret;
247 247
     }
248 248
     if (s->seg_hd) {
249
-        url_close(s->seg_hd);
249
+        ffurl_close(s->seg_hd);
250 250
         s->seg_hd = NULL;
251 251
         s->cur_seq_no++;
252 252
     }
... ...
@@ -292,7 +292,7 @@ static int applehttp_close(URLContext *h)
292 292
 
293 293
     free_segment_list(s);
294 294
     free_variant_list(s);
295
-    url_close(s->seg_hd);
295
+    ffurl_close(s->seg_hd);
296 296
     av_free(s);
297 297
     return 0;
298 298
 }
... ...
@@ -164,7 +164,7 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up,
164 164
     if (!ret)
165 165
         return 0;
166 166
  fail:
167
-    url_close(*puc);
167
+    ffurl_close(*puc);
168 168
     *puc = NULL;
169 169
     return ret;
170 170
 }
... ...
@@ -196,6 +196,10 @@ int64_t url_seek(URLContext *h, int64_t pos, int whence)
196 196
 {
197 197
     return ffurl_seek(h, pos, whence);
198 198
 }
199
+int url_close(URLContext *h)
200
+{
201
+    return ffurl_close(h);
202
+}
199 203
 #endif
200 204
 
201 205
 #define URL_SCHEME_CHARS                        \
... ...
@@ -239,7 +243,7 @@ int ffurl_open(URLContext **puc, const char *filename, int flags)
239 239
     ret = ffurl_connect(*puc);
240 240
     if (!ret)
241 241
         return 0;
242
-    url_close(*puc);
242
+    ffurl_close(*puc);
243 243
     *puc = NULL;
244 244
     return ret;
245 245
 }
... ...
@@ -309,7 +313,7 @@ int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
309 309
     return ret;
310 310
 }
311 311
 
312
-int url_close(URLContext *h)
312
+int ffurl_close(URLContext *h)
313 313
 {
314 314
     int ret = 0;
315 315
     if (!h) return 0; /* can happen when ffurl_open fails */
... ...
@@ -330,7 +334,7 @@ int url_exist(const char *filename)
330 330
     URLContext *h;
331 331
     if (ffurl_open(&h, filename, URL_RDONLY) < 0)
332 332
         return 0;
333
-    url_close(h);
333
+    ffurl_close(h);
334 334
     return 1;
335 335
 }
336 336
 
... ...
@@ -109,18 +109,10 @@ attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
109 109
 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
110 110
 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
111 111
 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
112
+attribute_deprecated int url_close(URLContext *h);
112 113
 #endif
113 114
 
114 115
 /**
115
- * Close the resource accessed by the URLContext h, and free the
116
- * memory used by it.
117
- *
118
- * @return a negative value if an error condition occurred, 0
119
- * otherwise
120
- */
121
-int url_close(URLContext *h);
122
-
123
-/**
124 116
  * Return a non-zero value if the resource indicated by url
125 117
  * exists, 0 otherwise.
126 118
  */
... ...
@@ -950,7 +950,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags)
950 950
         return err;
951 951
     err = ffio_fdopen(s, h);
952 952
     if (err < 0) {
953
-        url_close(h);
953
+        ffurl_close(h);
954 954
         return err;
955 955
     }
956 956
     return 0;
... ...
@@ -962,7 +962,7 @@ int avio_close(AVIOContext *s)
962 962
 
963 963
     av_free(s->buffer);
964 964
     av_free(s);
965
-    return url_close(h);
965
+    return ffurl_close(h);
966 966
 }
967 967
 
968 968
 #if FF_API_OLD_AVIO
... ...
@@ -47,7 +47,7 @@ static av_cold int concat_close(URLContext *h)
47 47
     struct concat_nodes *nodes = data->nodes;
48 48
 
49 49
     for (i = 0; i != data->length; i++)
50
-        err |= url_close(nodes[i].uc);
50
+        err |= ffurl_close(nodes[i].uc);
51 51
 
52 52
     av_freep(&data->nodes);
53 53
     av_freep(&h->priv_data);
... ...
@@ -106,7 +106,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
106 106
 
107 107
         /* creating size */
108 108
         if ((size = url_filesize(uc)) < 0) {
109
-            url_close(uc);
109
+            ffurl_close(uc);
110 110
             err = AVERROR(ENOSYS);
111 111
             break;
112 112
         }
... ...
@@ -69,7 +69,7 @@ static int gopher_close(URLContext *h)
69 69
 {
70 70
     GopherContext *s = h->priv_data;
71 71
     if (s->hd) {
72
-        url_close(s->hd);
72
+        ffurl_close(s->hd);
73 73
         s->hd = NULL;
74 74
     }
75 75
     av_freep(&h->priv_data);
... ...
@@ -134,7 +134,7 @@ static int http_open_cnx(URLContext *h)
134 134
         goto fail;
135 135
     if (s->http_code == 401) {
136 136
         if (cur_auth_type == HTTP_AUTH_NONE && s->auth_state.auth_type != HTTP_AUTH_NONE) {
137
-            url_close(hd);
137
+            ffurl_close(hd);
138 138
             goto redo;
139 139
         } else
140 140
             goto fail;
... ...
@@ -142,7 +142,7 @@ static int http_open_cnx(URLContext *h)
142 142
     if ((s->http_code == 301 || s->http_code == 302 || s->http_code == 303 || s->http_code == 307)
143 143
         && location_changed == 1) {
144 144
         /* url moved, get next */
145
-        url_close(hd);
145
+        ffurl_close(hd);
146 146
         if (redirects++ >= MAX_REDIRECTS)
147 147
             return AVERROR(EIO);
148 148
         location_changed = 0;
... ...
@@ -151,7 +151,7 @@ static int http_open_cnx(URLContext *h)
151 151
     return 0;
152 152
  fail:
153 153
     if (hd)
154
-        url_close(hd);
154
+        ffurl_close(hd);
155 155
     s->hd = NULL;
156 156
     return AVERROR(EIO);
157 157
 }
... ...
@@ -457,7 +457,7 @@ static int http_close(URLContext *h)
457 457
     }
458 458
 
459 459
     if (s->hd)
460
-        url_close(s->hd);
460
+        ffurl_close(s->hd);
461 461
     return ret;
462 462
 }
463 463
 
... ...
@@ -493,7 +493,7 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
493 493
         s->off = old_off;
494 494
         return -1;
495 495
     }
496
-    url_close(old_hd);
496
+    ffurl_close(old_hd);
497 497
     return off;
498 498
 }
499 499
 
... ...
@@ -69,7 +69,7 @@ static int md5_close(URLContext *h)
69 69
         if (err)
70 70
             return err;
71 71
         err = ffurl_write(out, buf, i*2+1);
72
-        url_close(out);
72
+        ffurl_close(out);
73 73
     } else {
74 74
         if (fwrite(buf, 1, i*2+1, stdout) < i*2+1)
75 75
             err = AVERROR(errno);
... ...
@@ -64,7 +64,7 @@ static int mmsh_close(URLContext *h)
64 64
     MMSHContext *mmsh = (MMSHContext *)h->priv_data;
65 65
     MMSContext *mms   = &mmsh->mms;
66 66
     if (mms->mms_hd)
67
-        url_close(mms->mms_hd);
67
+        ffurl_close(mms->mms_hd);
68 68
     av_free(mms->streams);
69 69
     av_free(mms->asf_header);
70 70
     av_freep(&h->priv_data);
... ...
@@ -259,7 +259,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
259 259
     }
260 260
 
261 261
     // close the socket and then reopen it for sending the second play request.
262
-    url_close(mms->mms_hd);
262
+    ffurl_close(mms->mms_hd);
263 263
     memset(headers, 0, sizeof(headers));
264 264
     if (ffurl_alloc(&mms->mms_hd, httpname, URL_RDONLY) < 0) {
265 265
         return AVERROR(EIO);
... ...
@@ -464,7 +464,7 @@ static int mms_close(URLContext *h)
464 464
     MMSContext *mms   = &mmst->mms;
465 465
     if(mms->mms_hd) {
466 466
         send_close_packet(mmst);
467
-        url_close(mms->mms_hd);
467
+        ffurl_close(mms->mms_hd);
468 468
     }
469 469
 
470 470
     /* free all separately allocated pointers in mms */
... ...
@@ -786,7 +786,7 @@ static int rtmp_close(URLContext *h)
786 786
         gen_delete_stream(h, rt);
787 787
 
788 788
     av_freep(&rt->flv_data);
789
-    url_close(rt->stream);
789
+    ffurl_close(rt->stream);
790 790
     av_free(rt);
791 791
     return 0;
792 792
 }
... ...
@@ -212,9 +212,9 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
212 212
 
213 213
  fail:
214 214
     if (s->rtp_hd)
215
-        url_close(s->rtp_hd);
215
+        ffurl_close(s->rtp_hd);
216 216
     if (s->rtcp_hd)
217
-        url_close(s->rtcp_hd);
217
+        ffurl_close(s->rtcp_hd);
218 218
     av_free(s);
219 219
     return AVERROR(EIO);
220 220
 }
... ...
@@ -313,8 +313,8 @@ static int rtp_close(URLContext *h)
313 313
 {
314 314
     RTPContext *s = h->priv_data;
315 315
 
316
-    url_close(s->rtp_hd);
317
-    url_close(s->rtcp_hd);
316
+    ffurl_close(s->rtp_hd);
317
+    ffurl_close(s->rtcp_hd);
318 318
     av_free(s);
319 319
     return 0;
320 320
 }
... ...
@@ -509,7 +509,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s)
509 509
         }
510 510
         rtsp_st->transport_priv = NULL;
511 511
         if (rtsp_st->rtp_handle)
512
-            url_close(rtsp_st->rtp_handle);
512
+            ffurl_close(rtsp_st->rtp_handle);
513 513
         rtsp_st->rtp_handle = NULL;
514 514
     }
515 515
 }
... ...
@@ -1297,8 +1297,8 @@ fail:
1297 1297
 void ff_rtsp_close_connections(AVFormatContext *s)
1298 1298
 {
1299 1299
     RTSPState *rt = s->priv_data;
1300
-    if (rt->rtsp_hd_out != rt->rtsp_hd) url_close(rt->rtsp_hd_out);
1301
-    url_close(rt->rtsp_hd);
1300
+    if (rt->rtsp_hd_out != rt->rtsp_hd) ffurl_close(rt->rtsp_hd_out);
1301
+    ffurl_close(rt->rtsp_hd);
1302 1302
     rt->rtsp_hd = rt->rtsp_hd_out = NULL;
1303 1303
 }
1304 1304
 
... ...
@@ -1888,7 +1888,7 @@ static int rtp_read_header(AVFormatContext *s,
1888 1888
         break;
1889 1889
     }
1890 1890
     getsockname(url_get_file_handle(in), (struct sockaddr*) &addr, &addrlen);
1891
-    url_close(in);
1891
+    ffurl_close(in);
1892 1892
     in = NULL;
1893 1893
 
1894 1894
     memset(&codec, 0, sizeof(codec));
... ...
@@ -1927,7 +1927,7 @@ static int rtp_read_header(AVFormatContext *s,
1927 1927
 
1928 1928
 fail:
1929 1929
     if (in)
1930
-        url_close(in);
1930
+        ffurl_close(in);
1931 1931
     ff_network_close();
1932 1932
     return ret;
1933 1933
 }
... ...
@@ -54,7 +54,7 @@ static int sap_read_close(AVFormatContext *s)
54 54
     if (sap->sdp_ctx)
55 55
         av_close_input_stream(sap->sdp_ctx);
56 56
     if (sap->ann_fd)
57
-        url_close(sap->ann_fd);
57
+        ffurl_close(sap->ann_fd);
58 58
     av_freep(&sap->sdp);
59 59
     ff_network_close();
60 60
     return 0;
... ...
@@ -59,7 +59,7 @@ static int sap_write_close(AVFormatContext *s)
59 59
 
60 60
     av_freep(&sap->ann);
61 61
     if (sap->ann_fd)
62
-        url_close(sap->ann_fd);
62
+        ffurl_close(sap->ann_fd);
63 63
     ff_network_close();
64 64
     return 0;
65 65
 }
... ...
@@ -102,4 +102,13 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size);
102 102
  */
103 103
 int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
104 104
 
105
+/**
106
+ * Close the resource accessed by the URLContext h, and free the
107
+ * memory used by it.
108
+ *
109
+ * @return a negative value if an error condition occurred, 0
110
+ * otherwise
111
+ */
112
+int ffurl_close(URLContext *h);
113
+
105 114
 #endif //AVFORMAT_URL_H