1 /* 2 * 3 * This file is part of FFmpeg. 4 * 5 * FFmpeg is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * FFmpeg is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with FFmpeg; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 /** 21 * @file 22 * unbuffered private I/O API 23 */ 24 25 module ffmpeg.libavformat.url; 26 27 import ffmpeg.libavformat.avio; 28 import ffmpeg.libavutil.dict; 29 import ffmpeg.libavutil.log; 30 31 import std.stdint; 32 33 @nogc nothrow extern(C): 34 35 struct URLContext { 36 const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ 37 URLProtocol *prot; 38 void *priv_data; 39 char *filename; /**< specified URL */ 40 int flags; 41 int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ 42 int is_streamed; /**< true if streamed (no seek possible), default = false */ 43 int is_connected; 44 AVIOInterruptCB interrupt_callback; 45 int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ 46 const char *protocol_whitelist; 47 } 48 49 struct URLProtocol { 50 const char *name; 51 int function( URLContext *h, const char *url, int flags) url_open; 52 /** 53 * This callback is to be used by protocols which open further nested 54 * protocols. options are then to be passed to ffurl_open()/ffurl_connect() 55 * for those nested protocols. 56 */ 57 int function(URLContext *h, const char *url, int flags, AVDictionary **options) url_open2; 58 int function(URLContext *s, URLContext **c) url_accept; 59 int function(URLContext *c) url_handshake; 60 61 /** 62 * Read data from the protocol. 63 * If data is immediately available (even less than size), EOF is 64 * reached or an error occurs (including EINTR), return immediately. 65 * Otherwise: 66 * In non-blocking mode, return AVERROR(EAGAIN) immediately. 67 * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), 68 * and return AVERROR(EAGAIN) on timeout. 69 * Checking interrupt_callback, looping on EINTR and EAGAIN and until 70 * enough data has been read is left to the calling function; see 71 * retry_transfer_wrapper in avio.c. 72 */ 73 int function( URLContext *h, ubyte *buf, int size) url_read; 74 int function(URLContext *h, const ubyte *buf, int size) url_write; 75 int64_t function( URLContext *h, int64_t pos, int whence) url_seek; 76 int function(URLContext *h) url_close; 77 URLProtocol *next; 78 int function(URLContext *h, int pause) url_read_pause; 79 int64_t function(URLContext *h, int stream_index, 80 int64_t timestamp, int flags) url_read_seek; 81 int function(URLContext *h) url_get_file_handle; 82 int function(URLContext *h, int **handles, 83 int *numhandles) url_get_multi_file_handle; 84 int function(URLContext *h, int flags) url_shutdown; 85 int priv_data_size; 86 const AVClass *priv_data_class; 87 int flags; 88 int function(URLContext *h, int mask) url_check; 89 int function(URLContext *h) url_open_dir; 90 int function(URLContext *h, AVIODirEntry **next) url_read_dir; 91 int function(URLContext *h) url_close_dir; 92 int function(URLContext *h) url_delete; 93 int function(URLContext *h_src, URLContext *h_dst) url_move; 94 const char *default_whitelist; 95 }