]> git.sesse.net Git - vlc/blob - include/ninput.h
4876a72f006c818660d734d13c7e2418a0a10538
[vlc] / include / ninput.h
1 /*****************************************************************************
2  * ninput.h
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: ninput.h,v 1.9 2003/09/12 16:26:40 fenrir 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 #if 0
28 enum es_extra_type_e
29 {
30     ES_EXTRA_TYPE_UNKNOWN,
31     ES_EXTRA_TYPE_WAVEFORMATEX,
32     ES_EXTRA_TYPE_BITMAPINFOHEADER
33 };
34
35 typedef struct
36 {
37     int             i_cat;
38     vlc_fourcc_t    i_codec;
39
40     int             i_group;    /* eg -1. if >= 0 then a "group" (program) is
41                                    created for each value */
42
43     int             i_priority; /*  -2 : mean not selectable by the users
44                                     -1 : mean not selected by default even
45                                         when no other stream
46                                     >=0: priority */
47     char            *psz_language;
48     char            *psz_description;
49
50     struct
51     {
52         int i_samplerate;
53         int i_channels;
54         int i_bitrate;
55         int i_blockalign;
56         int i_bitspersample;
57     } audio;
58
59     struct
60     {
61         int i_width;
62         int i_height;
63         int i_display_width;
64         int i_display_height;
65     } video;
66
67     struct
68     {
69         char *psz_encoding;
70     } subs;
71
72     int     i_extra_type;
73     int     i_extra;
74     void    *p_extra;
75 } es_format_t;
76
77 static inline void es_format_Init( es_format_t *fmt,
78                                    int i_cat, vlc_fourcc_t i_codec )
79 {
80     fmt->i_cat                  = i_cat;
81     fmt->i_codec                = i_codec;
82     fmt->i_group                = -1;
83     fmt->i_priority             = 0;
84     fmt->psz_language           = NULL;
85     fmt->psz_description        = NULL;
86
87     fmt->audio.i_samplerate     = 0;
88     fmt->audio.i_channels       = 0;
89     fmt->audio.i_bitrate        = 0;
90     fmt->audio.i_blockalign     = 0;
91     fmt->audio.i_bitspersample  = 0;
92
93     fmt->video.i_width          = 0;
94     fmt->video.i_height         = 0;
95     fmt->video.i_display_width  = 0;
96     fmt->video.i_display_height = 0;
97
98     fmt->subs.psz_encoding      = NULL;
99
100     fmt->i_extra_type           = ES_EXTRA_TYPE_UNKNOWN;
101     fmt->i_extra                = 0;
102     fmt->p_extra                = NULL;
103 }
104
105 enum es_out_query_e
106 {
107     ES_OUT_SET_SELECT,  /* arg1= es_out_id_t* arg2=vlc_bool_t   */
108     ES_OUT_GET_SELECT   /* arg1= es_out_id_t* arg2=vlc_bool_t*  */
109 };
110
111 typedef struct es_out_t     es_out_t;
112 typedef struct es_out_id_t  es_out_id_t;
113 typedef struct es_out_sys_t es_out_sys_t;
114
115 struct es_out_t
116 {
117     es_out_id_t (*pf_add)    ( es_out_t *, es_format_t * );
118     int         (*pf_send)   ( es_out_t *, es_out_id_t *, pes_packet_t * );
119     void        (*pf_del)    ( es_out_t *, es_out_id_t * );
120     int         (*pf_control)( es_out_t *, int i_query, va_list );
121
122     es_out_sys_t    *p_sys;
123 };
124
125 static inline es_out_id_t * es_out_Add( es_out_t *out, es_format_t *fmt )
126 {
127     return out->pf_add( out, fmt );
128 }
129 static inline void es_out_Del( es_out_t *out, es_out_id_t *id )
130 {
131     out->pf_del( out, id );
132 }
133 static inline int es_out_Send( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
134 {
135     return out->pf_send( out, id, p_pes );
136 }
137 static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
138 {
139     return out->pf_control( out, i_query, args );
140 }
141 static inline int es_out_Control( es_out_t *out, int i_query, ... )
142 {
143     va_list args;
144     int     i_result;
145
146     va_start( args, i_query );
147     i_result = es_out_vaControl( out, i_query, args );
148     va_end( args );
149     return i_result;
150 }
151 #endif
152
153 /**
154  * \defgroup stream Stream
155  *
156  *  This will allow you to easily handle read/seek in demuxer modules.
157  * @{
158  */
159
160 /**
161  * Possible commands to send to stream_Control() and stream_vaControl()
162  */
163 enum stream_query_e
164 {
165     /* capabilities */
166     STREAM_CAN_SEEK,            /**< arg1= vlc_bool_t *   res=cannot fail*/
167     STREAM_CAN_FASTSEEK,        /**< arg1= vlc_bool_t *   res=cannot fail*/
168
169     /* */
170     STREAM_SET_POSITION,        /**< arg1= int64_t        res=can fail  */
171     STREAM_GET_POSITION,        /**< arg1= int64_t *      res=cannot fail*/
172
173     STREAM_GET_SIZE,            /**< arg1= int64_t *      res=cannot fail (0 if no sense)*/
174 };
175
176 /* Stream */
177 VLC_EXPORT( stream_t *,     stream_OpenInput,       ( input_thread_t * ) );
178 VLC_EXPORT( void,           stream_Release,         ( stream_t * ) );
179 VLC_EXPORT( int,            stream_vaControl,       ( stream_t *, int i_query, va_list ) );
180 VLC_EXPORT( int,            stream_Control,         ( stream_t *, int i_query, ... ) );
181 VLC_EXPORT( int,            stream_Read,            ( stream_t *, void *p_read, int i_read ) );
182 VLC_EXPORT( int,            stream_Peek,            ( stream_t *, uint8_t **pp_peek, int i_peek ) );
183 VLC_EXPORT( data_packet_t *,stream_DataPacket,      ( stream_t *, int i_size, vlc_bool_t b_force ) );
184 VLC_EXPORT( pes_packet_t *, stream_PesPacket,       ( stream_t *, int i_size ) );
185
186 static int64_t inline stream_Tell( stream_t *s )
187 {
188     int64_t i_pos;
189     stream_Control( s, STREAM_GET_POSITION, &i_pos );
190
191     return i_pos;
192 }
193 static int64_t inline stream_Size( stream_t *s )
194 {
195     int64_t i_pos;
196     stream_Control( s, STREAM_GET_SIZE, &i_pos );
197
198     return i_pos;
199 }
200 static int inline stream_Seek( stream_t *s, int64_t i_pos )
201 {
202     return stream_Control( s, STREAM_SET_POSITION, i_pos );
203 }
204
205
206 /**
207  * @}
208  */
209
210 /**
211  * \defgroup demux Demux
212  * @{
213  */
214 enum demux_query_e
215 {
216     DEMUX_GET_POSITION,         /* arg1= double *       res=    */
217     DEMUX_SET_POSITION,         /* arg1= double         res=can fail    */
218
219     DEMUX_GET_TIME,             /* arg1= int64_t *      res=    */
220     DEMUX_SET_TIME,             /* arg1= int64_t        res=can fail    */
221
222     DEMUX_GET_LENGTH            /* arg1= int64_t *      res=can fail    */
223 };
224
225
226
227 /* Demux */
228 VLC_EXPORT( int,            demux_vaControl,        ( input_thread_t *, int i_query, va_list  ) );
229 VLC_EXPORT( int,            demux_Control,          ( input_thread_t *, int i_query, ...  ) );
230
231 VLC_EXPORT( int,            demux_vaControlDefault, ( input_thread_t *, int i_query, va_list  ) );
232
233 /**
234  * @}
235  */
236 #endif
237