Statistics
| Branch: | Revision:

ffmpeg / libavformat / url.h @ c486dade

History | View | Annotate | Download (5.39 KB)

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

    
20
/**
21
 * @file
22
 * unbuffered private I/O API
23
 */
24

    
25
#ifndef AVFORMAT_URL_H
26
#define AVFORMAT_URL_H
27

    
28
#include "avio.h"
29
#include "libavformat/version.h"
30

    
31
#if !FF_API_OLD_AVIO
32
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
33

    
34
extern int (*url_interrupt_cb)(void);
35

    
36
typedef struct URLContext {
37
    const AVClass *av_class;    /**< information for av_log(). Set by url_open(). */
38
    struct 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
} URLContext;
46
#endif
47

    
48
/**
49
 * Create a URLContext for accessing to the resource indicated by
50
 * url, but do not initiate the connection yet.
51
 *
52
 * @param puc pointer to the location where, in case of success, the
53
 * function puts the pointer to the created URLContext
54
 * @param flags flags which control how the resource indicated by url
55
 * is to be opened
56
 * @return 0 in case of success, a negative value corresponding to an
57
 * AVERROR code in case of failure
58
 */
59
int ffurl_alloc(URLContext **h, const char *url, int flags);
60

    
61
/**
62
 * Connect an URLContext that has been allocated by ffurl_alloc
63
 */
64
int ffurl_connect(URLContext *h);
65

    
66
/**
67
 * Create an URLContext for accessing to the resource indicated by
68
 * url, and open it.
69
 *
70
 * @param puc pointer to the location where, in case of success, the
71
 * function puts the pointer to the created URLContext
72
 * @param flags flags which control how the resource indicated by url
73
 * is to be opened
74
 * @return 0 in case of success, a negative value corresponding to an
75
 * AVERROR code in case of failure
76
 */
77
int ffurl_open(URLContext **h, const char *url, int flags);
78

    
79
/**
80
 * Read up to size bytes from the resource accessed by h, and store
81
 * the read bytes in buf.
82
 *
83
 * @return The number of bytes actually read, or a negative value
84
 * corresponding to an AVERROR code in case of error. A value of zero
85
 * indicates that it is not possible to read more from the accessed
86
 * resource (except if the value of the size argument is also zero).
87
 */
88
int ffurl_read(URLContext *h, unsigned char *buf, int size);
89

    
90
/**
91
 * Read as many bytes as possible (up to size), calling the
92
 * read function multiple times if necessary.
93
 * This makes special short-read handling in applications
94
 * unnecessary, if the return value is < size then it is
95
 * certain there was either an error or the end of file was reached.
96
 */
97
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
98

    
99
/**
100
 * Write size bytes from buf to the resource accessed by h.
101
 *
102
 * @return the number of bytes actually written, or a negative value
103
 * corresponding to an AVERROR code in case of failure
104
 */
105
int ffurl_write(URLContext *h, const unsigned char *buf, int size);
106

    
107
/**
108
 * Change the position that will be used by the next read/write
109
 * operation on the resource accessed by h.
110
 *
111
 * @param pos specifies the new position to set
112
 * @param whence specifies how pos should be interpreted, it must be
113
 * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
114
 * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
115
 * (return the filesize of the requested resource, pos is ignored).
116
 * @return a negative value corresponding to an AVERROR code in case
117
 * of failure, or the resulting file position, measured in bytes from
118
 * the beginning of the file. You can use this feature together with
119
 * SEEK_CUR to read the current file position.
120
 */
121
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
122

    
123
/**
124
 * Close the resource accessed by the URLContext h, and free the
125
 * memory used by it.
126
 *
127
 * @return a negative value if an error condition occurred, 0
128
 * otherwise
129
 */
130
int ffurl_close(URLContext *h);
131

    
132
/**
133
 * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
134
 * if the operation is not supported by h, or another negative value
135
 * corresponding to an AVERROR error code in case of failure.
136
 */
137
int64_t ffurl_size(URLContext *h);
138

    
139
/**
140
 * Return the file descriptor associated with this URL. For RTP, this
141
 * will return only the RTP file descriptor, not the RTCP file descriptor.
142
 *
143
 * @return the file descriptor associated with this URL, or <0 on error.
144
 */
145
int ffurl_get_file_handle(URLContext *h);
146

    
147
/**
148
 * Register the URLProtocol protocol.
149
 *
150
 * @param size the size of the URLProtocol struct referenced
151
 */
152
int ffurl_register_protocol(URLProtocol *protocol, int size);
153

    
154
/* udp.c */
155
int ff_udp_set_remote_url(URLContext *h, const char *uri);
156
int ff_udp_get_local_port(URLContext *h);
157

    
158
#endif //AVFORMAT_URL_H