Data Structures | Defines | 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...

Defines

#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 )

Typedefs

typedef struct stream_text_t stream_text_t

Enumerations

enum  stream_query_e {
  STREAM_CAN_SEEK, STREAM_CAN_FASTSEEK, STREAM_SET_POSITION, STREAM_GET_POSITION,
  STREAM_GET_SIZE, STREAM_CONTROL_ACCESS, STREAM_UPDATE_SIZE, STREAM_GET_CONTENT_TYPE,
  STREAM_SET_RECORD_STATE
}
 

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

More...

Functions

VLC_API 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".
VLC_API 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.
VLC_API int stream_vaControl (stream_t *s, int i_query, va_list args)
 Use to control the "stream_t *".
VLC_API void stream_Delete (stream_t *s)
 Destroy a stream.
VLC_API int stream_Control (stream_t *s, int i_query,...)
VLC_API block_tstream_Block (stream_t *s, int i_size)
 Read "i_size" bytes and store them in a block_t.
VLC_API 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.
VLC_API char * stream_ReadLine (stream_t *)
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.
VLC_API 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.
VLC_API void stream_DemuxSend (stream_t *s, block_t *p_block)
 Send data to a stream_t handle created by stream_DemuxNew.
VLC_API 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.
VLC_API stream_tstream_UrlNew (vlc_object_t *p_this, const char *psz_url)
 Create a stream_t reading from a URL.
VLC_API stream_tstream_FilterNew (stream_t *p_source, const char *psz_stream_filter)
 Try to add a stream filter to an open stream.

Detailed Description

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


Define Documentation

#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 )

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_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_CONTROL_ACCESS 
STREAM_UPDATE_SIZE 
STREAM_GET_CONTENT_TYPE 

arg1= char ** res=can fail

STREAM_SET_RECORD_STATE 

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


Function Documentation

VLC_API 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_New, block_Release(), block_t::i_buffer, block_t::p_buffer, and stream_Read().

VLC_API 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 __MIN, block_New, 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  )  [inline, static]

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

Result must be free()'d.

References stream_Control(), and STREAM_GET_CONTENT_TYPE.

VLC_API int stream_Control ( stream_t s,
int  i_query,
  ... 
)
VLC_API void stream_Delete ( stream_t s  ) 
VLC_API stream_t* stream_DemuxNew ( demux_t p_demux,
const char *  psz_demux,
es_out_t out 
)
VLC_API void stream_DemuxSend ( stream_t s,
block_t p_block 
)

Send data to a stream_t handle created by stream_DemuxNew.

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

VLC_API 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(), and VLC_OBJECT.

VLC_API 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_this the calling vlc_object
p_buffer the memory buffer for the stream
i_buffer the size of the buffer
i_preserve_memory if this is set to false the memory buffer pointed to by p_buffer is freed on stream_Destroy

References 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_destroy, stream_t::pf_peek, stream_t::pf_read, stream_t::psz_path, strdup(), stream_CommonDelete(), and stream_CommonNew().

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

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

VLC_API char* stream_ReadLine ( stream_t  ) 
static int stream_Seek ( stream_t s,
uint64_t  i_pos 
) [inline, static]
static int64_t stream_Size ( stream_t s  )  [inline, static]

Get the size of the stream.

References stream_Control(), and STREAM_GET_SIZE.

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

static int64_t stream_Tell ( stream_t s  )  [inline, static]

Get the current position in a stream.

References stream_Control(), and STREAM_GET_POSITION.

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

VLC_API 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 access_Delete(), access_New, input_SplitMRL(), msg_Err, stream_t::pf_destroy, and stream_AccessNew().

VLC_API 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.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines