| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Buffered I/O for ffmpeg system | 2 * Buffered I/O for ffmpeg system |
| 3 * Copyright (c) 2000,2001 Fabrice Bellard | 3 * Copyright (c) 2000,2001 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #define IO_BUFFER_SIZE 32768 | 29 #define IO_BUFFER_SIZE 32768 |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Do seeks within this distance ahead of the current buffer by skipping | 32 * Do seeks within this distance ahead of the current buffer by skipping |
| 33 * data instead of calling the protocol seek function, for seekable | 33 * data instead of calling the protocol seek function, for seekable |
| 34 * protocols. | 34 * protocols. |
| 35 */ | 35 */ |
| 36 #define SHORT_SEEK_THRESHOLD 4096 | 36 #define SHORT_SEEK_THRESHOLD 4096 |
| 37 | 37 |
| 38 static void fill_buffer(ByteIOContext *s); | 38 static void fill_buffer(ByteIOContext *s); |
| 39 #if LIBAVFORMAT_VERSION_MAJOR >= 53 | 39 #if !FF_API_URL_RESETBUF |
| 40 static int url_resetbuf(ByteIOContext *s, int flags); | 40 static int url_resetbuf(ByteIOContext *s, int flags); |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 int init_put_byte(ByteIOContext *s, | 43 int init_put_byte(ByteIOContext *s, |
| 44 unsigned char *buffer, | 44 unsigned char *buffer, |
| 45 int buffer_size, | 45 int buffer_size, |
| 46 int write_flag, | 46 int write_flag, |
| 47 void *opaque, | 47 void *opaque, |
| 48 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), | 48 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
| 49 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), | 49 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 return AVERROR(ENOMEM); | 625 return AVERROR(ENOMEM); |
| 626 | 626 |
| 627 av_free(s->buffer); | 627 av_free(s->buffer); |
| 628 s->buffer = buffer; | 628 s->buffer = buffer; |
| 629 s->buffer_size = buf_size; | 629 s->buffer_size = buf_size; |
| 630 s->buf_ptr = buffer; | 630 s->buf_ptr = buffer; |
| 631 url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY); | 631 url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY); |
| 632 return 0; | 632 return 0; |
| 633 } | 633 } |
| 634 | 634 |
| 635 #if LIBAVFORMAT_VERSION_MAJOR < 53 | 635 #if FF_API_URL_RESETBUF |
| 636 int url_resetbuf(ByteIOContext *s, int flags) | 636 int url_resetbuf(ByteIOContext *s, int flags) |
| 637 #else | 637 #else |
| 638 static int url_resetbuf(ByteIOContext *s, int flags) | 638 static int url_resetbuf(ByteIOContext *s, int flags) |
| 639 #endif | 639 #endif |
| 640 { | 640 { |
| 641 #if LIBAVFORMAT_VERSION_MAJOR < 53 | 641 #if FF_API_URL_RESETBUF |
| 642 if (flags & URL_RDWR) | 642 if (flags & URL_RDWR) |
| 643 return AVERROR(EINVAL); | 643 return AVERROR(EINVAL); |
| 644 #else | 644 #else |
| 645 assert(flags == URL_WRONLY || flags == URL_RDONLY); | 645 assert(flags == URL_WRONLY || flags == URL_RDONLY); |
| 646 #endif | 646 #endif |
| 647 | 647 |
| 648 if (flags & URL_WRONLY) { | 648 if (flags & URL_WRONLY) { |
| 649 s->buf_end = s->buffer + s->buffer_size; | 649 s->buf_end = s->buffer + s->buffer_size; |
| 650 s->write_flag = 1; | 650 s->write_flag = 1; |
| 651 } else { | 651 } else { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 941 |
| 942 put_flush_packet(s); | 942 put_flush_packet(s); |
| 943 | 943 |
| 944 *pbuffer = d->buffer; | 944 *pbuffer = d->buffer; |
| 945 size = d->size; | 945 size = d->size; |
| 946 av_free(d); | 946 av_free(d); |
| 947 av_free(s); | 947 av_free(s); |
| 948 return size - padding; | 948 return size - padding; |
| 949 } | 949 } |
| 950 #endif /* CONFIG_MUXERS || CONFIG_NETWORK */ | 950 #endif /* CONFIG_MUXERS || CONFIG_NETWORK */ |
| OLD | NEW |