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
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 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 (vout_window_t *, const vout_window_cfg_t *);
35 static void Close(vout_window_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", 0)
46 set_callbacks (Open, Close)
47 add_shortcut ("embed-hwnd")
50 static int Control (vout_window_t *, int, va_list);
52 /* Keep a list of busy drawables, so we don't overlap videos if there are
53 * more than one video track in the stream. */
54 static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
55 static void **used = NULL;
58 * Find the drawable set by libvlc application.
60 static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
63 void *val = var_InheritAddress (wnd, "drawable-hwnd");
70 vlc_mutex_lock (&serializer);
72 for (/*n = 0*/; used[n] != NULL; n++)
75 msg_Warn (wnd, "HWND %p is busy", val);
80 tab = realloc (used, sizeof (*used) * (n + 2));
81 if (likely(tab != NULL))
90 vlc_mutex_unlock (&serializer);
95 wnd->handle.hwnd = val;
96 wnd->control = Control;
102 * Release the drawable.
104 static void Close (vout_window_t *wnd)
106 void *val = wnd->sys;
109 /* Remove this drawable from the list of busy ones */
110 vlc_mutex_lock (&serializer);
111 assert (used != NULL);
112 while (used[n] != val)
114 assert (used[n] != NULL);
118 used[n] = used[n + 1];
119 while (used[++n] != NULL);
126 vlc_mutex_unlock (&serializer);
130 static int Control (vout_window_t *wnd, int query, va_list ap)
136 case VOUT_WINDOW_SET_SIZE: /* not allowed */
137 case VOUT_WINDOW_SET_STATE: /* not allowed either, would be ugly */
140 msg_Warn (wnd, "unsupported control query %d", query);