1 /*****************************************************************************
2 * video.c: libvlc new API video functions
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * $Id: core.c 14187 2006-02-07 16:37:40Z courmisch $
8 * Authors: Clément Stenac <zorglub@videolan.org>
9 * Filippo Carone <littlejohn@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #include <libvlc_internal.h>
27 #include <vlc/libvlc.h>
33 * Remember to release the returned vout_thread_t since it is locked at
34 * the end of this function.
36 static vout_thread_t *GetVout( libvlc_input_t *p_input,
37 libvlc_exception_t *p_exception )
39 input_thread_t *p_input_thread;
40 vout_thread_t *p_vout;
44 libvlc_exception_raise( p_exception, "Input is NULL" );
48 p_input_thread = (input_thread_t*)vlc_object_get(
49 p_input->p_instance->p_vlc,
50 p_input->i_input_id );
53 libvlc_exception_raise( p_exception, "Input does not exist" );
57 p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD );
60 vlc_object_release( p_input_thread );
61 libvlc_exception_raise( p_exception, "No active video output" );
64 vlc_object_release( p_input_thread );
68 /**********************************************************************
70 **********************************************************************/
72 void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
73 libvlc_exception_t *p_e )
75 /* We only work on the first vout */
76 vout_thread_t *p_vout1 = GetVout( p_input, p_e );
77 vlc_value_t val; int i_ret;
79 /* GetVout will raise the exception for us */
85 if( b_fullscreen ) val.b_bool = VLC_TRUE;
86 else val.b_bool = VLC_FALSE;
88 i_ret = var_Set( p_vout1, "fullscreen", val );
90 libvlc_exception_raise( p_e,
91 "Unexpected error while setting fullscreen value" );
93 vlc_object_release( p_vout1 );
97 int libvlc_get_fullscreen( libvlc_input_t *p_input,
98 libvlc_exception_t *p_e )
100 /* We only work on the first vout */
101 vout_thread_t *p_vout1 = GetVout( p_input, p_e );
102 vlc_value_t val; int i_ret;
104 /* GetVout will raise the exception for us */
108 i_ret = var_Get( p_vout1, "fullscreen", &val );
110 libvlc_exception_raise( p_e,
111 "Unexpected error while looking up fullscreen value" );
113 return val.b_bool == VLC_TRUE ? 1 : 0;
116 void libvlc_toggle_fullscreen( libvlc_input_t *p_input,
117 libvlc_exception_t *p_e )
119 /* We only work on the first vout */
120 vout_thread_t *p_vout1 = GetVout( p_input, p_e );
121 vlc_value_t val; int i_ret;
123 /* GetVout will raise the exception for us */
127 i_ret = var_Get( p_vout1, "fullscreen", &val );
129 libvlc_exception_raise( p_e,
130 "Unexpected error while looking up fullscreen value" );
132 val.b_bool = !val.b_bool;
133 i_ret = var_Set( p_vout1, "fullscreen", val );
135 libvlc_exception_raise( p_e,
136 "Unexpected error while setting fullscreen value" );
138 vlc_object_release( p_vout1 );
143 libvlc_video_take_snapshot( libvlc_input_t *p_input, char *psz_filepath,
144 libvlc_exception_t *p_e )
146 vout_thread_t *p_vout = GetVout( p_input, p_e );
147 input_thread_t *p_input_thread;
151 /* GetVout will raise the exception for us */
157 p_input_thread = (input_thread_t*)vlc_object_get(
158 p_input->p_instance->p_vlc,
159 p_input->i_input_id );
160 if( !p_input_thread )
162 libvlc_exception_raise( p_e, "Input does not exist" );
166 snprintf( path, 255, "%s", psz_filepath );
167 var_SetString( p_vout, "snapshot-path", path );
168 var_SetString( p_vout, "snapshot-format", "png" );
170 vout_Control( p_vout, VOUT_SNAPSHOT );
171 vlc_object_release( p_vout );
172 vlc_object_release( p_input_thread );
178 int libvlc_video_get_height( libvlc_input_t *p_input,
179 libvlc_exception_t *p_e )
181 vout_thread_t *p_vout1 = GetVout( p_input, p_e );
185 vlc_object_release( p_vout1 );
187 return p_vout1->i_window_height;
190 int libvlc_video_get_width( libvlc_input_t *p_input,
191 libvlc_exception_t *p_e )
193 vout_thread_t *p_vout1 = GetVout( p_input, p_e );
197 vlc_object_release( p_vout1 );
199 return p_vout1->i_window_width;
202 vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
203 libvlc_exception_t *p_e )
205 vout_thread_t *p_vout = GetVout( p_input, p_e );
207 /* GetVout will raise the exception for us */
213 vlc_object_release( p_vout );
219 int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
220 libvlc_exception_t *p_e )
222 vout_thread_t *p_vout = GetVout( p_input, p_e );
223 vout_Control( p_vout , VOUT_REPARENT, d);
224 vlc_object_release( p_vout );
230 void libvlc_video_resize( libvlc_input_t *p_input, int width, int height, libvlc_exception_t *p_e )
232 vout_thread_t *p_vout = GetVout( p_input, p_e );
233 vout_Control( p_vout, VOUT_SET_SIZE, width, height );
234 vlc_object_release( p_vout );
238 int libvlc_video_destroy( libvlc_input_t *p_input,
239 libvlc_exception_t *p_e )
241 vout_thread_t *p_vout = GetVout( p_input, p_e );
242 vlc_object_detach( p_vout );
243 vlc_object_release( p_vout );
244 vout_Destroy( p_vout );