1 /*****************************************************************************
2  * es_out.h: Input es_out functions
3  *****************************************************************************
4  * Copyright (C) 1998-2008 VLC authors and VideoLAN
5  * Copyright (C) 2008 Laurent Aimar
6  * $Id: 8f202266e8317f80e1e230678f785f9e606c347f $
7  *
8  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24 
25 #ifndef LIBVLC_INPUT_ES_OUT_H
26 #define LIBVLC_INPUT_ES_OUT_H 1
27 
28 #include <vlc_common.h>
29 
30 enum es_out_mode_e
31 {
32     ES_OUT_MODE_NONE,   /* don't select anything */
33     ES_OUT_MODE_ALL,    /* eg for stream output */
34     ES_OUT_MODE_AUTO,   /* best audio/video or for input follow audio-track, sub-track */
35     ES_OUT_MODE_PARTIAL,/* select programs given after --programs */
36     ES_OUT_MODE_END     /* mark the es_out as dead */
37 };
38 
39 enum es_out_query_private_e
40 {
41     /* set/get mode */
42     ES_OUT_SET_MODE = ES_OUT_PRIVATE_START,         /* arg1= int                            */
43 
44     /* Get date to wait before demuxing more data */
45     ES_OUT_GET_WAKE_UP,                             /* arg1=mtime_t*            res=cannot fail */
46 
47     /* Wrapper for some ES command to work with id */
48     ES_OUT_SET_ES_BY_ID,
49     ES_OUT_RESTART_ES_BY_ID,
50     ES_OUT_SET_ES_DEFAULT_BY_ID,
51     ES_OUT_GET_ES_OBJECTS_BY_ID,                    /* arg1=int id, vlc_object_t **dec, vout_thread_t **, audio_output_t ** res=can fail*/
52 
53     /* Stop all selected ES and save the stopped state in a context. free the
54      * context or call ES_OUT_STOP_ALL_ES */
55     ES_OUT_STOP_ALL_ES,                             /* arg1=void ** */
56     /* Start all ES from the context returned by ES_OUT_STOP_ALL_ES */
57     ES_OUT_START_ALL_ES,                            /* arg1=void * */
58 
59     /* Get buffering state */
60     ES_OUT_GET_BUFFERING,                           /* arg1=bool*               res=cannot fail */
61 
62     /* Set delay for a ES category */
63     ES_OUT_SET_DELAY,                               /* arg1=es_category_e,      res=cannot fail */
64 
65     /* Set record state */
66     ES_OUT_SET_RECORD_STATE,                        /* arg1=bool                res=can fail */
67 
68     /* Set pause state */
69     ES_OUT_SET_PAUSE_STATE,                         /* arg1=bool b_source_paused, bool b_paused arg2=mtime_t   res=can fail */
70 
71     /* Set rate */
72     ES_OUT_SET_RATE,                                /* arg1=int i_source_rate arg2=int i_rate                  res=can fail */
73 
74     /* Set a new time */
75     ES_OUT_SET_TIME,                                /* arg1=mtime_t             res=can fail */
76 
77     /* Set next frame */
78     ES_OUT_SET_FRAME_NEXT,                          /*                          res=can fail */
79 
80     /* Set position/time/length */
81     ES_OUT_SET_TIMES,                               /* arg1=double f_position arg2=mtime_t i_time arg3=mtime_t i_length res=cannot fail */
82 
83     /* Set jitter */
84     ES_OUT_SET_JITTER,                              /* arg1=mtime_t i_pts_delay arg2= mtime_t i_pts_jitter, arg2=int i_cr_average res=cannot fail */
85 
86     /* Get forced group */
87     ES_OUT_GET_GROUP_FORCED,                        /* arg1=int * res=cannot fail */
88 
89     /* Set End Of Stream */
90     ES_OUT_SET_EOS,                                 /* res=cannot fail */
91 };
92 
es_out_SetMode(es_out_t * p_out,int i_mode)93 static inline void es_out_SetMode( es_out_t *p_out, int i_mode )
94 {
95     int i_ret = es_out_Control( p_out, ES_OUT_SET_MODE, i_mode );
96     assert( !i_ret );
97 }
es_out_GetWakeup(es_out_t * p_out)98 static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
99 {
100     mtime_t i_wu;
101     int i_ret = es_out_Control( p_out, ES_OUT_GET_WAKE_UP, &i_wu );
102 
103     assert( !i_ret );
104     return i_wu;
105 }
es_out_GetBuffering(es_out_t * p_out)106 static inline bool es_out_GetBuffering( es_out_t *p_out )
107 {
108     bool b;
109     int i_ret = es_out_Control( p_out, ES_OUT_GET_BUFFERING, &b );
110 
111     assert( !i_ret );
112     return b;
113 }
es_out_GetEmpty(es_out_t * p_out)114 static inline bool es_out_GetEmpty( es_out_t *p_out )
115 {
116     bool b;
117     int i_ret = es_out_Control( p_out, ES_OUT_GET_EMPTY, &b );
118 
119     assert( !i_ret );
120     return b;
121 }
es_out_SetDelay(es_out_t * p_out,int i_cat,mtime_t i_delay)122 static inline void es_out_SetDelay( es_out_t *p_out, int i_cat, mtime_t i_delay )
123 {
124     int i_ret = es_out_Control( p_out, ES_OUT_SET_DELAY, i_cat, i_delay );
125     assert( !i_ret );
126 }
es_out_SetRecordState(es_out_t * p_out,bool b_record)127 static inline int es_out_SetRecordState( es_out_t *p_out, bool b_record )
128 {
129     return es_out_Control( p_out, ES_OUT_SET_RECORD_STATE, b_record );
130 }
es_out_SetPauseState(es_out_t * p_out,bool b_source_paused,bool b_paused,mtime_t i_date)131 static inline int es_out_SetPauseState( es_out_t *p_out, bool b_source_paused, bool b_paused, mtime_t i_date )
132 {
133     return es_out_Control( p_out, ES_OUT_SET_PAUSE_STATE, b_source_paused, b_paused, i_date );
134 }
es_out_SetRate(es_out_t * p_out,int i_source_rate,int i_rate)135 static inline int es_out_SetRate( es_out_t *p_out, int i_source_rate, int i_rate )
136 {
137     return es_out_Control( p_out, ES_OUT_SET_RATE, i_source_rate, i_rate );
138 }
es_out_SetTime(es_out_t * p_out,mtime_t i_date)139 static inline int es_out_SetTime( es_out_t *p_out, mtime_t i_date )
140 {
141     return es_out_Control( p_out, ES_OUT_SET_TIME, i_date );
142 }
es_out_SetFrameNext(es_out_t * p_out)143 static inline int es_out_SetFrameNext( es_out_t *p_out )
144 {
145     return es_out_Control( p_out, ES_OUT_SET_FRAME_NEXT );
146 }
es_out_SetTimes(es_out_t * p_out,double f_position,mtime_t i_time,mtime_t i_length)147 static inline void es_out_SetTimes( es_out_t *p_out, double f_position, mtime_t i_time, mtime_t i_length )
148 {
149     int i_ret = es_out_Control( p_out, ES_OUT_SET_TIMES, f_position, i_time, i_length );
150     assert( !i_ret );
151 }
es_out_SetJitter(es_out_t * p_out,mtime_t i_pts_delay,mtime_t i_pts_jitter,int i_cr_average)152 static inline void es_out_SetJitter( es_out_t *p_out,
153                                      mtime_t i_pts_delay, mtime_t i_pts_jitter, int i_cr_average )
154 {
155     int i_ret = es_out_Control( p_out, ES_OUT_SET_JITTER,
156                                 i_pts_delay, i_pts_jitter, i_cr_average );
157     assert( !i_ret );
158 }
es_out_GetEsObjects(es_out_t * p_out,int i_id,vlc_object_t ** pp_decoder,vout_thread_t ** pp_vout,audio_output_t ** pp_aout)159 static inline int es_out_GetEsObjects( es_out_t *p_out, int i_id,
160                                        vlc_object_t **pp_decoder, vout_thread_t **pp_vout, audio_output_t **pp_aout )
161 {
162     return es_out_Control( p_out, ES_OUT_GET_ES_OBJECTS_BY_ID, i_id, pp_decoder, pp_vout, pp_aout );
163 }
es_out_GetGroupForced(es_out_t * p_out)164 static inline int es_out_GetGroupForced( es_out_t *p_out )
165 {
166     int i_group;
167     int i_ret = es_out_Control( p_out, ES_OUT_GET_GROUP_FORCED, &i_group );
168     assert( !i_ret );
169     return i_group;
170 }
es_out_Eos(es_out_t * p_out)171 static inline void es_out_Eos( es_out_t *p_out )
172 {
173     int i_ret = es_out_Control( p_out, ES_OUT_SET_EOS );
174     assert( !i_ret );
175 }
176 
177 es_out_t  *input_EsOutNew( input_thread_t *, int i_rate );
178 
179 #endif
180