1 /*****************************************************************************
2 * input.c: Libvlc new API input management functions
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include <libvlc_internal.h>
25 #include <vlc_demux.h>
26 #include <vlc/libvlc.h>
30 void libvlc_input_free( libvlc_input_t *p_input )
37 * Retrieve the input thread. Be sure to release the object
38 * once you are done with it.
40 input_thread_t *libvlc_get_input_thread( libvlc_input_t *p_input,
41 libvlc_exception_t *p_e )
43 input_thread_t *p_input_thread;
47 libvlc_exception_raise( p_e, "Input is NULL" );
51 p_input_thread = (input_thread_t*)vlc_object_get(
52 p_input->p_instance->p_vlc,
53 p_input->i_input_id );
56 libvlc_exception_raise( p_e, "Input does not exist" );
60 return p_input_thread;
65 /**************************************************************************
66 * Getters for stream information
67 **************************************************************************/
68 vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
69 libvlc_exception_t *p_exception )
71 input_thread_t *p_input_thread;
74 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
76 if ( libvlc_exception_raised( p_exception ) )
79 var_Get( p_input_thread, "length", &val );
80 vlc_object_release( p_input_thread );
82 return val.i_time / 1000;
85 vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
86 libvlc_exception_t *p_exception )
88 input_thread_t *p_input_thread;
92 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
94 if ( libvlc_exception_raised( p_exception ) )
97 var_Get( p_input_thread , "time", &val );
98 vlc_object_release( p_input_thread );
100 return val.i_time / 1000;
103 void libvlc_input_set_time( libvlc_input_t *p_input, vlc_int64_t time, libvlc_exception_t *p_exception )
105 input_thread_t *p_input_thread;
108 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
110 if ( libvlc_exception_raised( p_exception ) )
114 var_Set( p_input_thread, "time", value );
115 vlc_object_release( p_input_thread );
121 void libvlc_input_set_position( libvlc_input_t *p_input, float position, libvlc_exception_t *p_exception )
123 input_thread_t *p_input_thread;
126 val.f_float = position;
128 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
130 if ( libvlc_exception_raised( p_exception ) )
133 var_Set( p_input_thread, "position", val );
134 vlc_object_release( p_input_thread );
142 float libvlc_input_get_position( libvlc_input_t *p_input,
143 libvlc_exception_t *p_exception )
145 input_thread_t *p_input_thread;
148 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
150 if ( libvlc_exception_raised( p_exception ) )
153 var_Get( p_input_thread, "position", &val );
154 vlc_object_release( p_input_thread );
159 float libvlc_input_get_fps( libvlc_input_t *p_input,
160 libvlc_exception_t *p_exception)
163 input_thread_t *p_input_thread;
165 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
167 if( demux2_Control( p_input_thread->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
169 vlc_object_release( p_input_thread );
174 vlc_object_release( p_input_thread );
179 vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input,
180 libvlc_exception_t *p_exception)
182 input_thread_t *p_input_thread;
184 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
186 if ( libvlc_exception_raised( p_exception ) )
189 if ( !p_input_thread->b_die && !p_input_thread->b_dead )
191 vlc_object_release( p_input_thread );
195 vlc_object_release( p_input_thread );