url.h File Reference

unbuffered private I/O API More...

#include "avio.h"
#include "libavformat/version.h"
#include "libavutil/dict.h"
#include "libavutil/log.h"
Include dependency graph for url.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  URLContext
 
struct  URLProtocol
 

Macros

#define URL_PROTOCOL_FLAG_NESTED_SCHEME   1 /*< The protocol name can be the first part of a nested protocol scheme */
 
#define URL_PROTOCOL_FLAG_NETWORK   2 /*< The protocol uses network */
 

Typedefs

typedef struct URLContext URLContext
 
typedef struct URLProtocol URLProtocol
 

Functions

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 connection yet. More...
 
int ffurl_connect (URLContext *uc, AVDictionary **options)
 Connect an URLContext that has been allocated by ffurl_alloc. More...
 
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. More...
 
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. More...
 
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. More...
 
int ffurl_write (URLContext *h, const unsigned char *buf, int size)
 Write size bytes from buf to the resource accessed by h. More...
 
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. More...
 
int ffurl_closep (URLContext **h)
 Close the resource accessed by the URLContext h, and free the memory used by it. More...
 
int ffurl_close (URLContext *h)
 
int64_t ffurl_size (URLContext *h)
 Return the filesize of the resource accessed by h, AVERROR(ENOSYS) if the operation is not supported by h, or another negative value corresponding to an AVERROR error code in case of failure. More...
 
int ffurl_get_file_handle (URLContext *h)
 Return the file descriptor associated with this URL. More...
 
int ffurl_get_multi_file_handle (URLContext *h, int **handles, int *numhandles)
 Return the file descriptors associated with this URL. More...
 
int ffurl_shutdown (URLContext *h, int flags)
 Signal the URLContext that we are done reading or writing the stream. More...
 
int ffurl_register_protocol (URLProtocol *protocol, int size)
 Register the URLProtocol protocol. More...
 
int ff_check_interrupt (AVIOInterruptCB *cb)
 Check if the user has requested to interrup a blocking function associated with cb. More...
 
URLProtocolffurl_protocol_next (URLProtocol *prev)
 Iterate over all available protocols. More...
 
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, then you must call this function to set the remote server address. More...
 
int ff_udp_get_local_port (URLContext *h)
 Return the local port used by the UDP connection. More...
 

Variables

int(* url_interrupt_cb )(void)
 
const AVClass ffurl_context_class
 

Detailed Description

unbuffered private I/O API

Definition in file url.h.

Macro Definition Documentation

#define URL_PROTOCOL_FLAG_NESTED_SCHEME   1 /*< The protocol name can be the first part of a nested protocol scheme */

Definition at line 34 of file url.h.

Referenced by ffurl_alloc().

#define URL_PROTOCOL_FLAG_NETWORK   2 /*< The protocol uses network */

Definition at line 35 of file url.h.

Referenced by ffurl_closep(), http_get_file_handle(), and url_alloc_for_protocol().

Typedef Documentation

typedef struct URLContext URLContext
typedef struct URLProtocol URLProtocol

Function Documentation

int ff_check_interrupt ( AVIOInterruptCB cb)

Check if the user has requested to interrup a blocking function associated with cb.

Definition at line 428 of file avio.c.

Referenced by avformat_find_stream_info(), do_tls_poll(), ff_network_wait_fd_timeout(), ff_rtsp_open_transport_ctx(), hls_read(), read_data(), retry_transfer_wrapper(), rtp_read(), and tcp_open().

int ff_udp_get_local_port ( URLContext h)

Return the local port used by the UDP connection.

Parameters
hmedia file context
Returns
the local port number

Definition at line 421 of file udp.c.

Referenced by ff_rtp_get_local_rtcp_port(), ff_rtp_get_local_rtp_port(), and rtp_open().

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, then you must call this function to set the remote server address.

url syntax: udp://host:port[?option=val...] option: 'ttl=n' : set the ttl value (for multicast only) 'localport=n' : set the local port 'pkt_size=n' : set max packet size 'reuse=1' : enable reusing the socket 'overrun_nonfatal=1': survive in case of circular buffer overrun

Parameters
hmedia file context
uriof the remote server
Returns
zero if no error.

Definition at line 382 of file udp.c.

Referenced by ff_rtp_set_remote_url(), and udp_open().

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 connection yet.

Parameters
pucpointer to the location where, in case of success, the function puts the pointer to the created URLContext
flagsflags which control how the resource indicated by url is to be opened
int_cbinterrupt callback to use for the URLContext, may be NULL
Returns
0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 211 of file avio.c.

Referenced by avio_check(), ff_rtsp_open_transport_ctx(), ffurl_open(), mmsh_open_internal(), open_input(), and rtmp_http_open().

int ffurl_closep ( URLContext **  h)

Close the resource accessed by the URLContext h, and free the memory used by it.

Also set the URLContext pointer to NULL.

Returns
a negative value if an error condition occurred, 0 otherwise

Definition at line 338 of file avio.c.

Referenced by ffurl_close(), http_close(), http_get_file_handle(), and http_open_cnx().

int ffurl_connect ( URLContext uc,
AVDictionary **  options 
)

Connect an URLContext that has been allocated by ffurl_alloc.

Parameters
optionsA dictionary filled with options for nested protocols, i.e. it will be passed to url_open2() for protocols implementing it. This parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

Definition at line 190 of file avio.c.

Referenced by avio_check(), ff_rtsp_open_transport_ctx(), ffurl_open(), mmsh_open_internal(), open_input(), and rtmp_http_open().

int ffurl_get_file_handle ( URLContext h)

Return the file descriptor associated with this URL.

For RTP, this will return only the RTP file descriptor, not the RTCP file descriptor.

Returns
the file descriptor associated with this URL, or <0 on error.

Definition at line 399 of file avio.c.

Referenced by ff_rtsp_open_transport_ctx(), http_get_file_handle(), rtp_open(), rtsp_write_packet(), sap_fetch_packet(), sap_write_header(), srtp_get_file_handle(), and tls_open().

int ffurl_get_multi_file_handle ( URLContext h,
int **  handles,
int *  numhandles 
)

Return the file descriptors associated with this URL.

Returns
0 on success or <0 on error.

Definition at line 406 of file avio.c.

Referenced by ff_rtsp_open_transport_ctx(), and srtp_get_multi_file_handle().

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.

Parameters
pucpointer to the location where, in case of success, the function puts the pointer to the created URLContext
flagsflags which control how the resource indicated by url is to be opened
int_cbinterrupt callback to use for the URLContext, may be NULL
optionsA dictionary filled with protocol-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.
Returns
0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 247 of file avio.c.

Referenced by avio_open2(), cache_open(), concat_open(), crypto_open2(), ff_rtsp_open_transport_ctx(), gopher_open(), hls_read(), http_get_file_handle(), http_open_cnx(), ism_flush(), ism_seek(), md5_close(), mms_open(), open_input(), rtmp_calc_swfhash(), rtmp_open(), rtmpe_open(), rtp_new_av_stream(), rtp_open(), rtsp_listen(), rtsp_read_setup(), sap_read_header(), sap_write_header(), srtp_open(), and tls_open().

URLProtocol* ffurl_protocol_next ( URLProtocol prev)

Iterate over all available protocols.

Parameters
prevresult of the previous call to this functions or NULL.

Definition at line 35 of file avio.c.

Referenced by avio_enum_protocols(), ffurl_alloc(), and urlcontext_child_class_next().

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.

Returns
The number of bytes actually read, or a negative value corresponding to an AVERROR code in case of error. A value of zero indicates that it is not possible to read more from the accessed resource (except if the value of the size argument is also zero).

Definition at line 303 of file avio.c.

Referenced by cache_read(), concat_read(), crypto_read(), ff_rtmp_packet_read(), ff_rtsp_open_transport_ctx(), ffio_fdopen(), gopher_read(), hls_read(), http_buf_read(), http_getc(), read_data(), rtmp_http_open(), rtmp_http_read(), rtmp_http_send_cmd(), rtmp_write(), rtmpe_read(), sap_fetch_packet(), sap_read_header(), and srtp_read().

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.

This makes special short-read handling in applications unnecessary, if the return value is < size then it is certain there was either an error or the end of file was reached.

Definition at line 310 of file avio.c.

Referenced by ff_rtmp_packet_read_internal(), ff_rtsp_open_transport_ctx(), ff_rtsp_tcp_read_packet(), get_chunk_header(), get_http_header_data(), get_tcp_server_response(), open_input(), read_data_packet(), read_line(), rtmp_calc_swfhash(), rtmp_handshake(), rtmp_receive_hs_packet(), rtmp_server_handshake(), and rtsp_read_announce().

int ffurl_register_protocol ( URLProtocol protocol,
int  size 
)

Register the URLProtocol protocol.

Parameters
sizethe size of the URLProtocol struct referenced

Definition at line 96 of file avio.c.

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.

Parameters
posspecifies the new position to set
whencespecifies how pos should be interpreted, it must be one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the current position), SEEK_END (seek from the end), or AVSEEK_SIZE (return the filesize of the requested resource, pos is ignored).
Returns
a negative value corresponding to an AVERROR code in case of failure, or the resulting file position, measured in bytes from the beginning of the file. You can use this feature together with SEEK_CUR to read the current file position.

Definition at line 328 of file avio.c.

Referenced by cache_seek(), concat_read(), concat_seek(), ffio_fdopen(), ffurl_connect(), ffurl_size(), ism_seek(), and rtmp_calc_swfhash().

int ffurl_shutdown ( URLContext h,
int  flags 
)

Signal the URLContext that we are done reading or writing the stream.

Parameters
hpointer to the resource
flagsflags which control how the resource indicated by url is to be shutdown
Returns
a negative value if an error condition occurred, 0 otherwise

Definition at line 421 of file avio.c.

int64_t ffurl_size ( URLContext h)

Return the filesize of the resource accessed by h, AVERROR(ENOSYS) if the operation is not supported by h, or another negative value corresponding to an AVERROR error code in case of failure.

Definition at line 384 of file avio.c.

Referenced by concat_open().

int ffurl_write ( URLContext h,
const unsigned char *  buf,
int  size 
)

Variable Documentation

const AVClass ffurl_context_class

Definition at line 75 of file avio.c.

Referenced by ffio_url_child_class_next(), and url_alloc_for_protocol().

int(* url_interrupt_cb) (void)