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

This will allow you to easily handle read/seek in demuxer modules. More...

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.

Typedefs

typedef struct stream_text_t stream_text_t

Enumerations

enum  stream_query_e {
  STREAM_CAN_SEEK, STREAM_CAN_FASTSEEK, STREAM_CAN_PAUSE, STREAM_CAN_CONTROL_PACE,
  STREAM_IS_DIRECTORY, STREAM_SET_POSITION, STREAM_GET_POSITION, STREAM_GET_SIZE,
  STREAM_UPDATE_SIZE, 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
}
 Possible commands to send to stream_Control() and stream_vaControl() More...

Functions

int stream_Read (stream_t *s, void *p_read, int i_read)
 Try to read "i_read" bytes into a buffer pointed by "p_read".
int stream_Peek (stream_t *s, const uint8_t **pp_peek, int i_peek)
 Store in pp_peek a pointer to the next "i_peek" bytes in the stream.
int stream_vaControl (stream_t *s, int i_query, va_list args)
 Use to control the "stream_t *".
void stream_Delete (stream_t *s)
 Destroy a stream.
int stream_Control (stream_t *s, int i_query,...)
block_tstream_Block (stream_t *s, int i_size)
 Read "i_size" bytes and store them in a block_t.
block_tstream_BlockRemaining (stream_t *s, int i_max_size)
 Read the remaining of the data if there is less than i_max_size bytes, otherwise return NULL.
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.
static int64_t stream_Tell (stream_t *s)
 Get the current position in a stream.
static int64_t stream_Size (stream_t *s)
 Get the size of the stream.
static int stream_Seek (stream_t *s, uint64_t i_pos)
static char * stream_ContentType (stream_t *s)
 Get the Content-Type of a stream, or NULL if unknown.
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.
void stream_DemuxSend (stream_t *s, block_t *p_block)
 Send data to a stream handle created by stream_DemuxNew().
int stream_DemuxControlVa (stream_t *s, int, va_list)
 Perform a demux (i.e.
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.
stream_tstream_UrlNew (vlc_object_t *p_this, const char *psz_url)
 Create a stream_t reading from a URL.
stream_tstream_FilterNew (stream_t *p_source, const char *psz_stream_filter)
 Try to add a stream filter to an open stream.
int stream_FilterDefaultReadDir (stream_t *s, input_item_node_t *p_node)
 Default ReadDir implementation for stream Filter.

Detailed Description

This will allow you to easily handle read/seek in demuxer modules.

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().

Typedef Documentation

typedef struct stream_text_t stream_text_t

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_IS_DIRECTORY 

arg1= bool * res=cannot fail

STREAM_SET_POSITION 

arg1= uint64_t res=can fail

STREAM_GET_POSITION 

arg1= uint64_t * res=cannot fail

STREAM_GET_SIZE 

arg1= uint64_t * res=cannot fail (0 if no sense)

STREAM_UPDATE_SIZE 
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 

Function Documentation

block_t* stream_Block ( stream_t s,
int  i_size 
)

Read "i_size" bytes and store them in a block_t.

It always read i_size bytes unless you are at the end of the stream where it return what is available.

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

block_t* stream_BlockRemaining ( stream_t s,
int  i_max_size 
)

Read the remaining of the data if there is less than i_max_size bytes, otherwise return NULL.

The stream position is unknown after the call.

References block_Alloc(), block_Realloc(), block_t::i_buffer, msg_Err, block_t::p_buffer, stream_Read(), stream_Size(), and stream_Tell().

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.

int stream_Control ( stream_t s,
int  i_query,
  ... 
)
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_source, stream_t::pf_destroy, stream_t::psz_access, stream_t::psz_path, strdup(), stream_CommonDelete(), stream_CommonNew(), StreamDelete(), and VLC_OBJECT.

stream_t* stream_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.

You must delete it using stream_Delete.

int stream_Peek ( stream_t s,
const uint8_t **  pp_peek,
int  i_peek 
)

Store in pp_peek a pointer to the next "i_peek" bytes in the stream.

Returns
The real number of valid bytes. If it's less or equal to 0, pp_peek is invalid.
Note
pp_peek is a pointer to internal buffer and it will be invalid as soons as other stream_ functions are called.
Contrary to stream_Read, stream_Peek doesn't modify the stream position, and doesn't necessarily involve copying of data. It's mainly used by the modules to quickly probe the (head of the) stream.
Due to input limitation, the return value could be less than i_peek without meaning the end of the stream (but only when you have i_peek >= p_input->i_bufsize)

References stream_t::pf_peek.

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

int stream_Read ( stream_t s,
void *  p_read,
int  i_read 
)

Try to read "i_read" bytes into a buffer pointed by "p_read".

If "p_read" is NULL then data are skipped instead of read.

Returns
The real number of bytes read/skip. If this value is less than i_read that means that it's the end of the stream.
Note
stream_Read increments the stream position, and when p_read is NULL, this is its only task.

References stream_t::pf_read.

Referenced by DownloadArt(), ImageReadUrl(), SkipAPETag(), SkipID3Tag(), stream_Block(), stream_BlockRemaining(), 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 )
static int stream_Seek ( stream_t s,
uint64_t  i_pos 
)
inlinestatic
static int64_t stream_Size ( stream_t s)
inlinestatic

Get the size of the stream.

References stream_Control(), and STREAM_GET_SIZE.

Referenced by demux_vaControlHelper(), ImageReadUrl(), and stream_BlockRemaining().

static int64_t stream_Tell ( stream_t s)
inlinestatic

Get the current position in a stream.

References stream_Control(), and STREAM_GET_POSITION.

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

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.

int stream_vaControl ( stream_t s,
int  i_query,
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

References stream_t::pf_control.

Referenced by demux_vaControlHelper().