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

In-memory byte stream are a portable wrapper for in-memory formatted output byte streams. More...

Collaboration diagram for In-memory byte streams:

Data Structures

struct  vlc_memstream
 In-memory stream object. More...
 

Functions

int vlc_memstream_open (struct vlc_memstream *ms)
 Initializes a byte stream object.
 
int vlc_memstream_flush (struct vlc_memstream *ms)
 Flushes a byte stream object.
 
int vlc_memstream_close (struct vlc_memstream *ms)
 Closes a byte stream object.
 
size_t vlc_memstream_write (struct vlc_memstream *ms, const void *ptr, size_t len)
 Appends a binary blob to a byte stream.
 
int vlc_memstream_putc (struct vlc_memstream *ms, int c)
 Appends a single byte to a byte stream.
 
int vlc_memstream_puts (struct vlc_memstream *ms, const char *str)
 Appends a nul-terminated string to a byte stream.
 
int vlc_memstream_vprintf (struct vlc_memstream *ms, const char *fmt, va_list args)
 Appends a formatted string to a byte stream.
 
int vlc_memstream_printf (struct vlc_memstream *s, const char *fmt,...)
 Appends a formatted string to a byte stream.
 

Detailed Description

In-memory byte stream are a portable wrapper for in-memory formatted output byte streams.

Compare with POSIX open_memstream().

Function Documentation

◆ vlc_memstream_close()

int vlc_memstream_close ( struct vlc_memstream ms)

Closes a byte stream object.

This function flushes the stream object, releases any underlying resource, except for the heap-allocated formatted buffer ms->ptr, and deinitializes the object.

On success, the caller is responsible for freeing the buffer with free().

Compare with fclose().

Return values
0success
EOFfailure (ms->ptr and ms->length are unspecified)

References vlc_memstream::error, and vlc_memstream::ptr.

Referenced by EsOutCreateStrId(), mrl_AppendAnchorFragment(), mrl_EscapeFragmentIdentifier(), RunDownloader(), sout_AnnounceRegisterSDP(), StreamExtractorCreateMRL(), vlc_CPU_dump(), vlc_http_msg_format(), vlc_player_input_GetSelectedTrackStringIds(), vlc_player_osd_Tracks(), vlc_spawn_inner(), vlc_strfplayer(), vlc_uri_compose(), vlc_uri_fixup(), vlc_uri_fixup_inner(), and vlc_xml_encode().

◆ vlc_memstream_flush()

int vlc_memstream_flush ( struct vlc_memstream ms)

Flushes a byte stream object.

This function ensures that any previous write to the byte stream is flushed and the in-memory buffer is synchronized. It can be used observe the content of the buffer before the final vlc_memstream_close().

Compare with fflush().

Note
vlc_memstream_close() implicitly flushes the object. Calling vlc_memstream_flush() before closing is thus superfluous.
Warning
ms->ptr must not be freed. It can only be freed after a successful call to vlc_memstream_close().
Return values
0success, i.e., ms->ptr and ms->length are valid
EOFfailure (ms->ptr and ms->length are unspecified)

References vlc_memstream::error.

◆ vlc_memstream_open()

int vlc_memstream_open ( struct vlc_memstream ms)

Initializes a byte stream object.

Note
Even when this function fails, the stream object is initialized and can be used safely. It is sufficient to check for errors from vlc_memstream_flush() and vlc_memstream_close().

Compare with POSIX open_memstream().

Parameters
msbyte stream object
Return values
0on success
EOFon error

References vlc_memstream::error, vlc_memstream::length, vlc_memstream::ptr, and unlikely.

Referenced by EsOutCreateStrId(), mrl_AppendAnchorFragment(), mrl_EscapeFragmentIdentifier(), RunDownloader(), sout_AnnounceRegisterSDP(), StreamExtractorCreateMRL(), vlc_CPU_dump(), vlc_http_msg_format(), vlc_player_input_GetSelectedTrackStringIds(), vlc_player_osd_Tracks(), vlc_spawn_inner(), vlc_strfplayer(), vlc_uri_compose(), vlc_uri_fixup(), vlc_uri_fixup_inner(), and vlc_xml_encode().

◆ vlc_memstream_printf()

int vlc_memstream_printf ( struct vlc_memstream s,
const char *  fmt,
  ... 
)

◆ vlc_memstream_putc()

int vlc_memstream_putc ( struct vlc_memstream ms,
int  c 
)

Appends a single byte to a byte stream.

Compare with putc() or fputc().

Parameters
msthe VLC memstream to write to
cUnsigned byte value converted to int.

References vlc_memstream_write().

Referenced by EsOutCreateStrId(), mrl_AppendAnchorFragment(), sout_AnnounceRegisterSDP(), StreamExtractorCreateMRL(), vlc_player_input_GetSelectedTrackStringIds(), vlc_strfplayer(), vlc_uri_compose(), vlc_uri_fixup(), vlc_uri_fixup_inner(), and vlc_uri_putc().

◆ vlc_memstream_puts()

◆ vlc_memstream_vprintf()

int vlc_memstream_vprintf ( struct vlc_memstream ms,
const char *  fmt,
va_list  args 
)

Appends a formatted string to a byte stream.

Compare with vfprintf().

References vlc_memstream::error, vlc_memstream::length, vlc_memstream::ptr, and unlikely.

Referenced by vlc_memstream_printf().

◆ vlc_memstream_write()

size_t vlc_memstream_write ( struct vlc_memstream ms,
const void *  ptr,
size_t  len 
)

Appends a binary blob to a byte stream.

Compare with fwrite().

Parameters
msthe VLC memstream to write to
ptrstart address of the blob
lenbyte length of the blob

References vlc_memstream::error, vlc_memstream::length, vlc_memstream::ptr, and unlikely.

Referenced by RunDownloader(), sout_AnnounceRegisterSDP(), vlc_memstream_putc(), vlc_memstream_puts(), vlc_uri_compose(), vlc_uri_fixup(), and vlc_xml_encode().