Revision a8c5ab27

View differences:

libavformat/avio.h
146 146
int url_ferror(ByteIOContext *s);
147 147

  
148 148
#define URL_EOF (-1)
149
/* NOTE: return URL_EOF (-1) if EOF */
149 150
int url_fgetc(ByteIOContext *s);
151

  
152
/* XXX: currently size is limited */
150 153
#ifdef __GNUC__
151 154
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
152 155
#else
153 156
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
154 157
#endif
158

  
159
/* note: unlike fgets, the EOL character is not returned and a whole
160
   line is parsed. return NULL if first char read was EOF */
155 161
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
156 162

  
157 163
void put_flush_packet(ByteIOContext *s);
158 164

  
159 165
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
160 166
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
167

  
168
/* NOTE: return 0 if EOF, so you cannot use it if EOF handling is
169
   necessary */
161 170
int get_byte(ByteIOContext *s);
162 171
unsigned int get_le24(ByteIOContext *s);
163 172
unsigned int get_le32(ByteIOContext *s);
......
176 185
}
177 186

  
178 187
int url_fdopen(ByteIOContext *s, URLContext *h);
188

  
189
/* XXX: must be called before any I/O */
179 190
int url_setbufsize(ByteIOContext *s, int buf_size);
191

  
192
/* NOTE: when opened as read/write, the buffers are only used for
193
   reading */
180 194
int url_fopen(ByteIOContext *s, const char *filename, int flags);
181 195
int url_fclose(ByteIOContext *s);
182 196
URLContext *url_fileno(ByteIOContext *s);
197

  
198
/*
199
 * Return the maximum packet size associated to packetized buffered file
200
 * handle. If the file is not packetized (stream like http or file on
201
 * disk), then 0 is returned.
202
 *
203
 * @param h buffered file handle
204
 * @return maximum packet size in bytes
205
 */
183 206
int url_fget_max_packet_size(ByteIOContext *s);
184 207

  
185 208
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
209

  
210
/* return the written or read size */
186 211
int url_close_buf(ByteIOContext *s);
187 212

  
213
/*
214
 * Open a write only memory stream.
215
 *
216
 * @param s new IO context
217
 * @return zero if no error.
218
 */
188 219
int url_open_dyn_buf(ByteIOContext *s);
220

  
221
/*
222
 * Open a write only packetized memory stream with a maximum packet
223
 * size of 'max_packet_size'.  The stream is stored in a memory buffer
224
 * with a big endian 4 byte header giving the packet size in bytes.
225
 *
226
 * @param s new IO context
227
 * @param max_packet_size maximum packet size (must be > 0)
228
 * @return zero if no error.
229
 */
189 230
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
231

  
232
/*
233
 * Return the written size and a pointer to the buffer. The buffer
234
 *  must be freed with av_free().
235
 * @param s IO context
236
 * @param pointer to a byte buffer
237
 * @return the length of the byte buffer
238
 */
190 239
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
191 240

  
192 241
unsigned long get_checksum(ByteIOContext *s);
libavformat/aviobuf.c
303 303
    }
304 304
}
305 305

  
306
/* NOTE: return 0 if EOF, so you cannot use it if EOF handling is
307
   necessary */
308 306
/* XXX: put an inline version */
309 307
int get_byte(ByteIOContext *s)
310 308
{
......
319 317
    }
320 318
}
321 319

  
322
/* NOTE: return URL_EOF (-1) if EOF */
323 320
int url_fgetc(ByteIOContext *s)
324 321
{
325 322
    if (s->buf_ptr < s->buf_end) {
......
524 521
    return 0;
525 522
}
526 523

  
527
/* XXX: must be called before any I/O */
528 524
int url_setbufsize(ByteIOContext *s, int buf_size)
529 525
{
530 526
    uint8_t *buffer;
......
543 539
    return 0;
544 540
}
545 541

  
546
/* NOTE: when opened as read/write, the buffers are only used for
547
   reading */
548 542
int url_fopen(ByteIOContext *s, const char *filename, int flags)
549 543
{
550 544
    URLContext *h;
......
576 570
}
577 571

  
578 572
#ifdef CONFIG_MUXERS
579
/* XXX: currently size is limited */
580 573
int url_fprintf(ByteIOContext *s, const char *fmt, ...)
581 574
{
582 575
    va_list ap;
......
591 584
}
592 585
#endif //CONFIG_MUXERS
593 586

  
594
/* note: unlike fgets, the EOL character is not returned and a whole
595
   line is parsed. return NULL if first char read was EOF */
596 587
char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
597 588
{
598 589
    int c;
......
614 605
    return buf;
615 606
}
616 607

  
617
/*
618
 * Return the maximum packet size associated to packetized buffered file
619
 * handle. If the file is not packetized (stream like http or file on
620
 * disk), then 0 is returned.
621
 *
622
 * @param h buffered file handle
623
 * @return maximum packet size in bytes
624
 */
625 608
int url_fget_max_packet_size(ByteIOContext *s)
626 609
{
627 610
    return s->max_packet_size;
......
638 621
                         NULL, NULL, NULL, NULL);
639 622
}
640 623

  
641
/* return the written or read size */
642 624
int url_close_buf(ByteIOContext *s)
643 625
{
644 626
    put_flush_packet(s);
......
746 728
    return ret;
747 729
}
748 730

  
749
/*
750
 * Open a write only memory stream.
751
 *
752
 * @param s new IO context
753
 * @return zero if no error.
754
 */
755 731
int url_open_dyn_buf(ByteIOContext *s)
756 732
{
757 733
    return url_open_dyn_buf_internal(s, 0);
758 734
}
759 735

  
760
/*
761
 * Open a write only packetized memory stream with a maximum packet
762
 * size of 'max_packet_size'.  The stream is stored in a memory buffer
763
 * with a big endian 4 byte header giving the packet size in bytes.
764
 *
765
 * @param s new IO context
766
 * @param max_packet_size maximum packet size (must be > 0)
767
 * @return zero if no error.
768
 */
769 736
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size)
770 737
{
771 738
    if (max_packet_size <= 0)
......
773 740
    return url_open_dyn_buf_internal(s, max_packet_size);
774 741
}
775 742

  
776
/*
777
 * Return the written size and a pointer to the buffer. The buffer
778
 *  must be freed with av_free().
779
 * @param s IO context
780
 * @param pointer to a byte buffer
781
 * @return the length of the byte buffer
782
 */
783 743
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
784 744
{
785 745
    DynBuffer *d = s->opaque;

Also available in: Unified diff