Changeset 2d16a4083986d2676d638fc2d64f9561e555b6f9
- 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
| refc525b |
r2d16a40 |
|
| 66 | 66 | int (*pf_peek) ( stream_t *, uint8_t **pp_peek, int i_peek ); |
|---|
| 67 | 67 | int (*pf_control)( stream_t *, int i_query, va_list ); |
|---|
| | 68 | void (*pf_destroy)( stream_t *); |
|---|
| 68 | 69 | |
|---|
| 69 | 70 | stream_sys_t *p_sys; |
|---|
| … | … | |
| 105 | 106 | return s->pf_control( s, i_query, args ); |
|---|
| 106 | 107 | } |
|---|
| | 108 | |
|---|
| | 109 | /** |
|---|
| | 110 | * Destroy a stream |
|---|
| | 111 | */ |
|---|
| | 112 | static inline void stream_Delete( stream_t *s ) |
|---|
| | 113 | { |
|---|
| | 114 | s->pf_destroy( s ); |
|---|
| | 115 | } |
|---|
| | 116 | |
|---|
| 107 | 117 | static inline int stream_Control( stream_t *s, int i_query, ... ) |
|---|
| 108 | 118 | { |
|---|
| … | … | |
| 115 | 125 | return i_result; |
|---|
| 116 | 126 | } |
|---|
| | 127 | |
|---|
| | 128 | /** |
|---|
| | 129 | * Get the current position in a stream |
|---|
| | 130 | */ |
|---|
| 117 | 131 | static inline int64_t stream_Tell( stream_t *s ) |
|---|
| 118 | 132 | { |
|---|
| … | … | |
| 121 | 135 | return i_pos; |
|---|
| 122 | 136 | } |
|---|
| | 137 | |
|---|
| | 138 | /** |
|---|
| | 139 | * Get the size of the stream. |
|---|
| | 140 | */ |
|---|
| 123 | 141 | static inline int64_t stream_Size( stream_t *s ) |
|---|
| 124 | 142 | { |
|---|
| … | … | |
| 177 | 195 | VLC_EXPORT( void, stream_DemuxSend, ( stream_t *s, block_t *p_block ) ); |
|---|
| 178 | 196 | VLC_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 ) |
|---|
| | 200 | VLC_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 ) |
|---|
| | 202 | VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, char *psz_url ) ); |
|---|
| | 203 | |
|---|
| 182 | 204 | /** |
|---|
| 183 | 205 | * @} |
|---|
| r792697d |
r2d16a40 |
|
| 1335 | 1335 | stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer), |
|---|
| 1336 | 1336 | tk->p_extra_data, |
|---|
| 1337 | | tk->i_extra_data ); |
|---|
| | 1337 | tk->i_extra_data, |
|---|
| | 1338 | VLC_FALSE ); |
|---|
| 1338 | 1339 | MP4_ReadBoxCommon( p_mp4_stream, p_box ); |
|---|
| 1339 | 1340 | MP4_ReadBox_sample_vide( p_mp4_stream, p_box ); |
|---|
| … | … | |
| 1345 | 1346 | memcpy( tk->fmt.p_extra, p_box->data.p_sample_vide->p_qt_image_description, tk->fmt.i_extra ); |
|---|
| 1346 | 1347 | MP4_FreeBox_sample_vide( p_box ); |
|---|
| 1347 | | stream_MemoryDelete( p_mp4_stream, VLC_TRUE ); |
|---|
| | 1348 | stream_Delete( p_mp4_stream ); |
|---|
| 1348 | 1349 | } |
|---|
| 1349 | 1350 | else if( !strcmp( tk->psz_codec, "A_MS/ACM" ) ) |
|---|
| rb20696d |
r2d16a40 |
|
| 1853 | 1853 | p_stream_memory = |
|---|
| 1854 | 1854 | 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 ); |
|---|
| 1856 | 1856 | |
|---|
| 1857 | 1857 | /* and read uncompressd moov */ |
|---|
| 1858 | 1858 | p_box->data.p_cmov->p_moov = MP4_ReadBox( p_stream_memory, NULL ); |
|---|
| 1859 | 1859 | |
|---|
| 1860 | | stream_MemoryDelete( p_stream_memory, VLC_FALSE ); |
|---|
| | 1860 | stream_Delete( p_stream_memory ); |
|---|
| 1861 | 1861 | |
|---|
| 1862 | 1862 | #ifdef MP4_VERBOSE |
|---|
| r2ecc8ed |
r2d16a40 |
|
| 63 | 63 | |
|---|
| 64 | 64 | static void DecodeUrl( char * ); |
|---|
| 65 | | static void MRLSplit( input_thread_t *, char *, char **, char **, char ** ); |
|---|
| 66 | 65 | static void MRLSections( input_thread_t *, char *, int *, int *, int *, int *); |
|---|
| 67 | 66 | |
|---|
| … | … | |
| 2115 | 2114 | |
|---|
| 2116 | 2115 | if( in->p_stream ) |
|---|
| 2117 | | stream_AccessDelete( in->p_stream ); |
|---|
| | 2116 | stream_Delete( in->p_stream ); |
|---|
| 2118 | 2117 | |
|---|
| 2119 | 2118 | if( in->p_access ) |
|---|
| … | … | |
| 2133 | 2132 | |
|---|
| 2134 | 2133 | if( in->p_stream ) |
|---|
| 2135 | | stream_AccessDelete( in->p_stream ); |
|---|
| | 2134 | stream_Delete( in->p_stream ); |
|---|
| 2136 | 2135 | |
|---|
| 2137 | 2136 | if( in->p_access ) |
|---|
| … | … | |
| 2394 | 2393 | * Media Resource Locator. |
|---|
| 2395 | 2394 | *****************************************************************************/ |
|---|
| 2396 | | static void MRLSplit( input_thread_t *p_input, char *psz_dup, |
|---|
| 2397 | | char **ppsz_access, char **ppsz_demux, char **ppsz_path ) |
|---|
| | 2395 | void MRLSplit( vlc_object_t *p_input, char *psz_dup, |
|---|
| | 2396 | char **ppsz_access, char **ppsz_demux, char **ppsz_path ) |
|---|
| 2398 | 2397 | { |
|---|
| 2399 | 2398 | char *psz_access = NULL; |
|---|
| r70ee5fb |
r2d16a40 |
|
| 153 | 153 | /* Subtitles */ |
|---|
| 154 | 154 | char **subtitles_Detect( input_thread_t *, char* path, char *fname ); |
|---|
| | 155 | void MRLSplit( vlc_object_t *, char *, char **, char **, char ** ); |
|---|
| 155 | 156 | |
|---|
| 156 | 157 | #endif |
|---|
| rf992190 |
r2d16a40 |
|
| 30 | 30 | struct stream_sys_t |
|---|
| 31 | 31 | { |
|---|
| | 32 | vlc_bool_t i_preserve_memory; |
|---|
| 32 | 33 | int64_t i_pos; /* Current reading offset */ |
|---|
| 33 | 34 | int64_t i_size; |
|---|
| … | … | |
| 36 | 37 | }; |
|---|
| 37 | 38 | |
|---|
| 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 ); |
|---|
| | 39 | static int Read ( stream_t *, void *p_read, int i_read ); |
|---|
| | 40 | static int Peek ( stream_t *, uint8_t **pp_peek, int i_read ); |
|---|
| | 41 | static int Control( stream_t *, int i_query, va_list ); |
|---|
| | 42 | static void Delete ( stream_t * ); |
|---|
| 41 | 43 | |
|---|
| 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 | */ |
|---|
| 45 | 53 | stream_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 ) |
|---|
| 47 | 55 | { |
|---|
| 48 | 56 | stream_t *s = vlc_object_create( p_this, VLC_OBJECT_STREAM ); |
|---|
| … | … | |
| 55 | 63 | p_sys->i_size = i_size; |
|---|
| 56 | 64 | p_sys->p_buffer = p_buffer; |
|---|
| | 65 | p_sys->i_preserve_memory = i_preserve_memory; |
|---|
| 57 | 66 | |
|---|
| 58 | 67 | 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; |
|---|
| 62 | 72 | vlc_object_attach( s, p_this ); |
|---|
| 63 | 73 | |
|---|
| … | … | |
| 65 | 75 | } |
|---|
| 66 | 76 | |
|---|
| 67 | | void stream_MemoryDelete( stream_t *s, vlc_bool_t b_free_buffer ) |
|---|
| | 77 | static void Delete( stream_t *s ) |
|---|
| 68 | 78 | { |
|---|
| 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 ); |
|---|
| 70 | 80 | free( s->p_sys ); |
|---|
| 71 | 81 | vlc_object_detach( s ); |
|---|
| … | … | |
| 76 | 86 | * AStreamControl: |
|---|
| 77 | 87 | ****************************************************************************/ |
|---|
| 78 | | static int AStreamControl( stream_t *s, int i_query, va_list args ) |
|---|
| | 88 | static int Control( stream_t *s, int i_query, va_list args ) |
|---|
| 79 | 89 | { |
|---|
| 80 | 90 | stream_sys_t *p_sys = s->p_sys; |
|---|
| … | … | |
| 129 | 139 | } |
|---|
| 130 | 140 | |
|---|
| 131 | | static int AStreamReadMem( stream_t *s, void *p_read, int i_read ) |
|---|
| | 141 | static int Read( stream_t *s, void *p_read, int i_read ) |
|---|
| 132 | 142 | { |
|---|
| 133 | 143 | stream_sys_t *p_sys = s->p_sys; |
|---|
| … | … | |
| 138 | 148 | } |
|---|
| 139 | 149 | |
|---|
| 140 | | static int AStreamPeekMem( stream_t *s, uint8_t **pp_peek, int i_read ) |
|---|
| | 150 | static int Peek( stream_t *s, uint8_t **pp_peek, int i_read ) |
|---|
| 141 | 151 | { |
|---|
| 142 | 152 | stream_sys_t *p_sys = s->p_sys; |
|---|
| rdb4be85 |
r2d16a40 |
|
| 181 | 181 | /* Common */ |
|---|
| 182 | 182 | static int AStreamControl( stream_t *s, int i_query, va_list ); |
|---|
| | 183 | static void AStreamDestroy( stream_t *s ); |
|---|
| | 184 | static void UStreamDestroy( stream_t *s ); |
|---|
| 183 | 185 | static int ASeek( stream_t *s, int64_t i_pos ); |
|---|
| 184 | 186 | |
|---|
| … | … | |
| 187 | 189 | * stream_AccessNew: create a stream from a access |
|---|
| 188 | 190 | ****************************************************************************/ |
|---|
| | 191 | stream_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 | |
|---|
| 189 | 220 | stream_t *stream_AccessNew( access_t *p_access, vlc_bool_t b_quick ) |
|---|
| 190 | 221 | { |
|---|
| … | … | |
| 202 | 233 | s->pf_peek = NULL; |
|---|
| 203 | 234 | s->pf_control= AStreamControl; |
|---|
| | 235 | s->pf_destroy = AStreamDestroy; |
|---|
| 204 | 236 | |
|---|
| 205 | 237 | s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) ); |
|---|
| … | … | |
| 355 | 387 | |
|---|
| 356 | 388 | /**************************************************************************** |
|---|
| 357 | | * stream_AccessDelete: |
|---|
| | 389 | * AStreamDestroy: |
|---|
| 358 | 390 | ****************************************************************************/ |
|---|
| 359 | | void stream_AccessDelete( stream_t *s ) |
|---|
| | 391 | static void AStreamDestroy( stream_t *s ) |
|---|
| 360 | 392 | { |
|---|
| 361 | 393 | stream_sys_t *p_sys = s->p_sys; |
|---|
| … | … | |
| 380 | 412 | free( s->p_sys ); |
|---|
| 381 | 413 | vlc_object_destroy( s ); |
|---|
| | 414 | } |
|---|
| | 415 | |
|---|
| | 416 | static 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 ); |
|---|
| 382 | 421 | } |
|---|
| 383 | 422 | |
|---|