X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fmem_stream.c;h=94c6e517581c1e2cfdf9ccb86a209b033843e91e;hb=7686840e5c2b384eab661455a5e532a97c669e96;hp=ec586dd1e13150185501c8b9f85fde55085ed982;hpb=85b29bdc288a1573d43bd524908be5748a9b3640;p=vlc diff --git a/src/input/mem_stream.c b/src/input/mem_stream.c index ec586dd1e1..94c6e51758 100644 --- a/src/input/mem_stream.c +++ b/src/input/mem_stream.c @@ -1,10 +1,10 @@ /***************************************************************************** * mem_stream.c: stream_t wrapper around memory buffer ***************************************************************************** - * Copyright (C) 1999-2004 VideoLAN (Centrale Réseaux) and its contributors - * $Id: stream.c 9390 2004-11-22 09:56:48Z fenrir $ + * Copyright (C) 1999-2004 the VideoLAN team + * $Id$ * - * Authors: Sigmund Augdal + * Authors: Sigmund Augdal Helberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,18 +18,20 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include "input_internal.h" struct stream_sys_t { - vlc_bool_t i_preserve_memory; + bool i_preserve_memory; int64_t i_pos; /* Current reading offset */ int64_t i_size; uint8_t *p_buffer; @@ -37,7 +39,7 @@ struct stream_sys_t }; static int Read ( stream_t *, void *p_read, int i_read ); -static int Peek ( stream_t *, uint8_t **pp_peek, int i_read ); +static int Peek ( stream_t *, const uint8_t **pp_peek, int i_read ); static int Control( stream_t *, int i_query, va_list ); static void Delete ( stream_t * ); @@ -47,13 +49,13 @@ static void Delete ( stream_t * ); * \param p_this the calling vlc_object * \param p_buffer the memory buffer for the stream * \param i_buffer the size of the buffer - * \param i_preserve_memory if this is set to VLC_FALSE the memory buffer + * \param i_preserve_memory if this is set to false the memory buffer * pointed to by p_buffer is freed on stream_Destroy */ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer, - int64_t i_size, vlc_bool_t i_preserve_memory ) + int64_t i_size, bool i_preserve_memory ) { - stream_t *s = vlc_object_create( p_this, VLC_OBJECT_STREAM ); + stream_t *s = vlc_stream_create( p_this ); stream_sys_t *p_sys; if( !s ) return NULL; @@ -64,11 +66,13 @@ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer, p_sys->p_buffer = p_buffer; p_sys->i_preserve_memory = i_preserve_memory; - s->pf_block = NULL; s->pf_read = Read; s->pf_peek = Peek; s->pf_control = Control; s->pf_destroy = Delete; + + s->i_char_width = 1; + s->b_little_endian = false; vlc_object_attach( s, p_this ); return s; @@ -79,7 +83,7 @@ static void Delete( stream_t *s ) if( !s->p_sys->i_preserve_memory ) free( s->p_sys->p_buffer ); free( s->p_sys ); vlc_object_detach( s ); - vlc_object_destroy( s ); + vlc_object_release( s ); } /**************************************************************************** @@ -89,7 +93,7 @@ static int Control( stream_t *s, int i_query, va_list args ) { stream_sys_t *p_sys = s->p_sys; - vlc_bool_t *p_bool; + bool *p_bool; int64_t *pi_64, i_64; int i_int; @@ -101,13 +105,13 @@ static int Control( stream_t *s, int i_query, va_list args ) break; case STREAM_CAN_SEEK: - p_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); - *p_bool = VLC_TRUE; + p_bool = (bool*)va_arg( args, bool * ); + *p_bool = true; break; case STREAM_CAN_FASTSEEK: - p_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); - *p_bool = VLC_TRUE; + p_bool = (bool*)va_arg( args, bool * ); + *p_bool = true; break; case STREAM_GET_POSITION: @@ -118,11 +122,12 @@ static int Control( stream_t *s, int i_query, va_list args ) case STREAM_SET_POSITION: i_64 = (int64_t)va_arg( args, int64_t ); i_64 = __MAX( i_64, 0 ); - i_64 = __MIN( i_64, s->p_sys->i_size ); + i_64 = __MIN( i_64, s->p_sys->i_size ); p_sys->i_pos = i_64; break; case STREAM_GET_MTU: + case STREAM_GET_CONTENT_TYPE: return VLC_EGENERIC; case STREAM_CONTROL_ACCESS: @@ -147,7 +152,7 @@ static int Read( stream_t *s, void *p_read, int i_read ) return i_res; } -static int Peek( stream_t *s, uint8_t **pp_peek, int i_read ) +static int Peek( stream_t *s, const uint8_t **pp_peek, int i_read ) { stream_sys_t *p_sys = s->p_sys; int i_res = __MIN( i_read, p_sys->i_size - p_sys->i_pos );