Skip to content

Commit

Permalink
stream: stream_ -> vlc_stream_
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Jul 21, 2016
1 parent 9e8c9e9 commit 312d198
Show file tree
Hide file tree
Showing 135 changed files with 1,208 additions and 1,152 deletions.
5 changes: 3 additions & 2 deletions include/vlc_demux.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,15 @@ static inline void demux_UpdateTitleFromStream( demux_t *demux )
stream_t *s = demux->s;
unsigned title, seekpoint;

if( stream_Control( s, STREAM_GET_TITLE, &title ) == VLC_SUCCESS
if( vlc_stream_Control( s, STREAM_GET_TITLE, &title ) == VLC_SUCCESS
&& title != (unsigned)demux->info.i_title )
{
demux->info.i_title = title;
demux->info.i_update |= INPUT_UPDATE_TITLE;
}

if( stream_Control( s, STREAM_GET_SEEKPOINT, &seekpoint ) == VLC_SUCCESS
if( vlc_stream_Control( s, STREAM_GET_SEEKPOINT,
&seekpoint ) == VLC_SUCCESS
&& seekpoint != (unsigned)demux->info.i_seekpoint )
{
demux->info.i_seekpoint = seekpoint;
Expand Down
97 changes: 59 additions & 38 deletions include/vlc_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct stream_t
};

/**
* Possible commands to send to stream_Control() and stream_vaControl()
* Possible commands to send to vlc_stream_Control() and vlc_stream_vaControl()
*/
enum stream_query_e
{
Expand All @@ -154,7 +154,7 @@ enum stream_query_e
STREAM_SET_TITLE, /**< arg1= int res=can fail */
STREAM_SET_SEEKPOINT, /**< arg1= int res=can fail */

/* XXX only data read through stream_Read/Block will be recorded */
/* XXX only data read through vlc_stream_Read/Block will be recorded */
STREAM_SET_RECORD_STATE, /**< arg1=bool, arg2=const char *psz_ext (if arg1 is true) res=can fail */

STREAM_SET_PRIVATE_ID_STATE = 0x1000, /* arg1= int i_private_data, bool b_selected res=can fail */
Expand All @@ -175,14 +175,14 @@ enum stream_query_e
* \param len number of bytes to read
* \return the number of bytes read or a negative value on error.
*/
VLC_API ssize_t stream_Read(stream_t *, void *, size_t) VLC_USED;
VLC_API ssize_t vlc_stream_Read(stream_t *, void *buf, size_t len) VLC_USED;

/**
* 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.
* 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
Expand All @@ -193,7 +193,7 @@ VLC_API ssize_t stream_Read(stream_t *, void *, size_t) VLC_USED;
* \return the number of bytes actually available (shorter than requested if
* the end-of-stream is reached), or a negative value on error.
*/
VLC_API ssize_t stream_Peek(stream_t *, const uint8_t **, size_t) VLC_USED;
VLC_API ssize_t vlc_stream_Peek(stream_t *, const uint8_t **, size_t) VLC_USED;

/**
* Reads a data block from a byte stream.
Expand All @@ -206,26 +206,26 @@ VLC_API ssize_t stream_Peek(stream_t *, const uint8_t **, size_t) VLC_USED;
* imply that the stream is ended nor that it has encountered a nonrecoverable
* error.
*
* This function should be used instead of stream_Read() or stream_Peek() when
* the caller can handle reads of any size.
* This function should be used instead of vlc_stream_Read() or
* vlc_stream_Peek() when the caller can handle reads of any size.
*
* \return either a data block or NULL
*/
VLC_API block_t *stream_ReadBlock(stream_t *) VLC_USED;
VLC_API block_t *vlc_stream_ReadBlock(stream_t *) VLC_USED;

/**
* Tells the current stream position.
*
* @return the byte offset from the beginning of the stream (cannot fail)
*/
VLC_API uint64_t stream_Tell(const stream_t *) VLC_USED;
VLC_API uint64_t vlc_stream_Tell(const stream_t *) VLC_USED;

/**
* 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 stream_Seek().
* 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
Expand All @@ -240,38 +240,54 @@ VLC_API uint64_t stream_Tell(const stream_t *) VLC_USED;
* the end-of-stream is reached. But that rule is not enforced; it is entirely
* dependent on the underlying implementation of the stream.
*/
VLC_API bool stream_Eof(const stream_t *) VLC_USED;
VLC_API bool vlc_stream_Eof(const stream_t *) VLC_USED;

/**
* Sets the current stream position.
*
* @param offset byte offset from the beginning of the stream
* @return zero on success, a negative value on error
*/
VLC_API int stream_Seek(stream_t *, uint64_t offset) VLC_USED;
VLC_API int vlc_stream_Seek(stream_t *, uint64_t offset) VLC_USED;

VLC_API int stream_vaControl( stream_t *s, int i_query, va_list args );
VLC_API void stream_Delete( stream_t *s );
VLC_API int stream_Control( stream_t *s, int i_query, ... );
VLC_API block_t * stream_Block( stream_t *s, size_t );
VLC_API char * stream_ReadLine( stream_t * );
VLC_API int stream_ReadDir( stream_t *, input_item_node_t * );
VLC_API int vlc_stream_vaControl(stream_t *s, int query, va_list args);

VLC_API stream_t *stream_CommonNew(vlc_object_t *, void (*)(stream_t *));
static inline int vlc_stream_Control(stream_t *s, int query, ...)
{
va_list ap;
int ret;

va_start(ap, query);
ret = vlc_stream_vaControl(s, query, ap);
va_end(ap);
return ret;
}

VLC_API block_t *vlc_stream_Block(stream_t *s, size_t);
VLC_API char *vlc_stream_ReadLine(stream_t *);
VLC_API int vlc_stream_ReadDir(stream_t *, input_item_node_t *);

/**
* Closes a byte stream.
* \param s byte stream to close
*/
VLC_API void vlc_stream_Delete(stream_t *s);

VLC_API stream_t *vlc_stream_CommonNew(vlc_object_t *, void (*)(stream_t *));

/**
* Get the size of the stream.
*/
VLC_USED static inline int stream_GetSize( stream_t *s, uint64_t *size )
VLC_USED static inline int vlc_stream_GetSize( stream_t *s, uint64_t *size )
{
return stream_Control( s, STREAM_GET_SIZE, size );
return vlc_stream_Control( s, STREAM_GET_SIZE, size );
}

static inline int64_t stream_Size( stream_t *s )
{
uint64_t i_pos;

if( stream_GetSize( s, &i_pos ) )
if( vlc_stream_GetSize( s, &i_pos ) )
return 0;
if( i_pos >> 62 )
return (int64_t)1 << 62;
Expand All @@ -285,7 +301,7 @@ static inline int64_t stream_Size( stream_t *s )
static inline char *stream_ContentType( stream_t *s )
{
char *res;
if( stream_Control( s, STREAM_GET_CONTENT_TYPE, &res ) )
if( vlc_stream_Control( s, STREAM_GET_CONTENT_TYPE, &res ) )
return NULL;
return res;
}
Expand All @@ -299,17 +315,18 @@ static inline char *stream_ContentType( stream_t *s )
* \param preserve if false, free(base) will be called when the stream is
* destroyed; if true, the memory buffer is preserved
*/
VLC_API stream_t *stream_MemoryNew(vlc_object_t *obj, uint8_t *base,
size_t size, bool preserve) VLC_USED;
#define stream_MemoryNew(a, b, c, d) \
stream_MemoryNew(VLC_OBJECT(a), b, c, d)
VLC_API stream_t *vlc_stream_MemoryNew(vlc_object_t *obj, uint8_t *base,
size_t size, bool preserve) VLC_USED;
#define vlc_stream_MemoryNew(a, b, c, d) \
vlc_stream_MemoryNew(VLC_OBJECT(a), b, c, d)

/**
* Create a stream_t reading from a URL.
* You must delete it using stream_Delete.
* You must delete it using vlc_stream_Delete.
*/
VLC_API stream_t * stream_UrlNew(vlc_object_t *p_this, const char *psz_url );
#define stream_UrlNew( a, b ) stream_UrlNew( VLC_OBJECT(a), b )
VLC_API stream_t * vlc_stream_NewMRL(vlc_object_t *obj, const char *url)
VLC_USED;
#define vlc_stream_NewMRL(a, b) vlc_stream_NewMRL(VLC_OBJECT(a), b)

/**
* \defgroup stream_fifo FIFO stream
Expand All @@ -325,10 +342,10 @@ VLC_API stream_t * stream_UrlNew(vlc_object_t *p_this, const char *psz_url );
* anonymous pipe/FIFO.
*
* On the reader side, the normal stream functions are used,
* e.g. stream_Read() and stream_Delete().
* e.g. vlc_stream_Read() and vlc_stream_Delete().
*
* The created stream object is automatically destroyed when both the reader
* and the writer sides have been closed, with stream_Delete() and
* and the writer sides have been closed, with vlc_stream_Delete() and
* vlc_stream_fifo_Close() respectively.
*
* \param parent parent VLC object for the stream
Expand Down Expand Up @@ -377,19 +394,23 @@ VLC_API void vlc_stream_fifo_Close(stream_t *s);
* Try to add a stream filter to an open stream.
* @return New stream to use, or NULL if the filter could not be added.
**/
VLC_API stream_t* stream_FilterNew( stream_t *p_source, const char *psz_stream_filter );
VLC_API stream_t* vlc_stream_FilterNew( stream_t *p_source, const char *psz_stream_filter );

/**
* Default ReadDir implementation for stream Filter. This implementation just
* forward the pf_readdir call to the p_source stream.
*/
VLC_API int stream_FilterDefaultReadDir( stream_t *s, input_item_node_t *p_node );
VLC_API int vlc_stream_FilterDefaultReadDir(stream_t *s,
input_item_node_t *p_node);

/**
* Sets stream_FilterDefaultReadDir as the pf_readdir callback for this stream filter
* Sets vlc_stream_FilterDefaultReadDir as the pf_readdir callback for this
* stream filter.
*/
#define stream_FilterSetDefaultReadDir(p_stream) \
p_stream->pf_readdir = stream_FilterDefaultReadDir;
#define stream_FilterSetDefaultReadDir(stream) \
do { \
(stream)->pf_readdir = vlc_stream_FilterDefaultReadDir; \
} while (0)

/**
* @}
Expand Down
33 changes: 17 additions & 16 deletions modules/access/archive/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ static int FindVolumes(access_t *p_access, struct archive *p_archive, const char
/* Probe URI */
int i_savedflags = p_access->obj.flags;
p_access->obj.flags |= OBJECT_FLAGS_NOINTERACT;
stream_t *p_stream = stream_UrlNew(p_access, psz_newuri);
stream_t *p_stream = vlc_stream_NewMRL(p_access, psz_newuri);
p_access->obj.flags = i_savedflags;
if (p_stream)
{
ppsz_files[*pi_files] = psz_newuri;
(*pi_files)++;
stream_Delete(p_stream);
vlc_stream_Delete(p_stream);
}
else
{
Expand All @@ -150,7 +150,7 @@ static ssize_t ReadCallback(struct archive *p_archive, void *p_object, const voi
access_sys_t *p_sys = p_data->p_access->p_sys;

*pp_buffer = &p_sys->buffer;
return stream_Read(p_sys->p_stream, &p_sys->buffer, ARCHIVE_READ_SIZE);
return vlc_stream_Read(p_sys->p_stream, &p_sys->buffer, ARCHIVE_READ_SIZE);
}

static ssize_t SkipCallback(struct archive *p_archive, void *p_object, ssize_t i_request)
Expand All @@ -163,15 +163,15 @@ static ssize_t SkipCallback(struct archive *p_archive, void *p_object, ssize_t i
/* be smart as small seeks converts to reads */
if (p_sys->b_source_canseek)
{
int64_t i_pos = stream_Tell(p_sys->p_stream);
int64_t i_pos = vlc_stream_Tell(p_sys->p_stream);
if (i_pos >=0)
stream_Seek(p_sys->p_stream, i_pos + i_request);
i_skipped = stream_Tell(p_sys->p_stream) - i_pos;
vlc_stream_Seek(p_sys->p_stream, i_pos + i_request);
i_skipped = vlc_stream_Tell(p_sys->p_stream) - i_pos;
}
else while(i_request)
{
int i_skip = __MIN(INT32_MAX, i_request);
int i_read = stream_Read(p_sys->p_stream, NULL, i_skip);
int i_read = vlc_stream_Read(p_sys->p_stream, NULL, i_skip);
if (i_read > 0)
i_skipped += i_read;
else
Expand All @@ -193,7 +193,7 @@ static ssize_t SeekCallback(struct archive *p_archive, void *p_object, ssize_t i
switch(i_whence)
{
case SEEK_CUR:
i_pos = stream_Tell(p_sys->p_stream);
i_pos = vlc_stream_Tell(p_sys->p_stream);
break;
case SEEK_SET:
i_pos = 0;
Expand All @@ -208,8 +208,8 @@ static ssize_t SeekCallback(struct archive *p_archive, void *p_object, ssize_t i
if (i_pos < 0)
return -1;

stream_Seek(p_sys->p_stream, i_pos + i_offset); /* We don't care about return val */
return stream_Tell(p_sys->p_stream);
vlc_stream_Seek(p_sys->p_stream, i_pos + i_offset); /* We don't care about return val */
return vlc_stream_Tell(p_sys->p_stream);
}

static int SwitchCallback(struct archive *p_archive, void *p_object, void *p_object2)
Expand All @@ -220,8 +220,8 @@ static int SwitchCallback(struct archive *p_archive, void *p_object, void *p_obj
access_sys_t *p_sys = p_data->p_access->p_sys;

msg_Dbg(p_data->p_access, "opening next volume %s", p_nextdata->psz_uri);
stream_Delete(p_sys->p_stream);
p_sys->p_stream = stream_UrlNew(p_nextdata->p_access, p_nextdata->psz_uri);
vlc_stream_Delete(p_sys->p_stream);
p_sys->p_stream = vlc_stream_NewMRL(p_nextdata->p_access, p_nextdata->psz_uri);
return p_sys->p_stream ? ARCHIVE_OK : ARCHIVE_FATAL;
}

Expand All @@ -231,12 +231,13 @@ static int OpenCallback(struct archive *p_archive, void *p_object)
callback_data_t *p_data = (callback_data_t *) p_object;
access_sys_t *p_sys = p_data->p_access->p_sys;

p_sys->p_stream = stream_UrlNew( p_data->p_access, p_data->psz_uri );
p_sys->p_stream = vlc_stream_NewMRL( p_data->p_access, p_data->psz_uri );
if(!p_sys->p_stream)
return ARCHIVE_FATAL;

/* Seek callback must only be set if calls are guaranteed to succeed */
stream_Control(p_sys->p_stream, STREAM_CAN_SEEK, &p_sys->b_source_canseek);
vlc_stream_Control(p_sys->p_stream, STREAM_CAN_SEEK,
&p_sys->b_source_canseek);
if(p_sys->b_source_canseek)
archive_read_set_seek_callback(p_sys->p_archive, SeekCallback);

Expand All @@ -251,7 +252,7 @@ static int CloseCallback(struct archive *p_archive, void *p_object)

if (p_sys->p_stream)
{
stream_Delete(p_sys->p_stream);
vlc_stream_Delete(p_sys->p_stream);
p_sys->p_stream = NULL;
}

Expand All @@ -276,7 +277,7 @@ static int Control(access_t *p_access, int i_query, va_list args)
break;
}
else
return stream_vaControl( p_sys->p_stream, i_query, args );
return vlc_stream_vaControl( p_sys->p_stream, i_query, args );

case STREAM_SET_PAUSE_STATE:
break;
Expand Down
2 changes: 1 addition & 1 deletion modules/access/archive/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool ProbeArchiveFormat(stream_t *p_stream)
};

const uint8_t *p_peek;
int i_peek = stream_Peek(p_stream, &p_peek, magicbytes[0].i_offset + magicbytes[0].i_length);
int i_peek = vlc_stream_Peek(p_stream, &p_peek, magicbytes[0].i_offset + magicbytes[0].i_length);

for(int i=0; i<9;i++)
{
Expand Down
Loading

0 comments on commit 312d198

Please sign in to comment.