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 module ffmpeg.libavformat.url;
21 
22 /**
23  * @file
24  * unbuffered private I/O API
25  */
26 
27 import ffmpeg.libavformat.avio;
28 import ffmpeg.libavutil.dict;
29 import ffmpeg.libavutil.log;
30 import std.stdint;
31 
32 @nogc nothrow extern(C):
33 enum URL_PROTOCOL_FLAG_NESTED_SCHEME = 1; /*< The protocol name can be the first part of a nested protocol scheme */
34 enum URL_PROTOCOL_FLAG_NETWORK       = 2; /*< The protocol uses network */
35 
36 struct URLContext {
37     const AVClass *av_class;    /**< information for av_log(). Set by url_open(). */
38     URLProtocol *prot;
39     void *priv_data;
40     char *filename;             /**< specified URL */
41     int flags;
42     int max_packet_size;        /**< if non zero, the stream is packetized with this max packet size */
43     int is_streamed;            /**< true if streamed (no seek possible), default = false */
44     int is_connected;
45     AVIOInterruptCB interrupt_callback;
46     int64_t rw_timeout;         /**< maximum time to wait for (network) read/write operation completion, in mcs */
47     const char *protocol_whitelist;
48     const char *protocol_blacklist;
49 }
50 
51 struct URLProtocol {
52     const char *name;
53     int     function( URLContext *h, const char *url, int flags) url_open;
54     /**
55      * This callback is to be used by protocols which open further nested
56      * protocols. options are then to be passed to ffurl_open()/ffurl_connect()
57      * for those nested protocols.
58      */
59     int     function(URLContext *h, const char *url, int flags, AVDictionary **options) url_open2;
60     int     function(URLContext *s, URLContext **c) url_accept;
61     int     function(URLContext *c) url_handshake;
62 
63     /**
64      * Read data from the protocol.
65      * If data is immediately available (even less than size), EOF is
66      * reached or an error occurs (including EINTR), return immediately.
67      * Otherwise:
68      * In non-blocking mode, return AVERROR(EAGAIN) immediately.
69      * In blocking mode, wait for data/EOF/error with a short timeout (0.1s),
70      * and return AVERROR(EAGAIN) on timeout.
71      * Checking interrupt_callback, looping on EINTR and EAGAIN and until
72      * enough data has been read is left to the calling function; see
73      * retry_transfer_wrapper in avio.c.
74      */
75     int     function( URLContext *h, ubyte *buf, int size) url_read;
76     int     function(URLContext *h, const ubyte *buf, int size) url_write;
77     int64_t function( URLContext *h, int64_t pos, int whence) url_seek;
78     int     function(URLContext *h) url_close;
79     int function(URLContext *h, int pause) url_read_pause;
80     int64_t function(URLContext *h, int stream_index,
81                              int64_t timestamp, int flags) url_read_seek;
82     int function(URLContext *h) url_get_file_handle;
83     int function(URLContext *h, int **handles,
84                                      int *numhandles) url_get_multi_file_handle;
85     int function(URLContext *h, int flags) url_shutdown;
86     int priv_data_size;
87     const AVClass *priv_data_class;
88     int flags;
89     int function(URLContext *h, int mask) url_check;
90     int function(URLContext *h) url_open_dir;
91     int function(URLContext *h, AVIODirEntry **next) url_read_dir;
92     int function(URLContext *h) url_close_dir;
93     int function(URLContext *h) url_delete;
94     int function(URLContext *h_src, URLContext *h_dst) url_move;
95     const char *default_whitelist;
96 }