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/libvlc.h>
29 void libvlc_input_free( libvlc_input_t *p_input )
36 * Retrieve the input thread. Be sure to release the object
37 * once you are done with it.
39 input_thread_t *libvlc_get_input_thread( libvlc_input_t *p_input,
40 libvlc_exception_t *p_e )
42 input_thread_t *p_input_thread;
46 libvlc_exception_raise( p_e, "Input is NULL" );
50 p_input_thread = (input_thread_t*)vlc_object_get(
51 p_input->p_instance->p_vlc,
52 p_input->i_input_id );
55 libvlc_exception_raise( p_e, "Input does not exist" );
59 return p_input_thread;
64 /**************************************************************************
65 * Getters for stream information
66 **************************************************************************/
67 vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
68 libvlc_exception_t *p_exception )
70 input_thread_t *p_input_thread;
73 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
75 if ( libvlc_exception_raised( p_exception ) )
78 var_Get( p_input_thread, "length", &val );
79 vlc_object_release( p_input_thread );
81 return val.i_time / 1000;
84 vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
85 libvlc_exception_t *p_exception )
87 input_thread_t *p_input_thread;
91 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
93 if ( libvlc_exception_raised( p_exception ) )
96 var_Get( p_input_thread , "time", &val );
97 vlc_object_release( p_input_thread );
99 return val.i_time / 1000;
102 float libvlc_input_get_position( libvlc_input_t *p_input,
103 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 ) )
113 var_Get( p_input_thread, "position", &val );
114 vlc_object_release( p_input_thread );
119 vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input,
120 libvlc_exception_t *p_exception)
122 input_thread_t *p_input_thread;
124 p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
126 if ( libvlc_exception_raised( p_exception ) )
129 if ( !p_input_thread->b_die && !p_input_thread->b_dead )
131 vlc_object_release( p_input_thread );
135 vlc_object_release( p_input_thread );