]> git.sesse.net Git - vlc/blob - include/ninput.h
6c55b48fd45496c99d8eec435f01415b48c24a7f
[vlc] / include / ninput.h
1 /*****************************************************************************
2  * ninput.h
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: ninput.h,v 1.22 2004/01/06 21:42:43 sigmunau 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 _NINPUT_H
25 #define _NINPUT_H 1
26
27 #include "vlc_es.h"
28
29 enum es_out_mode_e
30 {
31     ES_OUT_MODE_NONE,   /* don't select anything */
32     ES_OUT_MODE_ALL,    /* eg for stream output */
33     ES_OUT_MODE_AUTO    /* best audio/video or for input follow audio-channel, spu-channel */
34 };
35
36 enum es_out_query_e
37 {
38     /* activate apply of mode */
39     ES_OUT_SET_ACTIVE,  /* arg1= vlc_bool_t                     */
40     /* see if mode is currently aplied or not */
41     ES_OUT_GET_ACTIVE,  /* arg1= vlc_bool_t*                    */
42
43     /* set/get mode */
44     ES_OUT_SET_MODE,    /* arg1= int                            */
45     ES_OUT_GET_MODE,    /* arg2= int*                           */
46
47     /* set es selected for the es category(audio/video/spu) */
48     ES_OUT_SET_ES,      /* arg1= es_out_id_t*                   */
49
50     /* force selection/unselection of the ES (bypass current mode)*/
51     ES_OUT_SET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t   */
52     ES_OUT_GET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t*  */
53
54     /* XXX XXX XXX Don't use them YET !!! */
55     ES_OUT_SET_PCR,     /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/
56     ES_OUT_RESET_PCR,   /* no arg */
57 };
58
59 struct es_out_t
60 {
61     es_out_id_t *(*pf_add)    ( es_out_t *, es_format_t * );
62     int          (*pf_send)   ( es_out_t *, es_out_id_t *, block_t * );
63     void         (*pf_del)    ( es_out_t *, es_out_id_t * );
64     int          (*pf_control)( es_out_t *, int i_query, va_list );
65
66     es_out_sys_t    *p_sys;
67 };
68
69 static inline es_out_id_t * es_out_Add( es_out_t *out, es_format_t *fmt )
70 {
71     return out->pf_add( out, fmt );
72 }
73 static inline void es_out_Del( es_out_t *out, es_out_id_t *id )
74 {
75     out->pf_del( out, id );
76 }
77 static inline int es_out_Send( es_out_t *out, es_out_id_t *id,
78                                block_t *p_block )
79 {
80     return out->pf_send( out, id, p_block );
81 }
82
83 static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
84 {
85     return out->pf_control( out, i_query, args );
86 }
87 static inline int es_out_Control( es_out_t *out, int i_query, ... )
88 {
89     va_list args;
90     int     i_result;
91
92     va_start( args, i_query );
93     i_result = es_out_vaControl( out, i_query, args );
94     va_end( args );
95     return i_result;
96 }
97
98 /**
99  * \defgroup stream Stream
100  *
101  *  This will allow you to easily handle read/seek in demuxer modules.
102  * @{
103  */
104
105 /**
106  * Possible commands to send to stream_Control() and stream_vaControl()
107  */
108 enum stream_query_e
109 {
110     /* capabilities */
111     STREAM_CAN_SEEK,            /**< arg1= vlc_bool_t *   res=cannot fail*/
112     STREAM_CAN_FASTSEEK,        /**< arg1= vlc_bool_t *   res=cannot fail*/
113
114     /* */
115     STREAM_SET_POSITION,        /**< arg1= int64_t        res=can fail  */
116     STREAM_GET_POSITION,        /**< arg1= int64_t *      res=cannot fail*/
117
118     STREAM_GET_SIZE,            /**< arg1= int64_t *      res=cannot fail (0 if no sense)*/
119 };
120
121 /* Stream */
122 VLC_EXPORT( stream_t *,     stream_OpenInput,       ( input_thread_t * ) );
123 VLC_EXPORT( void,           stream_Release,         ( stream_t * ) );
124 VLC_EXPORT( int,            stream_vaControl,       ( stream_t *, int i_query, va_list ) );
125 VLC_EXPORT( int,            stream_Control,         ( stream_t *, int i_query, ... ) );
126 VLC_EXPORT( int,            stream_Read,            ( stream_t *, void *p_read, int i_read ) );
127 VLC_EXPORT( int,            stream_Peek,            ( stream_t *, uint8_t **pp_peek, int i_peek ) );
128 VLC_EXPORT( char *,         stream_ReadLine,        ( stream_t * ) );
129 VLC_EXPORT( data_packet_t *,stream_DataPacket,      ( stream_t *, int i_size, vlc_bool_t b_force ) );
130 VLC_EXPORT( pes_packet_t *, stream_PesPacket,       ( stream_t *, int i_size ) );
131 VLC_EXPORT( block_t *,      stream_Block,           ( stream_t *, int i_size ) );
132
133 static int64_t inline stream_Tell( stream_t *s )
134 {
135     int64_t i_pos;
136     stream_Control( s, STREAM_GET_POSITION, &i_pos );
137
138     return i_pos;
139 }
140 static int64_t inline stream_Size( stream_t *s )
141 {
142     int64_t i_pos;
143     stream_Control( s, STREAM_GET_SIZE, &i_pos );
144
145     return i_pos;
146 }
147 static int inline stream_Seek( stream_t *s, int64_t i_pos )
148 {
149     return stream_Control( s, STREAM_SET_POSITION, i_pos );
150 }
151
152
153 /**
154  * @}
155  */
156
157 /**
158  * \defgroup demux Demux
159  * @{
160  */
161
162
163 struct demux_t
164 {
165     VLC_COMMON_MEMBERS
166
167     /* Module properties */
168     module_t    *p_module;
169
170     /* eg informative but needed (we can have access+demux) */
171     char        *psz_access;
172     char        *psz_demux;
173     char        *psz_path;
174
175     /* input stream */
176     stream_t    *s;     /* NULL in case of a access+demux in one */
177
178     /* es output */
179     es_out_t    *out;   /* ou p_es_out */
180
181     /* set by demuxer */
182     int (*pf_demux)  ( demux_t * );   /* demux one frame only */
183     int (*pf_control)( demux_t *, int i_query, va_list args);
184     demux_sys_t *p_sys;
185 };
186
187 enum demux_query_e
188 {
189     DEMUX_GET_POSITION,         /* arg1= double *       res=    */
190     DEMUX_SET_POSITION,         /* arg1= double         res=can fail    */
191
192     DEMUX_GET_TIME,             /* arg1= int64_t *      res=    */
193     DEMUX_SET_TIME,             /* arg1= int64_t        res=can fail    */
194
195     DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=can fail    */
196
197     DEMUX_GET_FPS               /* arg1= float *        res=can fail    */
198 };
199
200
201
202 /* Demux */
203 VLC_EXPORT( int,            demux_vaControl,        ( input_thread_t *, int i_query, va_list  ) );
204 VLC_EXPORT( int,            demux_Control,          ( input_thread_t *, int i_query, ...  ) );
205
206 VLC_EXPORT( int,            demux_vaControlDefault, ( input_thread_t *, int i_query, va_list  ) );
207
208
209 /* New demux arch: don't touch that */
210 /* stream_t *s could be null and then it mean a access+demux in one */
211 #define demux2_New( a, b, c, d ) __demux2_New(VLC_OBJECT(a), b, c, d)
212 VLC_EXPORT( demux_t *, __demux2_New,  ( vlc_object_t *p_obj, char *psz_mrl, stream_t *s, es_out_t *out ) );
213 VLC_EXPORT( void,      demux2_Delete, ( demux_t * ) );
214
215 static inline int demux2_Demux( demux_t *p_demux )
216 {
217     return p_demux->pf_demux( p_demux );
218 }
219 static inline int demux2_vaControl( demux_t *p_demux, int i_query, va_list args )
220 {
221     return p_demux->pf_control( p_demux, i_query, args );
222 }
223 static inline int demux2_Control( demux_t *p_demux, int i_query, ... )
224 {
225     va_list args;
226     int     i_result;
227
228     va_start( args, i_query );
229     i_result = demux2_vaControl( p_demux, i_query, args );
230     va_end( args );
231     return i_result;
232 }
233
234
235 /* Subtitles */
236 VLC_EXPORT( char **,        subtitles_Detect,       ( input_thread_t *, char* path, char *fname ) );
237
238 /**
239  * @}
240  */
241
242 #endif
243