opengl: factorize program creation
[vlc.git] / modules / video_output / wextern.c
blobaaa45ea5775db6de55f987809eb5d664c51acb8d
1 /**
2 * @file wextern.c
3 * @brief Dummy video window provider where the size is handled externally
4 */
5 /*****************************************************************************
6 * Copyright © 2019 VideoLabs, VideoLAN and VideoLAN Authors
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program 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 Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
27 #include <stdarg.h>
29 #include <vlc_common.h>
30 #include <vlc_plugin.h>
31 #include <vlc_vout_window.h>
33 #include <vlc/libvlc.h>
34 #include <vlc/libvlc_picture.h>
35 #include <vlc/libvlc_media.h>
36 #include <vlc/libvlc_renderer_discoverer.h>
37 #include <vlc/libvlc_media_player.h>
39 static int Open(vout_window_t *);
41 vlc_module_begin()
42 set_shortname(N_("Callback window"))
43 set_description(N_("External callback window"))
44 set_category(CAT_VIDEO)
45 set_subcategory(SUBCAT_VIDEO_VOUT)
46 set_capability("vout window", 0)
47 set_callback(Open)
48 vlc_module_end()
50 typedef struct {
51 void *opaque;
52 libvlc_video_output_set_resize_cb setResizeCb;
53 } wextern_t;
55 static void WindowResize(void *opaque, unsigned width, unsigned height)
57 vout_window_t *window = opaque;
58 vout_window_ReportSize(window, width, height);
61 static int Enable(struct vout_window_t *wnd, const vout_window_cfg_t *wcfg)
63 wextern_t *sys = wnd->sys;
65 if ( sys->setResizeCb != NULL )
66 /* bypass the size handling as the window doesn't handle the size */
67 sys->setResizeCb( sys->opaque, WindowResize, wnd );
69 (void) wcfg;
70 return VLC_SUCCESS;
73 static void Disable(struct vout_window_t *wnd)
75 wextern_t *sys = wnd->sys;
77 if ( sys->setResizeCb != NULL )
78 sys->setResizeCb( sys->opaque, NULL, NULL );
81 static const struct vout_window_operations ops = {
82 .enable = Enable,
83 .disable = Disable,
84 // .resize: don't let the core resize us on zoom/crop/ar changes
85 // the display module should do the ReportSize for us
88 static int Open(vout_window_t *wnd)
90 wextern_t *sys = vlc_obj_malloc(VLC_OBJECT(wnd), sizeof(*sys));
91 if (unlikely(sys==NULL))
92 return VLC_ENOMEM;
93 sys->opaque = var_InheritAddress( wnd, "vout-cb-opaque" );
94 sys->setResizeCb = var_InheritAddress( wnd, "vout-cb-resize-cb" );
96 wnd->sys = sys;
97 wnd->type = VOUT_WINDOW_TYPE_DUMMY;
98 wnd->ops = &ops;
99 return VLC_SUCCESS;