url.h
Go to the documentation of this file.
1 /*
2  *
3  * This file is part of Libav.
4  *
5  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef AVFORMAT_URL_H
26 #define AVFORMAT_URL_H
27 
28 #include "avio.h"
29 #include "libavformat/version.h"
30 
31 #include "libavutil/dict.h"
32 #include "libavutil/log.h"
33 
34 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
35 #define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
36 
37 extern int (*url_interrupt_cb)(void);
38 
39 extern const AVClass ffurl_context_class;
40 
41 typedef struct URLContext {
42  const AVClass *av_class;
43  struct URLProtocol *prot;
44  void *priv_data;
45  char *filename;
46  int flags;
51 } URLContext;
52 
53 typedef struct URLProtocol {
54  const char *name;
55  int (*url_open)( URLContext *h, const char *url, int flags);
61  int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options);
62 
75  int (*url_read)( URLContext *h, unsigned char *buf, int size);
76  int (*url_write)(URLContext *h, const unsigned char *buf, int size);
77  int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
78  int (*url_close)(URLContext *h);
79  struct URLProtocol *next;
80  int (*url_read_pause)(URLContext *h, int pause);
81  int64_t (*url_read_seek)(URLContext *h, int stream_index,
82  int64_t timestamp, int flags);
84  int (*url_get_multi_file_handle)(URLContext *h, int **handles,
85  int *numhandles);
86  int (*url_shutdown)(URLContext *h, int flags);
89  int flags;
90  int (*url_check)(URLContext *h, int mask);
91 } URLProtocol;
92 
106 int ffurl_alloc(URLContext **puc, const char *filename, int flags,
107  const AVIOInterruptCB *int_cb);
108 
118 
135 int ffurl_open(URLContext **puc, const char *filename, int flags,
137 
147 int ffurl_read(URLContext *h, unsigned char *buf, int size);
148 
156 int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
157 
164 int ffurl_write(URLContext *h, const unsigned char *buf, int size);
165 
180 int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
181 
189 int ffurl_close(URLContext *h);
190 
196 int64_t ffurl_size(URLContext *h);
197 
205 
211 int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles);
212 
223 int ffurl_shutdown(URLContext *h, int flags);
224 
230 int ffurl_register_protocol(URLProtocol *protocol, int size);
231 
237 
244 
245 /* udp.c */
246 int ff_udp_set_remote_url(URLContext *h, const char *uri);
248 
249 #endif /* AVFORMAT_URL_H */
int ffurl_shutdown(URLContext *h, int flags)
Signal the URLContext that we are done reading or writing the stream.
Definition: avio.c:362
Buffered I/O operations.
int size
int(* url_check)(URLContext *h, int mask)
Definition: url.h:90
int flags
Definition: url.h:89
const AVClass ffurl_context_class
Definition: avio.c:75
int64_t ffurl_size(URLContext *h)
Return the filesize of the resource accessed by h, AVERROR(ENOSYS) if the operation is not supported ...
Definition: avio.c:325
int is_streamed
true if streamed (no seek possible), default = false
Definition: url.h:48
AVIOInterruptCB interrupt_callback
Definition: url.h:50
struct URLProtocol * prot
Definition: url.h:43
int ffurl_register_protocol(URLProtocol *protocol, int size)
Register the URLProtocol protocol.
Definition: avio.c:96
int flags
Definition: url.h:46
int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Return the file descriptors associated with this URL.
Definition: avio.c:347
const AVClass * priv_data_class
Definition: url.h:88
struct URLProtocol * next
Definition: url.h:79
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:265
Public dictionary API.
int(* url_get_file_handle)(URLContext *h)
Definition: url.h:83
int(* url_get_multi_file_handle)(URLContext *h, int **handles, int *numhandles)
Definition: url.h:84
static int flags
Definition: log.c:42
Callback for checking whether to abort blocking functions.
Definition: avio.h:51
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
Definition: avio.c:203
int(* url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options)
This callback is to be used by protocols which open further nested protocols.
Definition: url.h:61
struct URLProtocol URLProtocol
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary...
Definition: avio.c:258
static const uint16_t mask[17]
Definition: lzw.c:38
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
Definition: avio.c:369
int ff_udp_set_remote_url(URLContext *h, const char *uri)
If no filename is given to av_open_input_file because you want to get the local port first...
Definition: udp.c:325
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...
Definition: avio.c:251
int(* url_open)(URLContext *h, const char *url, int flags)
Definition: url.h:55
int(* url_write)(URLContext *h, const unsigned char *buf, int size)
Definition: url.h:76
int(* url_read)(URLContext *h, unsigned char *buf, int size)
Read data from the protocol.
Definition: url.h:75
const AVIOInterruptCB int_cb
Definition: avconv.c:145
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
Definition: avio.c:155
struct URLContext URLContext
int(* url_read_pause)(URLContext *h, int pause)
Definition: url.h:80
int64_t(* url_seek)(URLContext *h, int64_t pos, int whence)
Definition: url.h:77
Libavformat version macros.
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
Definition: avio.c:340
int is_connected
Definition: url.h:49
URLProtocol * ffurl_protocol_next(URLProtocol *prev)
Iterate over all available protocols.
Definition: avio.c:35
int ff_udp_get_local_port(URLContext *h)
Return the local port used by the UDP connection.
Definition: udp.c:364
int64_t(* url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags)
Definition: url.h:81
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
Definition: url.h:41
Describe the class of an AVClass context structure.
Definition: log.h:33
void * priv_data
Definition: url.h:44
int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb)
Create a URLContext for accessing to the resource indicated by url, but do not initiate the connectio...
Definition: avio.c:176
const char * name
Definition: url.h:54
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h...
Definition: avio.c:276
const AVClass * av_class
information for av_log().
Definition: url.h:42
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
Definition: avio.c:286
const OptionDef options[]
Definition: avserver.c:4665
char * filename
specified URL
Definition: url.h:45
int(* url_interrupt_cb)(void)
int max_packet_size
if non zero, the stream is packetized with this max packet size
Definition: url.h:47
int(* url_close)(URLContext *h)
Definition: url.h:78
int(* url_shutdown)(URLContext *h, int flags)
Definition: url.h:86
int priv_data_size
Definition: url.h:87