1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * This file is part of FFmpeg. 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 5cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 6cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 7cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 8cabdff1aSopenharmony_ci * 9cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 10cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 11cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12cabdff1aSopenharmony_ci * Lesser General Public License for more details. 13cabdff1aSopenharmony_ci * 14cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 15cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 16cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17cabdff1aSopenharmony_ci */ 18cabdff1aSopenharmony_ci 19cabdff1aSopenharmony_ci/** 20cabdff1aSopenharmony_ci * @file 21cabdff1aSopenharmony_ci * unbuffered private I/O API 22cabdff1aSopenharmony_ci */ 23cabdff1aSopenharmony_ci 24cabdff1aSopenharmony_ci#ifndef AVFORMAT_URL_H 25cabdff1aSopenharmony_ci#define AVFORMAT_URL_H 26cabdff1aSopenharmony_ci 27cabdff1aSopenharmony_ci#include "avio.h" 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_ci#include "libavutil/dict.h" 30cabdff1aSopenharmony_ci#include "libavutil/log.h" 31cabdff1aSopenharmony_ci 32cabdff1aSopenharmony_ci#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ 33cabdff1aSopenharmony_ci#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */ 34cabdff1aSopenharmony_ci 35cabdff1aSopenharmony_ciextern const AVClass ffurl_context_class; 36cabdff1aSopenharmony_ci 37cabdff1aSopenharmony_citypedef struct URLContext { 38cabdff1aSopenharmony_ci const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ 39cabdff1aSopenharmony_ci const struct URLProtocol *prot; 40cabdff1aSopenharmony_ci void *priv_data; 41cabdff1aSopenharmony_ci char *filename; /**< specified URL */ 42cabdff1aSopenharmony_ci int flags; 43cabdff1aSopenharmony_ci int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ 44cabdff1aSopenharmony_ci int is_streamed; /**< true if streamed (no seek possible), default = false */ 45cabdff1aSopenharmony_ci int is_connected; 46cabdff1aSopenharmony_ci AVIOInterruptCB interrupt_callback; 47cabdff1aSopenharmony_ci int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ 48cabdff1aSopenharmony_ci const char *protocol_whitelist; 49cabdff1aSopenharmony_ci const char *protocol_blacklist; 50cabdff1aSopenharmony_ci int min_packet_size; /**< if non zero, the stream is packetized with this min packet size */ 51cabdff1aSopenharmony_ci} URLContext; 52cabdff1aSopenharmony_ci 53cabdff1aSopenharmony_citypedef struct URLProtocol { 54cabdff1aSopenharmony_ci const char *name; 55cabdff1aSopenharmony_ci int (*url_open)( URLContext *h, const char *url, int flags); 56cabdff1aSopenharmony_ci /** 57cabdff1aSopenharmony_ci * This callback is to be used by protocols which open further nested 58cabdff1aSopenharmony_ci * protocols. options are then to be passed to ffurl_open_whitelist() 59cabdff1aSopenharmony_ci * or ffurl_connect() for those nested protocols. 60cabdff1aSopenharmony_ci */ 61cabdff1aSopenharmony_ci int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); 62cabdff1aSopenharmony_ci int (*url_accept)(URLContext *s, URLContext **c); 63cabdff1aSopenharmony_ci int (*url_handshake)(URLContext *c); 64cabdff1aSopenharmony_ci 65cabdff1aSopenharmony_ci /** 66cabdff1aSopenharmony_ci * Read data from the protocol. 67cabdff1aSopenharmony_ci * If data is immediately available (even less than size), EOF is 68cabdff1aSopenharmony_ci * reached or an error occurs (including EINTR), return immediately. 69cabdff1aSopenharmony_ci * Otherwise: 70cabdff1aSopenharmony_ci * In non-blocking mode, return AVERROR(EAGAIN) immediately. 71cabdff1aSopenharmony_ci * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), 72cabdff1aSopenharmony_ci * and return AVERROR(EAGAIN) on timeout. 73cabdff1aSopenharmony_ci * Checking interrupt_callback, looping on EINTR and EAGAIN and until 74cabdff1aSopenharmony_ci * enough data has been read is left to the calling function; see 75cabdff1aSopenharmony_ci * retry_transfer_wrapper in avio.c. 76cabdff1aSopenharmony_ci */ 77cabdff1aSopenharmony_ci int (*url_read)( URLContext *h, unsigned char *buf, int size); 78cabdff1aSopenharmony_ci int (*url_write)(URLContext *h, const unsigned char *buf, int size); 79cabdff1aSopenharmony_ci int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); 80cabdff1aSopenharmony_ci int (*url_close)(URLContext *h); 81cabdff1aSopenharmony_ci int (*url_read_pause)(URLContext *h, int pause); 82cabdff1aSopenharmony_ci int64_t (*url_read_seek)(URLContext *h, int stream_index, 83cabdff1aSopenharmony_ci int64_t timestamp, int flags); 84cabdff1aSopenharmony_ci int (*url_get_file_handle)(URLContext *h); 85cabdff1aSopenharmony_ci int (*url_get_multi_file_handle)(URLContext *h, int **handles, 86cabdff1aSopenharmony_ci int *numhandles); 87cabdff1aSopenharmony_ci int (*url_get_short_seek)(URLContext *h); 88cabdff1aSopenharmony_ci int (*url_shutdown)(URLContext *h, int flags); 89cabdff1aSopenharmony_ci const AVClass *priv_data_class; 90cabdff1aSopenharmony_ci int priv_data_size; 91cabdff1aSopenharmony_ci int flags; 92cabdff1aSopenharmony_ci int (*url_check)(URLContext *h, int mask); 93cabdff1aSopenharmony_ci int (*url_open_dir)(URLContext *h); 94cabdff1aSopenharmony_ci int (*url_read_dir)(URLContext *h, AVIODirEntry **next); 95cabdff1aSopenharmony_ci int (*url_close_dir)(URLContext *h); 96cabdff1aSopenharmony_ci int (*url_delete)(URLContext *h); 97cabdff1aSopenharmony_ci int (*url_move)(URLContext *h_src, URLContext *h_dst); 98cabdff1aSopenharmony_ci const char *default_whitelist; 99cabdff1aSopenharmony_ci} URLProtocol; 100cabdff1aSopenharmony_ci 101cabdff1aSopenharmony_ci/** 102cabdff1aSopenharmony_ci * Create a URLContext for accessing to the resource indicated by 103cabdff1aSopenharmony_ci * url, but do not initiate the connection yet. 104cabdff1aSopenharmony_ci * 105cabdff1aSopenharmony_ci * @param puc pointer to the location where, in case of success, the 106cabdff1aSopenharmony_ci * function puts the pointer to the created URLContext 107cabdff1aSopenharmony_ci * @param flags flags which control how the resource indicated by url 108cabdff1aSopenharmony_ci * is to be opened 109cabdff1aSopenharmony_ci * @param int_cb interrupt callback to use for the URLContext, may be 110cabdff1aSopenharmony_ci * NULL 111cabdff1aSopenharmony_ci * @return >= 0 in case of success, a negative value corresponding to an 112cabdff1aSopenharmony_ci * AVERROR code in case of failure 113cabdff1aSopenharmony_ci */ 114cabdff1aSopenharmony_ciint ffurl_alloc(URLContext **puc, const char *filename, int flags, 115cabdff1aSopenharmony_ci const AVIOInterruptCB *int_cb); 116cabdff1aSopenharmony_ci 117cabdff1aSopenharmony_ci/** 118cabdff1aSopenharmony_ci * Connect an URLContext that has been allocated by ffurl_alloc 119cabdff1aSopenharmony_ci * 120cabdff1aSopenharmony_ci * @param options A dictionary filled with options for nested protocols, 121cabdff1aSopenharmony_ci * i.e. it will be passed to url_open2() for protocols implementing it. 122cabdff1aSopenharmony_ci * This parameter will be destroyed and replaced with a dict containing options 123cabdff1aSopenharmony_ci * that were not found. May be NULL. 124cabdff1aSopenharmony_ci */ 125cabdff1aSopenharmony_ciint ffurl_connect(URLContext *uc, AVDictionary **options); 126cabdff1aSopenharmony_ci 127cabdff1aSopenharmony_ci/** 128cabdff1aSopenharmony_ci * Create an URLContext for accessing to the resource indicated by 129cabdff1aSopenharmony_ci * url, and open it. 130cabdff1aSopenharmony_ci * 131cabdff1aSopenharmony_ci * @param puc pointer to the location where, in case of success, the 132cabdff1aSopenharmony_ci * function puts the pointer to the created URLContext 133cabdff1aSopenharmony_ci * @param flags flags which control how the resource indicated by url 134cabdff1aSopenharmony_ci * is to be opened 135cabdff1aSopenharmony_ci * @param int_cb interrupt callback to use for the URLContext, may be 136cabdff1aSopenharmony_ci * NULL 137cabdff1aSopenharmony_ci * @param options A dictionary filled with protocol-private options. On return 138cabdff1aSopenharmony_ci * this parameter will be destroyed and replaced with a dict containing options 139cabdff1aSopenharmony_ci * that were not found. May be NULL. 140cabdff1aSopenharmony_ci * @param parent An enclosing URLContext, whose generic options should 141cabdff1aSopenharmony_ci * be applied to this URLContext as well. 142cabdff1aSopenharmony_ci * @return >= 0 in case of success, a negative value corresponding to an 143cabdff1aSopenharmony_ci * AVERROR code in case of failure 144cabdff1aSopenharmony_ci */ 145cabdff1aSopenharmony_ciint ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, 146cabdff1aSopenharmony_ci const AVIOInterruptCB *int_cb, AVDictionary **options, 147cabdff1aSopenharmony_ci const char *whitelist, const char* blacklist, 148cabdff1aSopenharmony_ci URLContext *parent); 149cabdff1aSopenharmony_ci 150cabdff1aSopenharmony_ci/** 151cabdff1aSopenharmony_ci * Accept an URLContext c on an URLContext s 152cabdff1aSopenharmony_ci * 153cabdff1aSopenharmony_ci * @param s server context 154cabdff1aSopenharmony_ci * @param c client context, must be unallocated. 155cabdff1aSopenharmony_ci * @return >= 0 on success, ff_neterrno() on failure. 156cabdff1aSopenharmony_ci */ 157cabdff1aSopenharmony_ciint ffurl_accept(URLContext *s, URLContext **c); 158cabdff1aSopenharmony_ci 159cabdff1aSopenharmony_ci/** 160cabdff1aSopenharmony_ci * Perform one step of the protocol handshake to accept a new client. 161cabdff1aSopenharmony_ci * See avio_handshake() for details. 162cabdff1aSopenharmony_ci * Implementations should try to return decreasing values. 163cabdff1aSopenharmony_ci * If the protocol uses an underlying protocol, the underlying handshake is 164cabdff1aSopenharmony_ci * usually the first step, and the return value can be: 165cabdff1aSopenharmony_ci * (largest value for this protocol) + (return value from other protocol) 166cabdff1aSopenharmony_ci * 167cabdff1aSopenharmony_ci * @param c the client context 168cabdff1aSopenharmony_ci * @return >= 0 on success or a negative value corresponding 169cabdff1aSopenharmony_ci * to an AVERROR code on failure 170cabdff1aSopenharmony_ci */ 171cabdff1aSopenharmony_ciint ffurl_handshake(URLContext *c); 172cabdff1aSopenharmony_ci 173cabdff1aSopenharmony_ci/** 174cabdff1aSopenharmony_ci * Read up to size bytes from the resource accessed by h, and store 175cabdff1aSopenharmony_ci * the read bytes in buf. 176cabdff1aSopenharmony_ci * 177cabdff1aSopenharmony_ci * @return The number of bytes actually read, or a negative value 178cabdff1aSopenharmony_ci * corresponding to an AVERROR code in case of error. A value of zero 179cabdff1aSopenharmony_ci * indicates that it is not possible to read more from the accessed 180cabdff1aSopenharmony_ci * resource (except if the value of the size argument is also zero). 181cabdff1aSopenharmony_ci */ 182cabdff1aSopenharmony_ciint ffurl_read(URLContext *h, unsigned char *buf, int size); 183cabdff1aSopenharmony_ci 184cabdff1aSopenharmony_ci/** 185cabdff1aSopenharmony_ci * Read as many bytes as possible (up to size), calling the 186cabdff1aSopenharmony_ci * read function multiple times if necessary. 187cabdff1aSopenharmony_ci * This makes special short-read handling in applications 188cabdff1aSopenharmony_ci * unnecessary, if the return value is < size then it is 189cabdff1aSopenharmony_ci * certain there was either an error or the end of file was reached. 190cabdff1aSopenharmony_ci */ 191cabdff1aSopenharmony_ciint ffurl_read_complete(URLContext *h, unsigned char *buf, int size); 192cabdff1aSopenharmony_ci 193cabdff1aSopenharmony_ci/** 194cabdff1aSopenharmony_ci * Write size bytes from buf to the resource accessed by h. 195cabdff1aSopenharmony_ci * 196cabdff1aSopenharmony_ci * @return the number of bytes actually written, or a negative value 197cabdff1aSopenharmony_ci * corresponding to an AVERROR code in case of failure 198cabdff1aSopenharmony_ci */ 199cabdff1aSopenharmony_ciint ffurl_write(URLContext *h, const unsigned char *buf, int size); 200cabdff1aSopenharmony_ci 201cabdff1aSopenharmony_ci/** 202cabdff1aSopenharmony_ci * Change the position that will be used by the next read/write 203cabdff1aSopenharmony_ci * operation on the resource accessed by h. 204cabdff1aSopenharmony_ci * 205cabdff1aSopenharmony_ci * @param pos specifies the new position to set 206cabdff1aSopenharmony_ci * @param whence specifies how pos should be interpreted, it must be 207cabdff1aSopenharmony_ci * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the 208cabdff1aSopenharmony_ci * current position), SEEK_END (seek from the end), or AVSEEK_SIZE 209cabdff1aSopenharmony_ci * (return the filesize of the requested resource, pos is ignored). 210cabdff1aSopenharmony_ci * @return a negative value corresponding to an AVERROR code in case 211cabdff1aSopenharmony_ci * of failure, or the resulting file position, measured in bytes from 212cabdff1aSopenharmony_ci * the beginning of the file. You can use this feature together with 213cabdff1aSopenharmony_ci * SEEK_CUR to read the current file position. 214cabdff1aSopenharmony_ci */ 215cabdff1aSopenharmony_ciint64_t ffurl_seek(URLContext *h, int64_t pos, int whence); 216cabdff1aSopenharmony_ci 217cabdff1aSopenharmony_ci/** 218cabdff1aSopenharmony_ci * Close the resource accessed by the URLContext h, and free the 219cabdff1aSopenharmony_ci * memory used by it. Also set the URLContext pointer to NULL. 220cabdff1aSopenharmony_ci * 221cabdff1aSopenharmony_ci * @return a negative value if an error condition occurred, 0 222cabdff1aSopenharmony_ci * otherwise 223cabdff1aSopenharmony_ci */ 224cabdff1aSopenharmony_ciint ffurl_closep(URLContext **h); 225cabdff1aSopenharmony_ciint ffurl_close(URLContext *h); 226cabdff1aSopenharmony_ci 227cabdff1aSopenharmony_ci/** 228cabdff1aSopenharmony_ci * Return the filesize of the resource accessed by h, AVERROR(ENOSYS) 229cabdff1aSopenharmony_ci * if the operation is not supported by h, or another negative value 230cabdff1aSopenharmony_ci * corresponding to an AVERROR error code in case of failure. 231cabdff1aSopenharmony_ci */ 232cabdff1aSopenharmony_ciint64_t ffurl_size(URLContext *h); 233cabdff1aSopenharmony_ci 234cabdff1aSopenharmony_ci/** 235cabdff1aSopenharmony_ci * Return the file descriptor associated with this URL. For RTP, this 236cabdff1aSopenharmony_ci * will return only the RTP file descriptor, not the RTCP file descriptor. 237cabdff1aSopenharmony_ci * 238cabdff1aSopenharmony_ci * @return the file descriptor associated with this URL, or <0 on error. 239cabdff1aSopenharmony_ci */ 240cabdff1aSopenharmony_ciint ffurl_get_file_handle(URLContext *h); 241cabdff1aSopenharmony_ci 242cabdff1aSopenharmony_ci/** 243cabdff1aSopenharmony_ci * Return the file descriptors associated with this URL. 244cabdff1aSopenharmony_ci * 245cabdff1aSopenharmony_ci * @return 0 on success or <0 on error. 246cabdff1aSopenharmony_ci */ 247cabdff1aSopenharmony_ciint ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles); 248cabdff1aSopenharmony_ci 249cabdff1aSopenharmony_ci/** 250cabdff1aSopenharmony_ci * Return the current short seek threshold value for this URL. 251cabdff1aSopenharmony_ci * 252cabdff1aSopenharmony_ci * @return threshold (>0) on success or <=0 on error. 253cabdff1aSopenharmony_ci */ 254cabdff1aSopenharmony_ciint ffurl_get_short_seek(URLContext *h); 255cabdff1aSopenharmony_ci 256cabdff1aSopenharmony_ci/** 257cabdff1aSopenharmony_ci * Signal the URLContext that we are done reading or writing the stream. 258cabdff1aSopenharmony_ci * 259cabdff1aSopenharmony_ci * @param h pointer to the resource 260cabdff1aSopenharmony_ci * @param flags flags which control how the resource indicated by url 261cabdff1aSopenharmony_ci * is to be shutdown 262cabdff1aSopenharmony_ci * 263cabdff1aSopenharmony_ci * @return a negative value if an error condition occurred, 0 264cabdff1aSopenharmony_ci * otherwise 265cabdff1aSopenharmony_ci */ 266cabdff1aSopenharmony_ciint ffurl_shutdown(URLContext *h, int flags); 267cabdff1aSopenharmony_ci 268cabdff1aSopenharmony_ci/** 269cabdff1aSopenharmony_ci * Check if the user has requested to interrupt a blocking function 270cabdff1aSopenharmony_ci * associated with cb. 271cabdff1aSopenharmony_ci */ 272cabdff1aSopenharmony_ciint ff_check_interrupt(AVIOInterruptCB *cb); 273cabdff1aSopenharmony_ci 274cabdff1aSopenharmony_ci/* udp.c */ 275cabdff1aSopenharmony_ciint ff_udp_set_remote_url(URLContext *h, const char *uri); 276cabdff1aSopenharmony_ciint ff_udp_get_local_port(URLContext *h); 277cabdff1aSopenharmony_ci 278cabdff1aSopenharmony_ci/** 279cabdff1aSopenharmony_ci * Assemble a URL string from components. This is the reverse operation 280cabdff1aSopenharmony_ci * of av_url_split. 281cabdff1aSopenharmony_ci * 282cabdff1aSopenharmony_ci * Note, this requires networking to be initialized, so the caller must 283cabdff1aSopenharmony_ci * ensure ff_network_init has been called. 284cabdff1aSopenharmony_ci * 285cabdff1aSopenharmony_ci * @see av_url_split 286cabdff1aSopenharmony_ci * 287cabdff1aSopenharmony_ci * @param str the buffer to fill with the url 288cabdff1aSopenharmony_ci * @param size the size of the str buffer 289cabdff1aSopenharmony_ci * @param proto the protocol identifier, if null, the separator 290cabdff1aSopenharmony_ci * after the identifier is left out, too 291cabdff1aSopenharmony_ci * @param authorization an optional authorization string, may be null. 292cabdff1aSopenharmony_ci * An empty string is treated the same as a null string. 293cabdff1aSopenharmony_ci * @param hostname the host name string 294cabdff1aSopenharmony_ci * @param port the port number, left out from the string if negative 295cabdff1aSopenharmony_ci * @param fmt a generic format string for everything to add after the 296cabdff1aSopenharmony_ci * host/port, may be null 297cabdff1aSopenharmony_ci * @return the number of characters written to the destination buffer 298cabdff1aSopenharmony_ci */ 299cabdff1aSopenharmony_ciint ff_url_join(char *str, int size, const char *proto, 300cabdff1aSopenharmony_ci const char *authorization, const char *hostname, 301cabdff1aSopenharmony_ci int port, const char *fmt, ...) av_printf_format(7, 8); 302cabdff1aSopenharmony_ci 303cabdff1aSopenharmony_ci/** 304cabdff1aSopenharmony_ci * Convert a relative url into an absolute url, given a base url. 305cabdff1aSopenharmony_ci * 306cabdff1aSopenharmony_ci * @param buf the buffer where output absolute url is written 307cabdff1aSopenharmony_ci * @param size the size of buf 308cabdff1aSopenharmony_ci * @param base the base url, may be equal to buf. 309cabdff1aSopenharmony_ci * @param rel the new url, which is interpreted relative to base 310cabdff1aSopenharmony_ci * @param handle_dos_paths handle DOS paths for file or unspecified protocol 311cabdff1aSopenharmony_ci */ 312cabdff1aSopenharmony_ciint ff_make_absolute_url2(char *buf, int size, const char *base, 313cabdff1aSopenharmony_ci const char *rel, int handle_dos_paths); 314cabdff1aSopenharmony_ci 315cabdff1aSopenharmony_ci/** 316cabdff1aSopenharmony_ci * Convert a relative url into an absolute url, given a base url. 317cabdff1aSopenharmony_ci * 318cabdff1aSopenharmony_ci * Same as ff_make_absolute_url2 with handle_dos_paths being equal to 319cabdff1aSopenharmony_ci * HAVE_DOS_PATHS config variable. 320cabdff1aSopenharmony_ci */ 321cabdff1aSopenharmony_ciint ff_make_absolute_url(char *buf, int size, const char *base, 322cabdff1aSopenharmony_ci const char *rel); 323cabdff1aSopenharmony_ci 324cabdff1aSopenharmony_ci/** 325cabdff1aSopenharmony_ci * Allocate directory entry with default values. 326cabdff1aSopenharmony_ci * 327cabdff1aSopenharmony_ci * @return entry or NULL on error 328cabdff1aSopenharmony_ci */ 329cabdff1aSopenharmony_ciAVIODirEntry *ff_alloc_dir_entry(void); 330cabdff1aSopenharmony_ci 331cabdff1aSopenharmony_ciconst AVClass *ff_urlcontext_child_class_iterate(void **iter); 332cabdff1aSopenharmony_ci 333cabdff1aSopenharmony_ci/** 334cabdff1aSopenharmony_ci * Construct a list of protocols matching a given whitelist and/or blacklist. 335cabdff1aSopenharmony_ci * 336cabdff1aSopenharmony_ci * @param whitelist a comma-separated list of allowed protocol names or NULL. If 337cabdff1aSopenharmony_ci * this is a non-empty string, only protocols in this list will 338cabdff1aSopenharmony_ci * be included. 339cabdff1aSopenharmony_ci * @param blacklist a comma-separated list of forbidden protocol names or NULL. 340cabdff1aSopenharmony_ci * If this is a non-empty string, all protocols in this list 341cabdff1aSopenharmony_ci * will be excluded. 342cabdff1aSopenharmony_ci * 343cabdff1aSopenharmony_ci * @return a NULL-terminated array of matching protocols. The array must be 344cabdff1aSopenharmony_ci * freed by the caller. 345cabdff1aSopenharmony_ci */ 346cabdff1aSopenharmony_ciconst URLProtocol **ffurl_get_protocols(const char *whitelist, 347cabdff1aSopenharmony_ci const char *blacklist); 348cabdff1aSopenharmony_ci 349cabdff1aSopenharmony_citypedef struct URLComponents { 350cabdff1aSopenharmony_ci const char *url; /**< whole URL, for reference */ 351cabdff1aSopenharmony_ci const char *scheme; /**< possibly including lavf-specific options */ 352cabdff1aSopenharmony_ci const char *authority; /**< "//" if it is a real URL */ 353cabdff1aSopenharmony_ci const char *userinfo; /**< including final '@' if present */ 354cabdff1aSopenharmony_ci const char *host; 355cabdff1aSopenharmony_ci const char *port; /**< including initial ':' if present */ 356cabdff1aSopenharmony_ci const char *path; 357cabdff1aSopenharmony_ci const char *query; /**< including initial '?' if present */ 358cabdff1aSopenharmony_ci const char *fragment; /**< including initial '#' if present */ 359cabdff1aSopenharmony_ci const char *end; 360cabdff1aSopenharmony_ci} URLComponents; 361cabdff1aSopenharmony_ci 362cabdff1aSopenharmony_ci#define url_component_end_scheme authority 363cabdff1aSopenharmony_ci#define url_component_end_authority userinfo 364cabdff1aSopenharmony_ci#define url_component_end_userinfo host 365cabdff1aSopenharmony_ci#define url_component_end_host port 366cabdff1aSopenharmony_ci#define url_component_end_port path 367cabdff1aSopenharmony_ci#define url_component_end_path query 368cabdff1aSopenharmony_ci#define url_component_end_query fragment 369cabdff1aSopenharmony_ci#define url_component_end_fragment end 370cabdff1aSopenharmony_ci#define url_component_end_authority_full path 371cabdff1aSopenharmony_ci 372cabdff1aSopenharmony_ci#define URL_COMPONENT_HAVE(uc, component) \ 373cabdff1aSopenharmony_ci ((uc).url_component_end_##component > (uc).component) 374cabdff1aSopenharmony_ci 375cabdff1aSopenharmony_ci/** 376cabdff1aSopenharmony_ci * Parse an URL to find the components. 377cabdff1aSopenharmony_ci * 378cabdff1aSopenharmony_ci * Each component runs until the start of the next component, 379cabdff1aSopenharmony_ci * possibly including a mandatory delimiter. 380cabdff1aSopenharmony_ci * 381cabdff1aSopenharmony_ci * @param uc structure to fill with pointers to the components. 382cabdff1aSopenharmony_ci * @param url URL to parse. 383cabdff1aSopenharmony_ci * @param end end of the URL, or NULL to parse to the end of string. 384cabdff1aSopenharmony_ci * 385cabdff1aSopenharmony_ci * @return >= 0 for success or an AVERROR code, especially if the URL is 386cabdff1aSopenharmony_ci * malformed. 387cabdff1aSopenharmony_ci */ 388cabdff1aSopenharmony_ciint ff_url_decompose(URLComponents *uc, const char *url, const char *end); 389cabdff1aSopenharmony_ci 390cabdff1aSopenharmony_ci/** 391cabdff1aSopenharmony_ci * Move or rename a resource. 392cabdff1aSopenharmony_ci * 393cabdff1aSopenharmony_ci * @note url_src and url_dst should share the same protocol and authority. 394cabdff1aSopenharmony_ci * 395cabdff1aSopenharmony_ci * @param url_src url to resource to be moved 396cabdff1aSopenharmony_ci * @param url_dst new url to resource if the operation succeeded 397cabdff1aSopenharmony_ci * @return >=0 on success or negative on error. 398cabdff1aSopenharmony_ci */ 399cabdff1aSopenharmony_ciint ffurl_move(const char *url_src, const char *url_dst); 400cabdff1aSopenharmony_ci 401cabdff1aSopenharmony_ci/** 402cabdff1aSopenharmony_ci * Delete a resource. 403cabdff1aSopenharmony_ci * 404cabdff1aSopenharmony_ci * @param url resource to be deleted. 405cabdff1aSopenharmony_ci * @return >=0 on success or negative on error. 406cabdff1aSopenharmony_ci */ 407cabdff1aSopenharmony_ciint ffurl_delete(const char *url); 408cabdff1aSopenharmony_ci 409cabdff1aSopenharmony_ci#endif /* AVFORMAT_URL_H */ 410