Statistics
| Branch: | Revision:

ffmpeg / libavformat / url.h @ b8404847

History | View | Annotate | Download (4.61 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
#endif
34

    
35
/**
36
 * Create a URLContext for accessing to the resource indicated by
37
 * url, but do not initiate the connection yet.
38
 *
39
 * @param puc pointer to the location where, in case of success, the
40
 * function puts the pointer to the created URLContext
41
 * @param flags flags which control how the resource indicated by url
42
 * is to be opened
43
 * @return 0 in case of success, a negative value corresponding to an
44
 * AVERROR code in case of failure
45
 */
46
int ffurl_alloc(URLContext **h, const char *url, int flags);
47

    
48
/**
49
 * Connect an URLContext that has been allocated by ffurl_alloc
50
 */
51
int ffurl_connect(URLContext *h);
52

    
53
/**
54
 * Create an URLContext for accessing to the resource indicated by
55
 * url, and open it.
56
 *
57
 * @param puc pointer to the location where, in case of success, the
58
 * function puts the pointer to the created URLContext
59
 * @param flags flags which control how the resource indicated by url
60
 * is to be opened
61
 * @return 0 in case of success, a negative value corresponding to an
62
 * AVERROR code in case of failure
63
 */
64
int ffurl_open(URLContext **h, const char *url, int flags);
65

    
66
/**
67
 * Read up to size bytes from the resource accessed by h, and store
68
 * the read bytes in buf.
69
 *
70
 * @return The number of bytes actually read, or a negative value
71
 * corresponding to an AVERROR code in case of error. A value of zero
72
 * indicates that it is not possible to read more from the accessed
73
 * resource (except if the value of the size argument is also zero).
74
 */
75
int ffurl_read(URLContext *h, unsigned char *buf, int size);
76

    
77
/**
78
 * Read as many bytes as possible (up to size), calling the
79
 * read function multiple times if necessary.
80
 * This makes special short-read handling in applications
81
 * unnecessary, if the return value is < size then it is
82
 * certain there was either an error or the end of file was reached.
83
 */
84
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
85

    
86
/**
87
 * Write size bytes from buf to the resource accessed by h.
88
 *
89
 * @return the number of bytes actually written, or a negative value
90
 * corresponding to an AVERROR code in case of failure
91
 */
92
int ffurl_write(URLContext *h, const unsigned char *buf, int size);
93

    
94
/**
95
 * Change the position that will be used by the next read/write
96
 * operation on the resource accessed by h.
97
 *
98
 * @param pos specifies the new position to set
99
 * @param whence specifies how pos should be interpreted, it must be
100
 * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
101
 * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
102
 * (return the filesize of the requested resource, pos is ignored).
103
 * @return a negative value corresponding to an AVERROR code in case
104
 * of failure, or the resulting file position, measured in bytes from
105
 * the beginning of the file. You can use this feature together with
106
 * SEEK_CUR to read the current file position.
107
 */
108
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
109

    
110
/**
111
 * Close the resource accessed by the URLContext h, and free the
112
 * memory used by it.
113
 *
114
 * @return a negative value if an error condition occurred, 0
115
 * otherwise
116
 */
117
int ffurl_close(URLContext *h);
118

    
119
/**
120
 * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
121
 * if the operation is not supported by h, or another negative value
122
 * corresponding to an AVERROR error code in case of failure.
123
 */
124
int64_t ffurl_size(URLContext *h);
125

    
126
/**
127
 * Return the file descriptor associated with this URL. For RTP, this
128
 * will return only the RTP file descriptor, not the RTCP file descriptor.
129
 *
130
 * @return the file descriptor associated with this URL, or <0 on error.
131
 */
132
int ffurl_get_file_handle(URLContext *h);
133

    
134
#endif //AVFORMAT_URL_H