libavformat/avio.c File Reference

#include <unistd.h>
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "os_support.h"
#include "avformat.h"

Go to the source code of this file.

Data Structures

struct  URLProtocol_compat

Defines

#define _XOPEN_SOURCE   600
#define URL_SCHEME_CHARS

Functions

static int default_interrupt_cb (void)
URLProtocolav_protocol_next (URLProtocol *p)
 If protocol is NULL, returns the first registered protocol, if protocol is non-NULL, returns the next registered protocol after protocol, or NULL if protocol is the last one.
int av_register_protocol2 (URLProtocol *protocol, int size)
 Register the URLProtocol protocol.
int av_register_protocol (URLProtocol *protocol)
int register_protocol (URLProtocol *protocol)
static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, const char *filename, int flags)
int url_connect (URLContext *uc)
 Connect an URLContext that has been allocated by url_alloc.
int url_open_protocol (URLContext **puc, struct URLProtocol *up, const char *filename, int flags)
 Create a URLContext for accessing to the resource indicated by url, and open it using the URLProtocol up.
int url_alloc (URLContext **puc, const char *filename, int flags)
 Create a URLContext for accessing to the resource indicated by url, but do not initiate the connection yet.
int url_open (URLContext **puc, const char *filename, int flags)
 Create an URLContext for accessing to the resource indicated by url, and open it.
static int retry_transfer_wrapper (URLContext *h, unsigned char *buf, int size, int size_min, int(*transfer_func)(URLContext *h, unsigned char *buf, int size))
int url_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.
int url_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.
int url_write (URLContext *h, const unsigned char *buf, int size)
 Write size bytes from buf to the resource accessed by h.
int64_t url_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.
int url_close (URLContext *h)
 Close the resource accessed by the URLContext h, and free the memory used by it.
int url_exist (const char *filename)
 Return a non-zero value if the resource indicated by url exists, 0 otherwise.
int64_t url_filesize (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.
int url_get_file_handle (URLContext *h)
 Return the file descriptor associated with this URL.
int url_get_max_packet_size (URLContext *h)
 Return the maximum packet size associated to packetized file handle.
void url_get_filename (URLContext *h, char *buf, int buf_size)
 Copy the filename of the resource accessed by h to buf.
void url_set_interrupt_cb (URLInterruptCB *interrupt_cb)
 The callback is called in blocking functions to test regulary if asynchronous interruption is needed.
int av_url_read_pause (URLContext *h, int pause)
 Pause and resume playing - only meaningful if using a network streaming protocol (e.g.
int64_t av_url_read_seek (URLContext *h, int stream_index, int64_t timestamp, int flags)
 Seek to a given timestamp relative to some component stream.

Variables

URLProtocolfirst_protocol = NULL
URLInterruptCBurl_interrupt_cb = default_interrupt_cb


Define Documentation

#define _XOPEN_SOURCE   600

Definition at line 23 of file avio.c.

#define URL_SCHEME_CHARS

Value:

"abcdefghijklmnopqrstuvwxyz"                \
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                \
    "0123456789+-."

Definition at line 170 of file avio.c.

Referenced by url_alloc().


Function Documentation

URLProtocol* av_protocol_next ( URLProtocol p  ) 

If protocol is NULL, returns the first registered protocol, if protocol is non-NULL, returns the next registered protocol after protocol, or NULL if protocol is the last one.

Definition at line 53 of file avio.c.

Referenced by show_protocols().

int av_register_protocol ( URLProtocol protocol  ) 

Deprecated:
Use av_register_protocol2() instead.

Definition at line 86 of file avio.c.

int av_register_protocol2 ( URLProtocol protocol,
int  size 
)

Register the URLProtocol protocol.

Parameters:
size the size of the URLProtocol struct referenced

Definition at line 59 of file avio.c.

Referenced by av_register_protocol(), and register_protocol().

int av_url_read_pause ( URLContext h,
int  pause 
)

Pause and resume playing - only meaningful if using a network streaming protocol (e.g.

MMS).

Parameters:
pause 1 for pause, 0 for resume

Definition at line 351 of file avio.c.

int64_t av_url_read_seek ( URLContext h,
int  stream_index,
int64_t  timestamp,
int  flags 
)

Seek to a given timestamp relative to some component stream.

Only meaningful if using a network streaming protocol (e.g. MMS.).

Parameters:
stream_index The stream index that the timestamp is relative to. If stream_index is (-1) the timestamp should be in AV_TIME_BASE units from the beginning of the presentation. If a stream_index >= 0 is used and the protocol does not support seeking based on component streams, the call will fail with ENOTSUP.
timestamp timestamp in AVStream.time_base units or if there is no stream specified then in AV_TIME_BASE units.
flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE and AVSEEK_FLAG_ANY. The protocol may silently ignore AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will fail with ENOTSUP if used and not supported.
Returns:
>= 0 on success
See also:
AVInputFormat::read_seek

Definition at line 358 of file avio.c.

static int default_interrupt_cb ( void   )  [static]

Definition at line 339 of file avio.c.

Referenced by url_set_interrupt_cb().

int register_protocol ( URLProtocol protocol  ) 

Deprecated:
Use av_register_protocol() instead.

Definition at line 91 of file avio.c.

static int retry_transfer_wrapper ( URLContext h,
unsigned char *  buf,
int  size,
int  size_min,
int(*)(URLContext *h, unsigned char *buf, int size transfer_func 
) [inline, static]

Definition at line 216 of file avio.c.

Referenced by url_read(), url_read_complete(), and url_write().

int url_alloc ( URLContext **  h,
const char *  url,
int  flags 
)

Create a URLContext for accessing to the resource indicated by url, but do not initiate the connection yet.

Parameters:
puc pointer to the location where, in case of success, the function puts the pointer to the created URLContext
flags flags which control how the resource indicated by url is to be opened
Returns:
0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 175 of file avio.c.

Referenced by mmsh_open(), and url_open().

static int url_alloc_for_protocol ( URLContext **  puc,
struct URLProtocol up,
const char *  filename,
int  flags 
) [static]

Definition at line 97 of file avio.c.

Referenced by url_alloc(), and url_open_protocol().

int url_close ( URLContext h  ) 

int url_connect ( URLContext uc  ) 

Connect an URLContext that has been allocated by url_alloc.

Definition at line 139 of file avio.c.

Referenced by mmsh_open(), url_open(), and url_open_protocol().

int url_exist ( const char *  filename  ) 

Return a non-zero value if the resource indicated by url exists, 0 otherwise.

Definition at line 297 of file avio.c.

Referenced by build_feed_streams(), find_image_range(), and opt_output_file().

int64_t url_filesize ( 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 306 of file avio.c.

Referenced by concat_open().

int url_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 321 of file avio.c.

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

void url_get_filename ( URLContext h,
char *  buf,
int  buf_size 
)

Copy the filename of the resource accessed by h to buf.

Parameters:
buf_size size in bytes of buf

Definition at line 333 of file avio.c.

int url_get_max_packet_size ( URLContext h  ) 

Return the maximum packet size associated to packetized file handle.

If the file is not packetized (stream like HTTP or file on disk), then 0 is returned.

Parameters:
h file handle
Returns:
maximum packet size in bytes

Definition at line 328 of file avio.c.

Referenced by http_prepare_data(), rtmp_open(), rtp_new_av_stream(), rtp_open(), sap_write_header(), and url_fdopen().

int url_open ( URLContext **  h,
const char *  url,
int  flags 
)

Create an URLContext for accessing to the resource indicated by url, and open it.

Parameters:
puc pointer to the location where, in case of success, the function puts the pointer to the created URLContext
flags flags which control how the resource indicated by url is to be opened
Returns:
0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 203 of file avio.c.

Referenced by applehttp_read(), avio_open(), concat_open(), gopher_open(), http_open_cnx(), md5_close(), mms_open(), rtmp_open(), rtp_new_av_stream(), rtp_open(), sap_read_header(), sap_write_header(), and url_exist().

int url_open_protocol ( URLContext **  puc,
struct URLProtocol up,
const char *  url,
int  flags 
)

Create a URLContext for accessing to the resource indicated by url, and open it using the URLProtocol up.

Parameters:
puc pointer to the location where, in case of success, the function puts the pointer to the created URLContext
flags flags which control how the resource indicated by url is to be opened
Returns:
0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 153 of file avio.c.

int url_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 246 of file avio.c.

Referenced by applehttp_read(), concat_read(), ff_rtmp_packet_read(), gopher_read(), http_getc(), http_read(), sap_fetch_packet(), sap_read_header(), and url_fdopen().

int url_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 253 of file avio.c.

Referenced by ff_rtmp_packet_read(), ff_rtsp_tcp_read_packet(), get_chunk_header(), get_http_header_data(), get_tcp_server_response(), read_data_packet(), and rtmp_handshake().

int64_t url_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:
pos specifies the new position to set
whence specifies 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 271 of file avio.c.

Referenced by concat_read(), concat_seek(), url_connect(), url_fdopen(), and url_filesize().

void url_set_interrupt_cb ( URLInterruptCB interrupt_cb  ) 

The callback is called in blocking functions to test regulary if asynchronous interruption is needed.

AVERROR(EINTR) is returned in this case by the interrupted function. 'NULL' means no interrupt callback is given.

Definition at line 344 of file avio.c.

Referenced by decode_thread(), main(), and transcode().

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

Write size bytes from buf to the resource accessed by h.

Returns:
the number of bytes actually written, or a negative value corresponding to an AVERROR code in case of failure

Definition at line 260 of file avio.c.

Referenced by ff_rtmp_packet_write(), gopher_write(), http_close(), http_connect(), http_send_data(), http_write(), md5_close(), rtmp_handshake(), rtp_check_and_send_back_rr(), rtp_send_punch_packets(), rtp_write(), sap_write_close(), sap_write_packet(), send_command_packet(), tcp_write_packet(), and url_fdopen().


Variable Documentation

Definition at line 50 of file avio.c.

URLInterruptCB* url_interrupt_cb = default_interrupt_cb


Generated on Mon May 2 19:50:25 2011 for FFmpeg by  doxygen 1.5.6