]> git.sesse.net Git - vlc/blob - src/control/libvlc_input.c
Be consistant in naming
[vlc] / src / control / libvlc_input.c
1 /*****************************************************************************
2  * input.c: Libvlc new API input management functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include <libvlc_internal.h>
25 #include <vlc/libvlc.h>
26
27 #include <vlc/intf.h>
28
29 void libvlc_input_free( libvlc_input_t *p_input )
30 {
31     if( p_input )
32         free( p_input );
33 }
34
35 /**************************************************************************
36  * Getters for stream information
37  **************************************************************************/
38 vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
39                              libvlc_exception_t *p_exception )
40 {
41     input_thread_t *p_input_thread;
42     vlc_value_t val;
43
44     if( !p_input )
45     {
46         libvlc_exception_raise( p_exception, "Input is NULL" );
47         return -1;
48     }
49
50     p_input_thread = (input_thread_t*)vlc_object_get(
51                                  p_input->p_instance->p_vlc,
52                                  p_input->i_input_id );
53     if( !p_input_thread )
54     {
55         libvlc_exception_raise( p_exception, "Input does not exist" );
56         return -1;
57     }
58     var_Get( p_input_thread, "length", &val );
59     vlc_object_release( p_input_thread );
60
61     return val.i_time / 1000;
62 }
63
64 vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
65                            libvlc_exception_t *p_exception )
66 {
67     input_thread_t *p_input_thread;
68     vlc_value_t val;
69
70     if( !p_input )
71     {
72         libvlc_exception_raise( p_exception, "Input is NULL" );
73         return -1;
74     }
75
76     p_input_thread = (input_thread_t*)vlc_object_get(
77                                  p_input->p_instance->p_vlc,
78                                  p_input->i_input_id );
79     if( !p_input_thread )
80     {
81         libvlc_exception_raise( p_exception, "Input does not exist" );
82         return -1;
83     }
84     var_Get( p_input_thread , "time", &val );
85     vlc_object_release( p_input_thread );
86
87     return val.i_time / 1000;
88 }
89
90 float libvlc_input_get_position( libvlc_input_t *p_input,
91                                  libvlc_exception_t *p_exception )
92 {
93     input_thread_t *p_input_thread;
94     vlc_value_t val;
95
96     if( !p_input )
97     {
98         libvlc_exception_raise( p_exception, "Input is NULL" );
99         return -1;
100     }
101
102     p_input_thread = (input_thread_t*)vlc_object_get(
103                             p_input->p_instance->p_vlc,
104                             p_input->i_input_id );
105     if( !p_input_thread )
106     {
107         libvlc_exception_raise( p_exception, "Input does not exist" );
108         return -1.0;
109     }
110     var_Get( p_input_thread, "position", &val );
111     vlc_object_release( p_input_thread );
112
113     return val.f_float;
114 }