]> git.sesse.net Git - vlc/blob - include/vlc_block.h
* include/vlc_block.h, modules/codec/libmpeg2.c: re-added the discontinuity flag...
[vlc] / include / vlc_block.h
1 /*****************************************************************************
2  * vlc_block.h: Data blocks management functions
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: vlc_block.h,v 1.3 2003/09/30 20:23:03 gbazin Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef _VLC_BLOCK_H
25 #define _VLC_BLOCK_H 1
26
27 /*
28  * block
29  */
30 typedef struct block_sys_t block_sys_t;
31
32 struct block_t
33 {
34     block_t     *p_next;
35
36     vlc_bool_t  b_frame_display;
37     vlc_bool_t  b_frame_start;
38     mtime_t     i_pts;
39     mtime_t     i_dts;
40
41     vlc_bool_t  b_discontinuity; /* only temporary */
42
43     int         i_buffer;
44     uint8_t     *p_buffer;
45
46     void        (*pf_release)   ( block_t * );
47
48     block_t    *(*pf_modify)    ( block_t *, vlc_bool_t );
49     block_t    *(*pf_duplicate) ( block_t * );
50     block_t    *(*pf_realloc)   ( block_t *, int i_prebody, int i_body );
51
52     /* Following fields are private, user should never touch it */
53     /* XXX never touch that OK !!! the first that access that will
54      * have cvs account removed ;) XXX */
55
56     /* It's an object that should be valid as long as the block_t is valid */
57     /* It should become a true block manager to reduce malloc/free */
58     vlc_object_t    *p_manager;
59
60     /* private member for block_New, .... manager */
61     block_sys_t *p_sys;
62 };
63
64 struct block_fifo_t
65 {
66     vlc_mutex_t         lock;                         /* fifo data lock */
67     vlc_cond_t          wait;         /* fifo data conditional variable */
68
69     int                 i_depth;
70     block_t             *p_first;
71     block_t             **pp_last;
72 };
73
74 /*
75  * block
76  */
77 #define block_New( a, b ) __block_New( VLC_OBJECT(a), b )
78 VLC_EXPORT( block_t *,  __block_New,        ( vlc_object_t *, int ) );
79 static inline void block_Release( block_t *p_block )
80 {
81     p_block->pf_release( p_block );
82 }
83 static inline block_t *block_Modify( block_t *p_block, vlc_bool_t b_willmodify )
84 {
85     return p_block->pf_modify( p_block, b_willmodify );
86 }
87 static inline block_t *block_Duplicate( block_t *p_block )
88 {
89     return p_block->pf_duplicate( p_block );
90 }
91 static inline block_t *block_Realloc( block_t *p_block, int i_pre, int i_body )
92 {
93     return p_block->pf_realloc( p_block, i_pre, i_body );
94 }
95 VLC_EXPORT( void,       block_ChainAppend,  ( block_t **, block_t * ) );
96 VLC_EXPORT( void,       block_ChainRelease, ( block_t * ) );
97 VLC_EXPORT( int,        block_ChainExtract, ( block_t *, void *, int ) );
98 VLC_EXPORT( block_t *,  block_ChainGather,  ( block_t * ) );
99
100 /* a bit special, only for new/other block manager */
101 VLC_EXPORT( block_t *,  block_NewEmpty,     ( void ) );
102
103 #define block_FifoNew( a ) __block_FifoNew( VLC_OBJECT(a) )
104 VLC_EXPORT( block_fifo_t *, __block_FifoNew,    ( vlc_object_t * ) );
105 VLC_EXPORT( void,           block_FifoRelease,  ( block_fifo_t * ) );
106 VLC_EXPORT( void,           block_FifoEmpty,    ( block_fifo_t * ) );
107 VLC_EXPORT( int,            block_FifoPut,      ( block_fifo_t *, block_t * ) );
108 VLC_EXPORT( block_t *,      block_FifoGet,      ( block_fifo_t * ) );
109 VLC_EXPORT( block_t *,      block_FifoGetFrame, ( block_fifo_t * ) );
110 VLC_EXPORT( block_t *,      block_FifoShow,     ( block_fifo_t * ) );
111
112 #endif /* VLC_BLOCK_H */