3 * @brief Legacy monolithic LibVLC video window provider
5 /*****************************************************************************
6 * Copyright © 2009 Rémi Denis-Courmont
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2.0
11 * of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 ****************************************************************************/
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_vout_window.h>
34 static int Open (vlc_object_t *);
35 static void Close(vlc_object_t *);
41 set_shortname (N_("Drawable"))
42 set_description (N_("Embedded window video"))
43 set_category (CAT_VIDEO)
44 set_subcategory (SUBCAT_VIDEO_VOUT)
45 set_capability ("vout window hwnd", 70)
46 set_callbacks (Open, Close)
47 //add_integer ("drawable-hwnd", 0, NULL, HWN_TEXT, HWND_LONGTEXT, true) /* How to ? */
48 // change_unsaveable ()
51 static int Control (vout_window_t *, int, va_list);
53 static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
56 * Find the drawable set by libvlc application.
58 static int Open (vlc_object_t *obj)
60 vout_window_t *wnd = (vout_window_t *)obj;
64 if (var_Create (obj->p_libvlc, "hwnd-in-use", VLC_VAR_ADDRESS)
65 || var_Create (obj, "drawable-hwnd", VLC_VAR_DOINHERIT | VLC_VAR_ADDRESS))
68 val = var_GetAddress (obj, "drawable-hwnd");
69 var_Destroy (obj, "drawable-hwn");
71 /* Keep a list of busy drawables, so we don't overlap videos if there are
72 * more than one video track in the stream. */
73 vlc_mutex_lock (&serializer);
74 /* TODO: per-type list of busy drawables */
75 used = var_GetAddress (obj->p_libvlc, "drawables-in-use");
78 while (used[n] != NULL)
86 used = realloc (used, sizeof (*used) * (n + 2));
91 var_SetAddress (obj->p_libvlc, "hwnd-in-use", used);
96 msg_Warn (wnd, "HWND %p is busy", val);
99 vlc_mutex_unlock (&serializer);
104 wnd->handle.hwnd = val;
105 wnd->control = Control;
111 * Release the drawable.
113 static void Close (vlc_object_t *obj)
115 vout_window_t *wnd = (vout_window_t *)obj;
116 void **used, *val = wnd->sys;
119 /* Remove this drawable from the list of busy ones */
120 vlc_mutex_lock (&serializer);
121 used = var_GetAddress (obj->p_libvlc, "hwnd-in-use");
123 while (used[n] != val)
129 used[n] = used[n + 1];
130 while (used[++n] != NULL);
133 var_SetAddress (obj->p_libvlc, "hwnd-in-use", NULL);
134 vlc_mutex_unlock (&serializer);
138 /* Variables are reference-counted... */
139 var_Destroy (obj->p_libvlc, "hwnd-in-use");
143 static int Control (vout_window_t *wnd, int query, va_list ap)
149 case VOUT_WINDOW_SET_SIZE: /* not allowed */
150 case VOUT_WINDOW_SET_ON_TOP: /* not allowed either, would be ugly */
153 msg_Warn (wnd, "unsupported control query %d", query);