]> git.sesse.net Git - vlc/blob - src/video_output/window.c
Provide a type name for window objects
[vlc] / src / video_output / window.c
1 /*****************************************************************************
2  * window.c: "vout window" managment
3  *****************************************************************************
4  * Copyright (C) 2009 Laurent Aimar
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ 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 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 #include <assert.h>
31
32 #include <vlc_common.h>
33 #include <vlc_vout_window.h>
34 #include <libvlc.h>
35
36 vout_window_t *vout_window_New(vlc_object_t *obj,
37                                const char *module,
38                                const vout_window_cfg_t *cfg)
39 {
40     static char const name[] = "window";
41     vout_window_t *window = vlc_custom_create(obj, sizeof(*window),
42                                               VLC_OBJECT_GENERIC, name);
43     window->cfg = cfg;
44     memset(&window->handle, 0, sizeof(window->handle));
45     window->control = NULL;
46     window->sys = NULL;
47
48     vlc_object_attach(window, obj);
49
50     const char *type;
51     switch (cfg->type) {
52     case VOUT_WINDOW_TYPE_HWND:
53         type = "vout window hwnd";
54         break;
55     case VOUT_WINDOW_TYPE_XID:
56         type = "vout window xid";
57         break;
58     default:
59         assert(0);
60     }
61
62     window->module = module_need(window, type,
63                                  module, module && *module != '\0');
64     if (!window->module) {
65         vlc_object_detach(window);
66         vlc_object_release(window);
67         return NULL;
68     }
69     return window;
70 }
71
72 void vout_window_Delete(vout_window_t *window)
73 {
74     if (!window)
75         return;
76
77     vlc_object_detach(window);
78
79     module_unneed(window, window->module);
80
81     vlc_object_release(window);
82 }
83
84 int vout_window_Control(vout_window_t *window, int query, ...)
85 {
86     va_list args;
87     va_start(args, query);
88     int ret = window->control(window, query, args);
89     va_end(args);
90
91     return ret;
92 }
93