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