]> git.sesse.net Git - vlc/blob - src/video_output/vout_intf.c
* src/input/*:
[vlc] / src / video_output / vout_intf.c
1 /*****************************************************************************
2  * vout_intf.c : video output interface
3  *****************************************************************************
4  * Copyright (C) 2000-2004 VideoLAN
5  * $Id: video_output.c 6961 2004-03-05 17:34:23Z sam $
6  *
7  * Authors: Gildas Bazin <gbazin@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                                /* free() */
28
29 #include <vlc/vlc.h>
30
31 #include "vlc_video.h"
32 #include "video_output.h"
33 #include "vlc_interface.h"
34
35 /*****************************************************************************
36  * Local prototypes
37  *****************************************************************************/
38
39 /*****************************************************************************
40  * vout_RequestWindow: Create/Get a video window if possible.
41  *****************************************************************************
42  * This function looks for the main interface and tries to request
43  * a new video window. If it fails then the vout will still need to create the
44  * window by itself.
45  *****************************************************************************/
46 void *vout_RequestWindow( vout_thread_t *p_vout,
47                           int *pi_x_hint, int *pi_y_hint,
48                           unsigned int *pi_width_hint,
49                           unsigned int *pi_height_hint )
50 {
51     intf_thread_t *p_intf;
52     void *p_window;
53     vlc_value_t val;
54
55     /* Get requested coordinates */
56     var_Get( p_vout, "video-x", &val );
57     *pi_x_hint = val.i_int ;
58     var_Get( p_vout, "video-y", &val );
59     *pi_y_hint = val.i_int;
60
61     *pi_width_hint = p_vout->i_window_width;
62     *pi_height_hint = p_vout->i_window_height;
63
64     /* Check whether someone provided us with a window ID */
65     var_Get( p_vout->p_vlc, "drawable", &val );
66     if( val.i_int ) return (void *)val.i_int;
67
68     /* Find the main interface */
69     p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
70     if( !p_intf ) return NULL;
71
72     if( !p_intf->pf_request_window )
73     {
74         vlc_object_release( p_intf );
75         return NULL;
76     }
77
78     p_window = p_intf->pf_request_window( p_intf, pi_x_hint, pi_y_hint,
79                                           pi_width_hint, pi_height_hint );
80     vlc_object_release( p_intf );
81
82     return p_window;
83 }
84
85 void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window )
86 {
87     intf_thread_t *p_intf;
88
89     /* Find the main interface */
90     p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
91     if( !p_intf ) return;
92
93     if( !p_intf->pf_release_window )
94     {
95         msg_Err( p_vout, "no pf_release_window");
96         vlc_object_release( p_intf );
97         return;
98     }
99
100     p_intf->pf_release_window( p_intf, p_window );
101     vlc_object_release( p_intf );
102 }