VLC  3.0.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Enumerations | Functions
Stream

Buffered input byte streams. More...

Collaboration diagram for Stream:

Files

file  vlc_stream.h
 Byte streams and byte stream filter modules interface.
 

Data Structures

struct  stream_t
 stream_t definition More...
 

Macros

#define stream_MemoryNew(a, b, c, d)   stream_MemoryNew( VLC_OBJECT(a), b, c, d )
 
#define stream_UrlNew(a, b)   stream_UrlNew( VLC_OBJECT(a), b )
 
#define stream_FilterSetDefaultReadDir(p_stream)   p_stream->pf_readdir = stream_FilterDefaultReadDir;
 Sets stream_FilterDefaultReadDir as the pf_readdir callback for this stream filter. More...
 

Enumerations

enum  stream_query_e {
  STREAM_CAN_SEEK, STREAM_CAN_FASTSEEK, STREAM_CAN_PAUSE, STREAM_CAN_CONTROL_PACE,
  STREAM_GET_SIZE =6, STREAM_IS_DIRECTORY, STREAM_GET_PTS_DELAY = 0x101, STREAM_GET_TITLE_INFO,
  STREAM_GET_TITLE, STREAM_GET_SEEKPOINT, STREAM_GET_META, STREAM_GET_CONTENT_TYPE,
  STREAM_GET_SIGNAL, STREAM_SET_PAUSE_STATE = 0x200, STREAM_SET_TITLE, STREAM_SET_SEEKPOINT,
  STREAM_SET_RECORD_STATE, STREAM_SET_PRIVATE_ID_STATE = 0x1000, STREAM_SET_PRIVATE_ID_CA, STREAM_GET_PRIVATE_ID_STATE,
  STREAM_GET_PRIVATE_BLOCK
}
 Possible commands to send to stream_Control() and stream_vaControl() More...
 

Functions

ssize_t stream_Read (stream_t *, void *, size_t)
 Reads data from a byte stream. More...
 
ssize_t stream_Peek (stream_t *, const uint8_t **, size_t)
 Peeks at data from a byte stream. More...
 
uint64_t stream_Tell (const stream_t *)
 Tells the current stream position. More...
 
int stream_Seek (stream_t *, uint64_t offset)
 Sets the current stream position. More...
 
int stream_vaControl (stream_t *s, int i_query, va_list args)
 Use to control the "stream_t *". More...
 
void stream_Delete (stream_t *s)
 Destroy a stream. More...
 
int stream_Control (stream_t *s, int i_query,...)
 
block_tstream_Block (stream_t *s, size_t)
 Read data into a block. More...
 
char * stream_ReadLine (stream_t *)
 
int stream_ReadDir (stream_t *, input_item_node_t *)
 Returns a node containing all the input_item of the directory pointer by this stream. More...
 
stream_tstream_CustomNew (vlc_object_t *, void(*)(stream_t *))
 Low level custom stream creation. More...
 
static int stream_GetSize (stream_t *s, uint64_t *size)
 Get the size of the stream. More...
 
static int64_t stream_Size (stream_t *s)
 
static char * stream_ContentType (stream_t *s)
 Get the Content-Type of a stream, or NULL if unknown. More...
 
stream_tstream_DemuxNew (demux_t *p_demux, const char *psz_demux, es_out_t *out)
 Create a special stream and a demuxer, this allows chaining demuxers You must delete it using stream_Delete. More...
 
void stream_DemuxSend (stream_t *s, block_t *p_block)
 Send data to a stream handle created by stream_DemuxNew(). More...
 
int stream_DemuxControlVa (stream_t *s, int, va_list)
 Perform a demux (i.e. More...
 
static int stream_DemuxControl (stream_t *s, int query,...)
 
stream_tstream_MemoryNew (vlc_object_t *p_obj, uint8_t *p_buffer, uint64_t i_size, bool b_preserve_memory)
 Create a stream_t reading from memory. More...
 
stream_tstream_UrlNew (vlc_object_t *p_this, const char *psz_url)
 Create a stream_t reading from a URL. More...
 
stream_tstream_FilterNew (stream_t *p_source, const char *psz_stream_filter)
 Try to add a stream filter to an open stream. More...
 
int stream_FilterDefaultReadDir (stream_t *s, input_item_node_t *p_node)
 Default ReadDir implementation for stream Filter. More...
 

Detailed Description

Buffered input byte streams.

Macro Definition Documentation

#define stream_FilterSetDefaultReadDir (   p_stream)    p_stream->pf_readdir = stream_FilterDefaultReadDir;

Sets stream_FilterDefaultReadDir as the pf_readdir callback for this stream filter.

#define stream_MemoryNew (   a,
  b,
  c,
 
)    stream_MemoryNew( VLC_OBJECT(a), b, c, d )
#define stream_UrlNew (   a,
 
)    stream_UrlNew( VLC_OBJECT(a), b )

Referenced by DownloadArt(), and ImageReadUrl().

Enumeration Type Documentation

Possible commands to send to stream_Control() and stream_vaControl()

Enumerator
STREAM_CAN_SEEK 

arg1= bool * res=cannot fail

STREAM_CAN_FASTSEEK 

arg1= bool * res=cannot fail

STREAM_CAN_PAUSE 

arg1= bool * res=cannot fail

STREAM_CAN_CONTROL_PACE 

arg1= bool * res=cannot fail

STREAM_GET_SIZE 

arg1= uint64_t * res=can fail

STREAM_IS_DIRECTORY 

arg1= bool *, res=can fail

STREAM_GET_PTS_DELAY 

arg1= int64_t* res=cannot fail

STREAM_GET_TITLE_INFO 

arg1=input_title_t*** arg2=int* res=can fail

STREAM_GET_TITLE 

arg1=unsigned * res=can fail

STREAM_GET_SEEKPOINT 

arg1=unsigned * res=can fail

STREAM_GET_META 

arg1= vlc_meta_t * res=can fail

STREAM_GET_CONTENT_TYPE 

arg1= char ** res=can fail

STREAM_GET_SIGNAL 

arg1=double *pf_quality, arg2=double *pf_strength res=can fail

STREAM_SET_PAUSE_STATE 

arg1= bool res=can fail

STREAM_SET_TITLE 

arg1= int res=can fail

STREAM_SET_SEEKPOINT 

arg1= int res=can fail

STREAM_SET_RECORD_STATE 

arg1=bool, arg2=const char *psz_ext (if arg1 is true) res=can fail

STREAM_SET_PRIVATE_ID_STATE 
STREAM_SET_PRIVATE_ID_CA 
STREAM_GET_PRIVATE_ID_STATE 
STREAM_GET_PRIVATE_BLOCK 

arg1= block_t **b, arg2=bool *eof

Function Documentation

block_t* stream_Block ( stream_t s,
size_t  size 
)

Read data into a block.

Parameters
sstream to read data from
sizenumber of bytes to read
Returns
a block of data, or NULL on error @ note The block size may be shorter than requested if the end-of-stream was reached.

References block_Alloc(), block_Release(), block_t::i_buffer, block_t::p_buffer, stream_Read(), and unlikely.

Referenced by ImageReadUrl().

static char* stream_ContentType ( stream_t s)
inlinestatic

Get the Content-Type of a stream, or NULL if unknown.

Result must be free()'d.

References stream_Control(), and STREAM_GET_CONTENT_TYPE.

Referenced by demux_IsContentType(), demux_NewAdvanced(), and ImageReadUrl().

int stream_Control ( stream_t s,
int  i_query,
  ... 
)
stream_t* stream_CustomNew ( vlc_object_t parent,
void(*)(stream_t *)  destroy 
)

Low level custom stream creation.

Low level custom stream creation.

References stream_CommonNew().

void stream_Delete ( stream_t s)
static int stream_DemuxControl ( stream_t s,
int  query,
  ... 
)
inlinestatic
int stream_DemuxControlVa ( stream_t s,
int  ,
va_list   
)

Perform a demux (i.e.

DEMUX_...) control request on a stream handle created by stream_DemuxNew().

< Unspecified error

< No error

References DEMUX_GET_LENGTH, DEMUX_GET_POSITION, DEMUX_GET_TIME, stream_sys_t::length, stream_sys_t::lock, stream_t::p_sys, stream_sys_t::position, stream_sys_t::stats, stream_sys_t::time, VLC_EGENERIC, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_SUCCESS.

Referenced by stream_DemuxControl().

stream_t* stream_DemuxNew ( demux_t p_demux,
const char *  psz_demux,
es_out_t out 
)
void stream_DemuxSend ( stream_t s,
block_t p_block 
)

Send data to a stream handle created by stream_DemuxNew().

References block_FifoPut(), stream_sys_t::p_fifo, and stream_t::p_sys.

int stream_FilterDefaultReadDir ( stream_t s,
input_item_node_t p_node 
)

Default ReadDir implementation for stream Filter.

This implementation just forward the pf_readdir call to the p_source stream.

References stream_t::p_source, and stream_ReadDir().

stream_t* stream_FilterNew ( stream_t p_source,
const char *  psz_stream_filter 
)

Try to add a stream filter to an open stream.

Returns
New stream to use, or NULL if the filter could not be added.

Try to add a stream filter to an open stream.

You must release it using stream_Delete unless it is used as a source to another filter.

References module_need, stream_t::p_input, stream_t::p_module, stream_t::p_parent, stream_t::p_source, stream_t::psz_url, strdup(), stream_CommonDelete(), stream_CommonNew(), StreamDelete(), and unlikely.

Referenced by stream_FilterAutoNew(), and stream_FilterChainNew().

static int stream_GetSize ( stream_t s,
uint64_t *  size 
)
inlinestatic

Get the size of the stream.

References stream_Control(), and STREAM_GET_SIZE.

Referenced by ImageReadUrl(), and stream_Size().

stream_t* stream_MemoryNew ( vlc_object_t p_this,
uint8_t *  p_buffer,
uint64_t  i_size,
bool  i_preserve_memory 
)

Create a stream_t reading from memory.

You must delete it using stream_Delete.

Create a stream_t reading from memory.

Parameters
p_thisthe calling vlc_object
p_bufferthe memory buffer for the stream
i_bufferthe size of the buffer
i_preserve_memoryif this is set to false the memory buffer pointed to by p_buffer is freed on stream_Destroy

References Control(), Delete(), stream_sys_t::i_pos, stream_sys_t::i_preserve_memory, stream_sys_t::i_size, stream_sys_t::p_buffer, stream_t::p_input, stream_t::p_sys, stream_t::pf_control, stream_t::pf_read, stream_t::pf_seek, Read(), Seek(), stream_CommonDelete(), and stream_CommonNew().

ssize_t stream_Peek ( stream_t ,
const uint8_t **  ,
size_t   
)

Peeks at data from a byte stream.

This function buffers for the requested number of bytes, waiting if necessary. Then it stores a pointer to the buffer. Unlike stream_Read() or stream_Block(), this function does not modify the stream read offset.

Note
The buffer remains valid until the next read/peek or seek operation on the same stream. In case of error, the buffer address is undefined.
Parameters
bufpstorage space for the buffer address [OUT]
lennumber of bytes to peek
Returns
the number of bytes actually available (shorter than requested if the end-of-stream is reached), or a negative value on error.
ssize_t stream_Read ( stream_t ,
void *  ,
size_t   
)

Reads data from a byte stream.

This function always waits for the requested number of bytes, unless a fatal error is encountered or the end-of-stream is reached first.

If the buffer is NULL, data is skipped instead of read. This is effectively a relative forward seek, but it works even on non-seekable streams.

Parameters
bufstart of buffer to read data into [OUT]
lennumber of bytes to read
Returns
the number of bytes read or a negative value on error.

References block_Release(), block_t::i_buffer, block_t::p_buffer, stream_priv_t::peek, stream_ReadRaw(), and unlikely.

Referenced by DownloadArt(), SkipAPETag(), SkipID3Tag(), stream_Block(), and stream_ReadLine().

int stream_ReadDir ( stream_t s,
input_item_node_t p_node 
)

Returns a node containing all the input_item of the directory pointer by this stream.

returns VLC_SUCCESS on success.

References stream_t::pf_readdir.

Referenced by stream_FilterDefaultReadDir().

char* stream_ReadLine ( stream_t )
int stream_Seek ( stream_t ,
uint64_t  offset 
)

Sets the current stream position.

Parameters
offsetbyte offset from the beginning of the stream
Returns
zero on success, a negative value on error

< No error

< No error

< Unspecified error

< No error

< No error

References block_Release(), block_t::i_buffer, stream_priv_t::offset, block_t::p_buffer, stream_priv_t::peek, stream_t::pf_seek, stream_Tell(), VLC_EGENERIC, and VLC_SUCCESS.

Referenced by demux_vaControlHelper().

static int64_t stream_Size ( stream_t s)
inlinestatic

References stream_GetSize().

Referenced by demux_vaControlHelper().

uint64_t stream_Tell ( const stream_t )

Tells the current stream position.

Returns
the byte offset from the beginning of the stream (cannot fail)

References block_t::i_buffer, stream_priv_t::offset, and stream_priv_t::peek.

Referenced by demux_vaControlHelper(), stream_ReadLine(), and stream_Seek().

stream_t* stream_UrlNew ( vlc_object_t p_this,
const char *  psz_url 
)

Create a stream_t reading from a URL.

You must delete it using stream_Delete.

References msg_Err, and stream_AccessNew().

int stream_vaControl ( stream_t s,
int  cmd,
va_list  args 
)

Use to control the "stream_t *".

Look at stream_query_e for possible "i_query" value and format arguments. Return VLC_SUCCESS if ... succeed ;) and VLC_EGENERIC if failed or unimplemented

< No error

< No error

< No error

References block_Release(), stream_priv_t::offset, stream_priv_t::peek, stream_t::pf_control, stream_ControlInternal(), STREAM_GET_PRIVATE_BLOCK, STREAM_SET_SEEKPOINT, STREAM_SET_TITLE, and VLC_SUCCESS.

Referenced by demux_vaControl(), demux_vaControlHelper(), and stream_Control().