VLC 4.0.0-dev
Loading...
Searching...
No Matches

Buffered input byte streams. More...

Collaboration diagram for Stream:

Modules

 Access
 Raw input byte streams.
 
 FIFO stream
 In-memory anonymous pipe.
 

Files

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

Data Structures

struct  vlc_stream_operations
 
struct  stream_t
 stream_t definition More...
 

Macros

#define vlc_stream_MemoryNew(a, b, c, d)    vlc_stream_MemoryNew(VLC_OBJECT(a), b, c, d)
 
#define vlc_stream_NewURL(a, b)   vlc_stream_NewURL(VLC_OBJECT(a), b)
 

Enumerations

enum  stream_query_e {
  STREAM_CAN_SEEK , STREAM_CAN_FASTSEEK , STREAM_CAN_PAUSE , STREAM_CAN_CONTROL_PACE ,
  STREAM_GET_SIZE =6 , STREAM_GET_MTIME , 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_GET_TAGS , STREAM_GET_TYPE , 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 vlc_stream_Control() and vlc_stream_vaControl() More...
 

Functions

ssize_t vlc_stream_Read (stream_t *s, void *buf, size_t len)
 Reads data from a byte stream.
 
ssize_t vlc_stream_ReadPartial (stream_t *s, void *buf, size_t len)
 Reads partial data from a byte stream.
 
ssize_t vlc_stream_Peek (stream_t *s, const uint8_t **bufp, size_t len)
 Peeks at data from a byte stream.
 
block_tvlc_stream_ReadBlock (stream_t *)
 Reads a data block from a byte stream.
 
uint64_t vlc_stream_Tell (const stream_t *)
 Tells the current stream position.
 
bool vlc_stream_Eof (const stream_t *)
 Checks for end of stream.
 
int vlc_stream_Seek (stream_t *s, uint64_t offset)
 Sets the current stream position.
 
int vlc_stream_vaControl (stream_t *s, int query, va_list args)
 Use to control the "stream_t *".
 
static int vlc_stream_Control (stream_t *s, int query,...)
 
block_tvlc_stream_Block (stream_t *s, size_t)
 Read data into a block.
 
char * vlc_stream_ReadLine (stream_t *)
 
int vlc_stream_ReadDir (stream_t *s, input_item_node_t *node)
 Reads a directory.
 
void vlc_stream_Delete (stream_t *s)
 Closes a byte stream.
 
stream_tvlc_stream_CommonNew (vlc_object_t *, void(*)(stream_t *))
 
static bool vlc_stream_CanSeek (stream_t *s)
 
static bool vlc_stream_CanFastSeek (stream_t *s)
 
static bool vlc_stream_CanPause (stream_t *s)
 
static bool vlc_stream_CanPace (stream_t *s)
 
static vlc_tick_t vlc_stream_GetPtsDelay (stream_t *s)
 
static int vlc_stream_GetSeekpoint (stream_t *s, unsigned *seekpoint)
 
static int vlc_stream_GetSignal (stream_t *s, double *quality, double *strength)
 
static int vlc_stream_GetTitle (stream_t *s, unsigned *title)
 
static int vlc_stream_GetMeta (stream_t *s, vlc_meta_t *meta)
 
static int vlc_stream_GetType (stream_t *s, int *type)
 
static int vlc_stream_GetSize (stream_t *s, uint64_t *size)
 Get the size of the stream.
 
static int vlc_stream_GetMTime (stream_t *s, uint64_t *mtime)
 
static int vlc_stream_GetTitleInfo (stream_t *s, input_title_t ***title_info, int *size)
 
static int vlc_stream_GetContentType (stream_t *s, char **content_type)
 
static int vlc_stream_GetTags (stream_t *s, const block_t **tags)
 
static int vlc_stream_GetPrivateIdState (stream_t *s, int priv_id, bool *state)
 
static int vlc_stream_SetPauseState (stream_t *s, bool pause_state)
 
static int vlc_stream_SetSeekPoint (stream_t *s, int seekpoint)
 
static int vlc_stream_SetTitle (stream_t *s, int title)
 
static int vlc_stream_SetRecordState (stream_t *s, bool record_state, const char *dir_path, const char *ext)
 
static int vlc_stream_SetPrivateIdState (stream_t *s, int priv_id, bool state)
 
static int vlc_stream_SetPrivateIdCa (stream_t *s, void *ca)
 Set the private ID ca.
 
static int64_t stream_Size (stream_t *s)
 
static bool stream_HasExtension (stream_t *s, const char *extension)
 
static char * stream_ContentType (stream_t *s)
 Get the Content-Type of a stream, or NULL if unknown.
 
static char * stream_MimeType (stream_t *s)
 Get the mime-type of a stream.
 
static bool stream_IsMimeType (stream_t *s, const char *type)
 Checks for a MIME type.
 
stream_tvlc_stream_MemoryNew (vlc_object_t *obj, uint8_t *base, size_t size, bool preserve)
 Create a stream from a memory buffer.
 
stream_tvlc_stream_NewURL (vlc_object_t *obj, const char *url)
 Create a stream_t reading from a URL.
 
stream_tvlc_stream_FilterNew (stream_t *p_source, const char *psz_stream_filter)
 Try to add a stream filter to an open stream.
 

Detailed Description

Buffered input byte streams.

Macro Definition Documentation

◆ vlc_stream_MemoryNew

#define vlc_stream_MemoryNew (   a,
  b,
  c,
 
)     vlc_stream_MemoryNew(VLC_OBJECT(a), b, c, d)

◆ vlc_stream_NewURL

#define vlc_stream_NewURL (   a,
 
)    vlc_stream_NewURL(VLC_OBJECT(a), b)

Enumeration Type Documentation

◆ stream_query_e

Possible commands to send to vlc_stream_Control() and vlc_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_GET_MTIME 

arg1=(uint64_t *) res=can fail Returns the last modified time in seconds since epoch.

STREAM_GET_PTS_DELAY 

arg1=(vlc_tick_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_GET_TAGS 

arg1=(const block_t **) res=can fail

STREAM_GET_TYPE 

arg1=(int*) 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 *dir_path (if arg1 is true), arg3=const char *psz_ext (if arg1 is true) res=can fail

STREAM_SET_PRIVATE_ID_STATE 

arg1=(int i_private_data) arg2=(bool b_selected) res=can fail

STREAM_SET_PRIVATE_ID_CA 

arg1=(void *)

STREAM_GET_PRIVATE_ID_STATE 

arg1=(int i_private_data) arg2=(bool *) res=can fail

Function Documentation

◆ stream_ContentType()

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

Referenced by stream_MimeType().

◆ stream_HasExtension()

static bool stream_HasExtension ( stream_t s,
const char *  extension 
)
inlinestatic

◆ stream_IsMimeType()

static bool stream_IsMimeType ( stream_t s,
const char *  type 
)
inlinestatic

Checks for a MIME type.

Checks if the stream has a specific MIME type.

References strcasecmp(), and stream_MimeType().

Referenced by demux_IsContentType().

◆ stream_MimeType()

static char * stream_MimeType ( stream_t s)
inlinestatic

Get the mime-type of a stream.

Warning
the returned resource is to be freed by the caller
Returns
the mime-type, or NULL if unknown

References stream_ContentType().

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

◆ stream_Size()

static int64_t stream_Size ( stream_t s)
inlinestatic

References vlc_stream_GetSize().

Referenced by demux_vaControlHelper().

◆ vlc_stream_Block()

block_t * vlc_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, vlc_frame_t::i_buffer, vlc_frame_t::p_buffer, unlikely, and vlc_stream_Read().

Referenced by ImageReadUrl().

◆ vlc_stream_CanFastSeek()

static bool vlc_stream_CanFastSeek ( stream_t s)
inlinestatic

◆ vlc_stream_CanPace()

static bool vlc_stream_CanPace ( stream_t s)
inlinestatic

◆ vlc_stream_CanPause()

static bool vlc_stream_CanPause ( stream_t s)
inlinestatic

◆ vlc_stream_CanSeek()

static bool vlc_stream_CanSeek ( stream_t s)
inlinestatic

◆ vlc_stream_CommonNew()

stream_t * vlc_stream_CommonNew ( vlc_object_t parent,
void(*)(stream_t *)  destroy 
)

References vlc_stream_CustomNew().

Referenced by se_AttachWrapper().

◆ vlc_stream_Control()

◆ vlc_stream_Delete()

◆ vlc_stream_Eof()

bool vlc_stream_Eof ( const stream_t s)

Checks for end of stream.

Checks if the last attempt to reads data from the stream encountered the end of stream before the attempt could be fully satisfied. The value is initially false, and is reset to false by vlc_stream_Seek().

Note
The function can return false even though the current stream position is equal to the stream size. It will return true after the following attempt to read more than zero bytes.
It might be possible to read after the end of the stream. It implies the size of the stream increased asynchronously in the mean time. Streams of most types cannot trigger such a case, but regular local files notably can.
In principles, the stream size should match the stream offset when the end-of-stream is reached. But that rule is not enforced; it is entirely dependent on the underlying implementation of the stream.

References stream_priv_t::eof, and stream_priv.

Referenced by AStreamReadBlock(), and AStreamReadStream().

◆ vlc_stream_FilterNew()

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

◆ vlc_stream_GetContentType()

static int vlc_stream_GetContentType ( stream_t s,
char **  content_type 
)
inlinestatic

◆ vlc_stream_GetMeta()

static int vlc_stream_GetMeta ( stream_t s,
vlc_meta_t meta 
)
inlinestatic

◆ vlc_stream_GetMTime()

static int vlc_stream_GetMTime ( stream_t s,
uint64_t *  mtime 
)
inlinestatic

◆ vlc_stream_GetPrivateIdState()

static int vlc_stream_GetPrivateIdState ( stream_t s,
int  priv_id,
bool *  state 
)
inlinestatic

◆ vlc_stream_GetPtsDelay()

static vlc_tick_t vlc_stream_GetPtsDelay ( stream_t s)
inlinestatic

◆ vlc_stream_GetSeekpoint()

static int vlc_stream_GetSeekpoint ( stream_t s,
unsigned *  seekpoint 
)
inlinestatic

◆ vlc_stream_GetSignal()

static int vlc_stream_GetSignal ( stream_t s,
double *  quality,
double *  strength 
)
inlinestatic

◆ vlc_stream_GetSize()

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

◆ vlc_stream_GetTags()

static int vlc_stream_GetTags ( stream_t s,
const block_t **  tags 
)
inlinestatic

◆ vlc_stream_GetTitle()

static int vlc_stream_GetTitle ( stream_t s,
unsigned *  title 
)
inlinestatic

◆ vlc_stream_GetTitleInfo()

static int vlc_stream_GetTitleInfo ( stream_t s,
input_title_t ***  title_info,
int *  size 
)
inlinestatic

◆ vlc_stream_GetType()

static int vlc_stream_GetType ( stream_t s,
int *  type 
)
inlinestatic

◆ vlc_stream_MemoryNew()

stream_t * vlc_stream_MemoryNew ( vlc_object_t obj,
uint8_t *  base,
size_t  size,
bool  preserve 
)

Create a stream from a memory buffer.

Parameters
objparent VLC object
basestart address of the memory buffer to read from
sizesize in bytes of the memory buffer
preserveif false, free(base) will be called when the stream is destroyed; if true, the memory buffer is preserved

References Control(), vlc_stream_memory_private::i_pos, vlc_stream_memory_private::i_size, vlc_stream_memory_private::p_buffer, stream_t::pf_control, stream_t::pf_read, stream_t::pf_seek, Read(), Seek(), stream_MemoryDelete(), stream_MemoryPreserveDelete(), unlikely, vlc_stream_CustomNew(), and vlc_stream_Private().

◆ vlc_stream_NewURL()

stream_t * vlc_stream_NewURL ( vlc_object_t obj,
const char *  url 
)

Create a stream_t reading from a URL.

You must delete it using vlc_stream_Delete.

References msg_Err, stream_AccessNew(), and stream_FilterAutoNew().

◆ vlc_stream_Peek()

ssize_t vlc_stream_Peek ( stream_t s,
const uint8_t **  bufp,
size_t  len 
)

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 vlc_stream_Read() or vlc_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
sthe stream object to peek from
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.

◆ vlc_stream_Read()

ssize_t vlc_stream_Read ( stream_t s,
void *  buf,
size_t  len 
)

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
sthe stream object to read from
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 vlc_stream_ReadPartial().

Referenced by download_key(), download_signature(), GetUpdateFile(), RunDownloader(), update_DownloadReal(), vlc_stream_Block(), and vlc_stream_ReadLine().

◆ vlc_stream_ReadBlock()

block_t * vlc_stream_ReadBlock ( stream_t s)

Reads a data block from a byte stream.

This function dequeues the next block of data from the byte stream. The byte stream back-end decides on the size of the block; the caller cannot make any assumption about it.

The function might also return NULL spuriously - this does not necessarily imply that the stream is ended nor that it has encountered a nonrecoverable error.

This function should be used instead of vlc_stream_Read() or vlc_stream_Peek() when the caller can handle reads of any size.

Returns
either a data block or NULL

References vlc_stream_operations::block, stream_priv_t::block, block_Alloc, block_Release, stream_priv_t::eof, vlc_frame_t::i_buffer, stream_priv_t::offset, stream_t::ops, vlc_frame_t::p_buffer, stream_priv_t::peek, stream_t::pf_block, stream_t::pf_read, vlc_stream_operations::read, vlc_stream_operations::stream, stream_priv, unlikely, and vlc_killed().

Referenced by AStreamReadBlock().

◆ vlc_stream_ReadDir()

int vlc_stream_ReadDir ( stream_t s,
input_item_node_t node 
)

Reads a directory.

This function fills an input item node with any and all the items within a directory. The behaviour is undefined if the stream is not a directory.

Parameters
sdirectory object to read from
nodenode to store the items into
Returns
VLC_SUCCESS on success

References stream_t::ops, stream_t::pf_readdir, vlc_stream_operations::readdir, and vlc_stream_operations::stream.

◆ vlc_stream_ReadLine()

◆ vlc_stream_ReadPartial()

ssize_t vlc_stream_ReadPartial ( stream_t s,
void *  buf,
size_t  len 
)

Reads partial data from a byte stream.

This function waits until some data is available for reading from the stream, a fatal error is encountered or the end-of-stream is reached.

Unlike vlc_stream_Read(), this function does not wait for the full requested bytes count. It can return a short count even before the end of the stream and in the absence of any error.

Parameters
sthe stream object to read from
bufstart of buffer to read data into [OUT]
lenbuffer size (maximum number of bytes to read)
Returns
the number of bytes read, 0 on end of stream or -1 if no data available

References stream_priv_t::eof, stream_priv_t::offset, stream_priv_t::peek, stream_priv, vlc_stream_CopyBlock(), and vlc_stream_ReadRaw().

Referenced by AStreamReadStream(), and vlc_stream_Read().

◆ vlc_stream_Seek()

int vlc_stream_Seek ( stream_t s,
uint64_t  offset 
)

Sets the current stream position.

This function changes the read offset within a stream, if the stream supports seeking. In case of error, the read offset is not changed.

Note
It is possible (but not useful) to seek past the end of a stream.
Parameters
sthe stream object to seek from
offsetbyte offset from the beginning of the stream
Returns
zero on success, a negative value on error

References stream_priv_t::block, block_Release, stream_priv_t::eof, vlc_frame_t::i_buffer, stream_priv_t::offset, stream_t::ops, vlc_frame_t::p_buffer, stream_priv_t::peek, stream_t::pf_seek, vlc_stream_operations::seek, vlc_stream_operations::stream, stream_priv, VLC_EGENERIC, and VLC_SUCCESS.

Referenced by AStreamSeek(), demux_Probe(), and demux_vaControlHelper().

◆ vlc_stream_SetPauseState()

static int vlc_stream_SetPauseState ( stream_t s,
bool  pause_state 
)
inlinestatic

◆ vlc_stream_SetPrivateIdCa()

static int vlc_stream_SetPrivateIdCa ( stream_t s,
void *  ca 
)
inlinestatic

Set the private ID ca.

The ca arg is of type en50221_capmt_info_t.

References STREAM_SET_PRIVATE_ID_CA, and vlc_stream_Control().

◆ vlc_stream_SetPrivateIdState()

static int vlc_stream_SetPrivateIdState ( stream_t s,
int  priv_id,
bool  state 
)
inlinestatic

◆ vlc_stream_SetRecordState()

static int vlc_stream_SetRecordState ( stream_t s,
bool  record_state,
const char *  dir_path,
const char *  ext 
)
inlinestatic

◆ vlc_stream_SetSeekPoint()

static int vlc_stream_SetSeekPoint ( stream_t s,
int  seekpoint 
)
inlinestatic

◆ vlc_stream_SetTitle()

static int vlc_stream_SetTitle ( stream_t s,
int  title 
)
inlinestatic

◆ vlc_stream_Tell()

uint64_t vlc_stream_Tell ( const stream_t s)

Tells the current stream position.

This function tells the current read offset (in bytes) from the start of the start of the stream.

Note
The read offset may be larger than the stream size, either because of a seek past the end, or because the stream shrank asynchronously.
Returns
the byte offset from the beginning of the stream (cannot fail)

References stream_priv_t::offset, and stream_priv.

Referenced by demux_Probe(), demux_vaControlHelper(), and vlc_stream_ReadLine().

◆ vlc_stream_vaControl()

int vlc_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

References stream_priv_t::block, block_Release, vlc_stream_operations::can_control_pace, vlc_stream_operations::can_fastseek, vlc_stream_operations::can_pause, vlc_stream_operations::can_seek, DEFAULT_PTS_DELAY, vlc_stream_operations::get_content_type, vlc_stream_operations::get_meta, vlc_stream_operations::get_mtime, vlc_stream_operations::get_private_id_state, vlc_stream_operations::get_pts_delay, vlc_stream_operations::get_seekpoint, vlc_stream_operations::get_signal, vlc_stream_operations::get_size, vlc_stream_operations::get_tags, vlc_stream_operations::get_title, vlc_stream_operations::get_title_info, vlc_stream_operations::get_type, stream_priv_t::offset, stream_t::ops, stream_priv_t::peek, stream_t::pf_control, vlc_stream_operations::set_pause_state, vlc_stream_operations::set_private_id_ca, vlc_stream_operations::set_private_id_state, vlc_stream_operations::set_record_state, vlc_stream_operations::set_seek_point, vlc_stream_operations::set_title, vlc_stream_operations::stream, STREAM_CAN_CONTROL_PACE, STREAM_CAN_FASTSEEK, STREAM_CAN_PAUSE, STREAM_CAN_SEEK, STREAM_GET_CONTENT_TYPE, STREAM_GET_META, STREAM_GET_MTIME, STREAM_GET_PRIVATE_ID_STATE, STREAM_GET_PTS_DELAY, STREAM_GET_SEEKPOINT, STREAM_GET_SIGNAL, STREAM_GET_SIZE, STREAM_GET_TAGS, STREAM_GET_TITLE, STREAM_GET_TITLE_INFO, STREAM_GET_TYPE, stream_priv, STREAM_SET_PAUSE_STATE, STREAM_SET_PRIVATE_ID_CA, STREAM_SET_PRIVATE_ID_STATE, STREAM_SET_RECORD_STATE, STREAM_SET_SEEKPOINT, STREAM_SET_TITLE, vlc_assert_unreachable, VLC_EGENERIC, and VLC_SUCCESS.

Referenced by AStreamControl(), demux_vaControlHelper(), and vlc_stream_Control().