Changeset 2d16a4083986d2676d638fc2d64f9561e555b6f9

Show
Ignore:
Timestamp:
01/04/05 20:37:31 (4 years ago)
Author:
Sigmund Augdal Helberg <sigmunau@videolan.org>
git-committer:
Sigmund Augdal Helberg <sigmunau@videolan.org> 1112380651 +0000
git-parent:

[5af605efe1cdeb21ffb33bd209a6e81df73573c2]

git-author:
Sigmund Augdal Helberg <sigmunau@videolan.org> 1112380651 +0000
Message:

added a stream_UrlNew to open a general purpos stream_t from a url.
added a pf_destroy to stream_t, changed all various stream_FooDestroy to
stream_Delete

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_stream.h

    refc525b r2d16a40  
    6666    int      (*pf_peek)   ( stream_t *, uint8_t **pp_peek, int i_peek ); 
    6767    int      (*pf_control)( stream_t *, int i_query, va_list ); 
     68    void     (*pf_destroy)( stream_t *); 
    6869 
    6970    stream_sys_t *p_sys; 
     
    105106    return s->pf_control( s, i_query, args ); 
    106107} 
     108 
     109/** 
     110 * Destroy a stream 
     111 */ 
     112static inline void stream_Delete( stream_t *s ) 
     113{ 
     114    s->pf_destroy( s ); 
     115} 
     116 
    107117static inline int stream_Control( stream_t *s, int i_query, ... ) 
    108118{ 
     
    115125    return i_result; 
    116126} 
     127 
     128/** 
     129 * Get the current position in a stream 
     130 */ 
    117131static inline int64_t stream_Tell( stream_t *s ) 
    118132{ 
     
    121135    return i_pos; 
    122136} 
     137 
     138/** 
     139 * Get the size of the stream. 
     140 */ 
    123141static inline int64_t stream_Size( stream_t *s ) 
    124142{ 
     
    177195VLC_EXPORT( void,      stream_DemuxSend,  ( stream_t *s, block_t *p_block ) ); 
    178196VLC_EXPORT( void,      stream_DemuxDelete,( stream_t *s ) ); 
    179 #define stream_MemoryNew( a, b, c ) __stream_MemoryNew( VLC_OBJECT(a), b, c ) 
    180 VLC_EXPORT( stream_t *,__stream_MemoryNew, (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size ) ); 
    181 VLC_EXPORT( void,      stream_MemoryDelete,( stream_t *s, vlc_bool_t b_free_buffer ) ); 
     197 
     198 
     199#define stream_MemoryNew( a, b, c, d ) __stream_MemoryNew( VLC_OBJECT(a), b, c, d ) 
     200VLC_EXPORT( stream_t *,__stream_MemoryNew, (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory ) ); 
     201#define stream_UrlNew( a, b ) __stream_UrlNew( VLC_OBJECT(a), b ) 
     202VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, char *psz_url ) ); 
     203 
    182204/** 
    183205 * @} 
  • modules/demux/mkv.cpp

    r792697d r2d16a40  
    13351335            stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer), 
    13361336                                                       tk->p_extra_data, 
    1337                                                        tk->i_extra_data ); 
     1337                                                       tk->i_extra_data, 
     1338                                                       VLC_FALSE ); 
    13381339            MP4_ReadBoxCommon( p_mp4_stream, p_box ); 
    13391340            MP4_ReadBox_sample_vide( p_mp4_stream, p_box ); 
     
    13451346            memcpy( tk->fmt.p_extra, p_box->data.p_sample_vide->p_qt_image_description, tk->fmt.i_extra ); 
    13461347            MP4_FreeBox_sample_vide( p_box ); 
    1347             stream_MemoryDelete( p_mp4_stream, VLC_TRUE ); 
     1348            stream_Delete( p_mp4_stream ); 
    13481349        } 
    13491350        else if( !strcmp( tk->psz_codec, "A_MS/ACM" ) ) 
  • modules/demux/mp4/libmp4.c

    rb20696d r2d16a40  
    18531853    p_stream_memory = 
    18541854        stream_MemoryNew( VLC_OBJECT(p_stream), p_cmvd->data.p_cmvd->p_data, 
    1855                           p_cmvd->data.p_cmvd->i_uncompressed_size ); 
     1855                          p_cmvd->data.p_cmvd->i_uncompressed_size, VLC_TRUE ); 
    18561856 
    18571857    /* and read uncompressd moov */ 
    18581858    p_box->data.p_cmov->p_moov = MP4_ReadBox( p_stream_memory, NULL ); 
    18591859 
    1860     stream_MemoryDelete( p_stream_memory, VLC_FALSE ); 
     1860    stream_Delete( p_stream_memory ); 
    18611861 
    18621862#ifdef MP4_VERBOSE 
  • src/input/input.c

    r2ecc8ed r2d16a40  
    6363 
    6464static void DecodeUrl( char * ); 
    65 static void MRLSplit( input_thread_t *, char *, char **, char **, char ** ); 
    6665static void MRLSections( input_thread_t *, char *, int *, int *, int *, int *); 
    6766 
     
    21152114 
    21162115    if( in->p_stream ) 
    2117         stream_AccessDelete( in->p_stream ); 
     2116        stream_Delete( in->p_stream ); 
    21182117 
    21192118    if( in->p_access ) 
     
    21332132 
    21342133    if( in->p_stream ) 
    2135         stream_AccessDelete( in->p_stream ); 
     2134        stream_Delete( in->p_stream ); 
    21362135 
    21372136    if( in->p_access ) 
     
    23942393 *           Media Resource Locator. 
    23952394 *****************************************************************************/ 
    2396 static void MRLSplit( input_thread_t *p_input, char *psz_dup, 
    2397                       char **ppsz_access, char **ppsz_demux, char **ppsz_path ) 
     2395void MRLSplit( vlc_object_t *p_input, char *psz_dup, 
     2396               char **ppsz_access, char **ppsz_demux, char **ppsz_path ) 
    23982397{ 
    23992398    char *psz_access = NULL; 
  • src/input/input_internal.h

    r70ee5fb r2d16a40  
    153153/* Subtitles */ 
    154154char **subtitles_Detect( input_thread_t *, char* path, char *fname ); 
     155void MRLSplit( vlc_object_t *, char *, char **, char **, char ** ); 
    155156 
    156157#endif 
  • src/input/mem_stream.c

    rf992190 r2d16a40  
    3030struct stream_sys_t 
    3131{ 
     32    vlc_bool_t  i_preserve_memory; 
    3233    int64_t     i_pos;      /* Current reading offset */ 
    3334    int64_t     i_size; 
     
    3637}; 
    3738 
    38 static int AStreamReadMem( stream_t *, void *p_read, int i_read ); 
    39 static int AStreamPeekMem( stream_t *, uint8_t **pp_peek, int i_read ); 
    40 static int AStreamControl( stream_t *, int i_query, va_list ); 
     39static int  Read   ( stream_t *, void *p_read, int i_read ); 
     40static int  Peek   ( stream_t *, uint8_t **pp_peek, int i_read ); 
     41static int  Control( stream_t *, int i_query, va_list ); 
     42static void Delete ( stream_t * ); 
    4143 
    42 /**************************************************************************** 
    43  * stream_MemoryNew: create a stream from a buffer 
    44  ****************************************************************************/ 
     44/** 
     45 * Create a stream from a memory buffer 
     46 * 
     47 * \param p_this the calling vlc_object 
     48 * \param p_buffer the memory buffer for the stream 
     49 * \param i_buffer the size of the buffer 
     50 * \param i_preserve_memory if this is set to VLC_FALSE the memory buffer 
     51 *        pointed to by p_buffer is freed on stream_Destroy 
     52 */ 
    4553stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer, 
    46                               int64_t i_size
     54                              int64_t i_size, vlc_bool_t i_preserve_memory
    4755{ 
    4856    stream_t *s = vlc_object_create( p_this, VLC_OBJECT_STREAM ); 
     
    5563    p_sys->i_size = i_size; 
    5664    p_sys->p_buffer = p_buffer; 
     65    p_sys->i_preserve_memory = i_preserve_memory; 
    5766 
    5867    s->pf_block   = NULL; 
    59     s->pf_read    = AStreamReadMem;    /* Set up later */ 
    60     s->pf_peek    = AStreamPeekMem; 
    61     s->pf_control = AStreamControl; 
     68    s->pf_read    = Read; 
     69    s->pf_peek    = Peek; 
     70    s->pf_control = Control; 
     71    s->pf_destroy = Delete; 
    6272    vlc_object_attach( s, p_this ); 
    6373 
     
    6575} 
    6676 
    67 void stream_MemoryDelete( stream_t *s, vlc_bool_t b_free_buffer
     77static void Delete( stream_t *s
    6878{ 
    69     if( b_free_buffer ) free( s->p_sys->p_buffer ); 
     79    if( !s->p_sys->i_preserve_memory ) free( s->p_sys->p_buffer ); 
    7080    free( s->p_sys ); 
    7181    vlc_object_detach( s ); 
     
    7686 * AStreamControl: 
    7787 ****************************************************************************/ 
    78 static int AStreamControl( stream_t *s, int i_query, va_list args ) 
     88static int Control( stream_t *s, int i_query, va_list args ) 
    7989{ 
    8090    stream_sys_t *p_sys = s->p_sys; 
     
    129139} 
    130140 
    131 static int AStreamReadMem( stream_t *s, void *p_read, int i_read ) 
     141static int Read( stream_t *s, void *p_read, int i_read ) 
    132142{ 
    133143    stream_sys_t *p_sys = s->p_sys; 
     
    138148} 
    139149 
    140 static int AStreamPeekMem( stream_t *s, uint8_t **pp_peek, int i_read ) 
     150static int Peek( stream_t *s, uint8_t **pp_peek, int i_read ) 
    141151{ 
    142152    stream_sys_t *p_sys = s->p_sys; 
  • src/input/stream.c

    rdb4be85 r2d16a40  
    181181/* Common */ 
    182182static int AStreamControl( stream_t *s, int i_query, va_list ); 
     183static void AStreamDestroy( stream_t *s ); 
     184static void UStreamDestroy( stream_t *s ); 
    183185static int  ASeek( stream_t *s, int64_t i_pos ); 
    184186 
     
    187189 * stream_AccessNew: create a stream from a access 
    188190 ****************************************************************************/ 
     191stream_t *__stream_UrlNew( vlc_object_t *p_parent, char *psz_url ) 
     192{ 
     193    char *psz_access, *psz_demux, *psz_path; 
     194    access_t *p_access; 
     195    stream_t *p_res; 
     196     
     197    MRLSplit( p_parent, psz_url, &psz_access, &psz_demux, &psz_path ); 
     198     
     199    /* Now try a real access */ 
     200    p_access = access2_New( p_parent, psz_access, NULL, 
     201                            psz_path, VLC_TRUE ); 
     202 
     203    if( p_access == NULL ) 
     204    { 
     205        msg_Err( p_parent, "no suitable access module for `%s'", psz_url ); 
     206        return NULL; 
     207    } 
     208    p_res = stream_AccessNew( p_access, VLC_TRUE ); 
     209    if( p_res ) 
     210    { 
     211        p_res->pf_destroy = UStreamDestroy; 
     212        return p_res; 
     213    } 
     214    else 
     215    { 
     216        access2_Delete( p_access ); 
     217    } 
     218} 
     219 
    189220stream_t *stream_AccessNew( access_t *p_access, vlc_bool_t b_quick ) 
    190221{ 
     
    202233    s->pf_peek   = NULL; 
    203234    s->pf_control= AStreamControl; 
     235    s->pf_destroy = AStreamDestroy; 
    204236 
    205237    s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) ); 
     
    355387 
    356388/**************************************************************************** 
    357  * stream_AccessDelete
     389 * AStreamDestroy
    358390 ****************************************************************************/ 
    359 void stream_AccessDelete( stream_t *s ) 
     391static void AStreamDestroy( stream_t *s ) 
    360392{ 
    361393    stream_sys_t *p_sys = s->p_sys; 
     
    380412    free( s->p_sys ); 
    381413    vlc_object_destroy( s ); 
     414} 
     415 
     416static void UStreamDestroy( stream_t *s ) 
     417{ 
     418    access_t *p_access = (access_t*)vlc_object_find( s, VLC_OBJECT_ACCESS, FIND_PARENT ); 
     419    AStreamDestroy( s ); 
     420    access2_Delete( p_access ); 
    382421} 
    383422