Browse code

avio: make url_seek() internal.

Anton Khirnov authored on 2011/04/01 00:30:31
Showing 5 changed files
... ...
@@ -143,10 +143,10 @@ int ffurl_connect(URLContext* uc)
143 143
     if (err)
144 144
         return err;
145 145
     uc->is_connected = 1;
146
-    //We must be careful here as url_seek() could be slow, for example for http
146
+    //We must be careful here as ffurl_seek() could be slow, for example for http
147 147
     if(   (uc->flags & (URL_WRONLY | URL_RDWR))
148 148
        || !strcmp(uc->prot->name, "file"))
149
-        if(!uc->is_streamed && url_seek(uc, 0, SEEK_SET) < 0)
149
+        if(!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
150 150
             uc->is_streamed= 1;
151 151
     return 0;
152 152
 }
... ...
@@ -192,6 +192,10 @@ int url_write(URLContext *h, const unsigned char *buf, int size)
192 192
 {
193 193
     return ffurl_write(h, buf, size);
194 194
 }
195
+int64_t url_seek(URLContext *h, int64_t pos, int whence)
196
+{
197
+    return ffurl_seek(h, pos, whence);
198
+}
195 199
 #endif
196 200
 
197 201
 #define URL_SCHEME_CHARS                        \
... ...
@@ -295,7 +299,7 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size)
295 295
     return retry_transfer_wrapper(h, buf, size, size, h->prot->url_write);
296 296
 }
297 297
 
298
-int64_t url_seek(URLContext *h, int64_t pos, int whence)
298
+int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
299 299
 {
300 300
     int64_t ret;
301 301
 
... ...
@@ -334,13 +338,13 @@ int64_t url_filesize(URLContext *h)
334 334
 {
335 335
     int64_t pos, size;
336 336
 
337
-    size= url_seek(h, 0, AVSEEK_SIZE);
337
+    size= ffurl_seek(h, 0, AVSEEK_SIZE);
338 338
     if(size<0){
339
-        pos = url_seek(h, 0, SEEK_CUR);
340
-        if ((size = url_seek(h, -1, SEEK_END)) < 0)
339
+        pos = ffurl_seek(h, 0, SEEK_CUR);
340
+        if ((size = ffurl_seek(h, -1, SEEK_END)) < 0)
341 341
             return size;
342 342
         size++;
343
-        url_seek(h, pos, SEEK_SET);
343
+        ffurl_seek(h, pos, SEEK_SET);
344 344
     }
345 345
     return size;
346 346
 }
... ...
@@ -108,25 +108,10 @@ attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
108 108
 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
+attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
111 112
 #endif
112 113
 
113 114
 /**
114
- * Change the position that will be used by the next read/write
115
- * operation on the resource accessed by h.
116
- *
117
- * @param pos specifies the new position to set
118
- * @param whence specifies how pos should be interpreted, it must be
119
- * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
120
- * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
121
- * (return the filesize of the requested resource, pos is ignored).
122
- * @return a negative value corresponding to an AVERROR code in case
123
- * of failure, or the resulting file position, measured in bytes from
124
- * the beginning of the file. You can use this feature together with
125
- * SEEK_CUR to read the current file position.
126
- */
127
-int64_t url_seek(URLContext *h, int64_t pos, int whence);
128
-
129
-/**
130 115
  * Close the resource accessed by the URLContext h, and free the
131 116
  * memory used by it.
132 117
  *
... ...
@@ -846,7 +846,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
846 846
 
847 847
     if (ffio_init_context(*s, buffer, buffer_size,
848 848
                       (h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
849
-                      ffurl_read, ffurl_write, url_seek) < 0) {
849
+                      ffurl_read, ffurl_write, ffurl_seek) < 0) {
850 850
         av_free(buffer);
851 851
         av_freep(s);
852 852
         return AVERROR(EIO);
... ...
@@ -141,7 +141,7 @@ static int concat_read(URLContext *h, unsigned char *buf, int size)
141 141
             return total ? total : result;
142 142
         if (!result)
143 143
             if (i + 1 == data->length ||
144
-                url_seek(nodes[++i].uc, 0, SEEK_SET) < 0)
144
+                ffurl_seek(nodes[++i].uc, 0, SEEK_SET) < 0)
145 145
                 break;
146 146
         total += result;
147 147
         buf   += result;
... ...
@@ -169,7 +169,7 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
169 169
         /* get the absolute position */
170 170
         for (i = 0; i != data->current; i++)
171 171
             pos += nodes[i].size;
172
-        pos += url_seek(nodes[i].uc, 0, SEEK_CUR);
172
+        pos += ffurl_seek(nodes[i].uc, 0, SEEK_CUR);
173 173
         whence = SEEK_SET;
174 174
         /* fall through with the absolute position */
175 175
     case SEEK_SET:
... ...
@@ -180,7 +180,7 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
180 180
         return AVERROR(EINVAL);
181 181
     }
182 182
 
183
-    result = url_seek(nodes[i].uc, pos, whence);
183
+    result = ffurl_seek(nodes[i].uc, pos, whence);
184 184
     if (result >= 0) {
185 185
         data->current = i;
186 186
         while (i)
... ...
@@ -86,4 +86,20 @@ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
86 86
  */
87 87
 int ffurl_write(URLContext *h, const unsigned char *buf, int size);
88 88
 
89
+/**
90
+ * Change the position that will be used by the next read/write
91
+ * operation on the resource accessed by h.
92
+ *
93
+ * @param pos specifies the new position to set
94
+ * @param whence specifies how pos should be interpreted, it must be
95
+ * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
96
+ * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
97
+ * (return the filesize of the requested resource, pos is ignored).
98
+ * @return a negative value corresponding to an AVERROR code in case
99
+ * of failure, or the resulting file position, measured in bytes from
100
+ * the beginning of the file. You can use this feature together with
101
+ * SEEK_CUR to read the current file position.
102
+ */
103
+int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
104
+
89 105
 #endif //AVFORMAT_URL_H