video_output/video_widgets.c \
video_output/vout_subpictures.c \
video_output/window.c \
+ video_output/window.h \
video_output/opengl.c \
video_output/vout_intf.c \
video_output/vout_internal.h \
#include <libvlc.h>
#include "display.h"
+#include "window.h"
#include "event.h"
static vout_window_t *VoutDisplayNewWindow(vout_display_t *vd, const vout_window_cfg_t *cfg)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
+ vout_window_t *window;
#ifdef ALLOW_DUMMY_VOUT
if (!osys->vout->p) {
if (!var_InheritBool(osys->vout, "embedded-video"))
cfg_override.is_standalone = true;
- return vout_window_New(VLC_OBJECT(osys->vout), "$window",
- &cfg_override, NULL);
+ window = vout_display_window_New(osys->vout, &cfg_override);
}
+ else
#endif
- return vout_NewDisplayWindow(osys->vout, cfg);
+ window = vout_NewDisplayWindow(osys->vout, cfg);
+
+ if (window != NULL)
+ vout_display_window_Attach(window, vd);
+ return window;
}
static void VoutDisplayDelWindow(vout_display_t *vd, vout_window_t *window)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
+ if (window != NULL)
+ vout_display_window_Detach(window);
#ifdef ALLOW_DUMMY_VOUT
if (!osys->vout->p) {
if( window)
- vout_window_Delete(window);
- return;
+ vout_display_window_Delete(window);
}
#endif
- vout_DeleteDisplayWindow(osys->vout, window);
+ else
+ vout_DeleteDisplayWindow(osys->vout, window);
}
static void VoutDisplayFitWindow(vout_display_t *vd, bool default_size)
static vout_window_t *SplitterNewWindow(vout_display_t *vd, const vout_window_cfg_t *cfg_ptr)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
+ vout_window_t *window;
vout_window_cfg_t cfg = *cfg_ptr;
cfg.is_standalone = true;
- return vout_window_New(VLC_OBJECT(osys->vout), "$window", &cfg, NULL);
+ window = vout_display_window_New(osys->vout, &cfg);
+ if (window != NULL)
+ vout_display_window_Attach(window, vd);
+ return window;
}
static void SplitterDelWindow(vout_display_t *vd, vout_window_t *window)
{
- if (window != NULL)
- vout_window_Delete(window);
+ if (window != NULL) {
+ vout_display_window_Detach(window);
+ vout_display_window_Delete(window);
+ }
(void) vd;
}
#include "vout_internal.h"
#include "interlacing.h"
#include "display.h"
+#include "window.h"
/*****************************************************************************
* Local prototypes
.height = cfg->fmt->i_visible_height,
};
- vout->p->window = vout_window_New(VLC_OBJECT(vout), "$window", &wcfg,
- NULL);
+ vout->p->window = vout_display_window_New(vout, &wcfg);
} else
vout->p->window = NULL;
void vout_DeleteDisplayWindow(vout_thread_t *vout, vout_window_t *window)
{
if (window == NULL && vout->p->window != NULL) {
- vout_window_Delete(vout->p->window);
+ vout_display_window_Delete(vout->p->window);
vout->p->window = NULL;
}
assert(vout->p->window == window);
vlc_module_unload(w->module, vout_window_stop, window);
vlc_object_release(window);
}
+
+/* Video output display integration */
+#include <vlc_vout_display.h>
+#include "window.h"
+
+typedef struct vout_display_window
+{
+ vout_display_t *vd;
+ unsigned width;
+ unsigned height;
+
+ vlc_mutex_t lock;
+} vout_display_window_t;
+
+static void vout_display_window_ResizeNotify(vout_window_t *window,
+ unsigned width, unsigned height)
+{
+ vout_display_window_t *state = window->owner.sys;
+
+ msg_Dbg(window, "resized to %ux%u", width, height);
+ vlc_mutex_lock(&state->lock);
+ state->width = width;
+ state->height = height;
+
+ if (state->vd != NULL)
+ vout_display_SendEventDisplaySize(state->vd, width, height);
+ vlc_mutex_unlock(&state->lock);
+}
+
+/**
+ * Creates a video window, initially without any attached display.
+ */
+vout_window_t *vout_display_window_New(vout_thread_t *vout,
+ const vout_window_cfg_t *cfg)
+{
+ vout_display_window_t *state = malloc(sizeof (*state));
+ if (state == NULL)
+ return NULL;
+
+ state->vd = NULL;
+ state->width = cfg->width;
+ state->height = cfg->height;
+ vlc_mutex_init(&state->lock);
+
+ vout_window_owner_t owner = {
+ .sys = state,
+ .resized = vout_display_window_ResizeNotify,
+ };
+ vout_window_t *window;
+
+ window = vout_window_New((vlc_object_t *)vout, "$window", cfg, &owner);
+ if (window == NULL) {
+ vlc_mutex_destroy(&state->lock);
+ free(state);
+ }
+ return window;
+}
+
+/**
+ * Attaches a window to a display. Window events will be dispatched to the
+ * display until they are detached.
+ */
+void vout_display_window_Attach(vout_window_t *window, vout_display_t *vd)
+{
+ vout_display_window_t *state = window->owner.sys;
+
+ vlc_mutex_lock(&state->lock);
+ state->vd = vd;
+
+ vout_display_SendEventDisplaySize(vd, state->width, state->height);
+ vlc_mutex_unlock(&state->lock);
+}
+
+/**
+ * Detaches a window from a display. Window events will no longer be dispatched
+ * (except those that do not need a display).
+ */
+void vout_display_window_Detach(vout_window_t *window)
+{
+ vout_display_window_t *state = window->owner.sys;
+
+ vlc_mutex_lock(&state->lock);
+ state->vd = NULL;
+ vlc_mutex_unlock(&state->lock);
+}
+
+/**
+ * Destroys a video window.
+ * \note The window must be detached.
+ */
+void vout_display_window_Delete(vout_window_t *window)
+{
+ vout_display_window_t *state = window->owner.sys;
+
+ vout_window_Delete(window);
+
+ assert(state->vd == NULL);
+ vlc_mutex_destroy(&state->lock);
+ free(state);
+}
--- /dev/null
+/*****************************************************************************
+ * window.h: window managment for VLC video output
+ *****************************************************************************
+ * Copyright © 2014 Rémi Denis-Courmont
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+vout_window_t *vout_display_window_New(vout_thread_t *,
+ const vout_window_cfg_t *);
+void vout_display_window_Attach(vout_window_t *, vout_display_t *);
+void vout_display_window_Detach(vout_window_t *);
+void vout_display_window_Delete(vout_window_t *);