[vlc-devel] [PATCH] mmal/vout: Implement a dummy window

Julian Scheel julian at jusst.de
Fri Oct 20 18:35:03 CEST 2017


Adds a fake window implementation to force the rendering into fullscreen
at any time.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 include/vlc_vout_window.h |  1 +
 modules/hw/mmal/vout.c    | 68 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index 3a613d4e47..ae47781eee 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -53,6 +53,7 @@ enum vout_window_type {
     VOUT_WINDOW_TYPE_NSOBJECT /**< MacOS X view */,
     VOUT_WINDOW_TYPE_ANDROID_NATIVE /**< Android native window */,
     VOUT_WINDOW_TYPE_WAYLAND /**< Wayland surface */,
+    VOUT_WINDOW_TYPE_MMAL /**< MMAL dummy window */,
 };
 
 /**
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index dc5807edd6..80862542b1 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -33,6 +33,7 @@
 #include <vlc_plugin.h>
 #include <vlc_threads.h>
 #include <vlc_vout_display.h>
+#include <vlc_vout_window.h>
 
 #include "mmal_picture.h"
 
@@ -71,6 +72,9 @@
 static int Open(vlc_object_t *);
 static void Close(vlc_object_t *);
 
+static int window_Open(vout_window_t *wnd, vout_window_cfg_t *cfg);
+static void window_Close(vout_window_t *wnd);
+
 vlc_module_begin()
     set_shortname(N_("MMAL vout"))
     set_description(N_("MMAL-based vout plugin for Raspberry Pi"))
@@ -84,6 +88,11 @@ vlc_module_begin()
     add_bool(MMAL_NATIVE_INTERLACED, false, MMAL_NATIVE_INTERLACE_TEXT,
                     MMAL_NATIVE_INTERLACE_LONGTEXT, false)
     set_callbacks(Open, Close)
+
+    add_submodule()
+        set_capability("vout window", 1)
+        set_callbacks(window_Open, window_Close)
+
 vlc_module_end()
 
 struct dmx_region_t {
@@ -104,6 +113,8 @@ struct vout_display_sys_t {
     vlc_mutex_t buffer_mutex;
     vlc_mutex_t manage_mutex;
 
+    vout_window_t *embed;
+
     plane_t planes[3]; /* Depending on video format up to 3 planes are used */
     picture_t **pictures; /* Actual list of alloced pictures passed into picture_pool */
     picture_pool_t *picture_pool;
@@ -163,7 +174,7 @@ static void control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
 static void input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
 
 /* TV service */
-static int query_resolution(vout_display_t *vd, unsigned *width, unsigned *height);
+static int query_resolution(vlc_object_t *obj, unsigned *width, unsigned *height);
 static void tvservice_cb(void *callback_data, uint32_t reason, uint32_t param1,
                 uint32_t param2);
 static void adjust_refresh_rate(vout_display_t *vd, const video_format_t *fmt);
@@ -181,6 +192,40 @@ static void dmx_region_delete(struct dmx_region_t *dmx_region,
 static void show_background(vout_display_t *vd, bool enable);
 static void maintain_phase_sync(vout_display_t *vd);
 
+/* Fake window implementation */
+static int window_Control(vout_window_t *wnd, int cmd, va_list ap)
+{
+    (void) wnd;
+    (void) ap;
+    return VLC_EGENERIC;
+}
+
+static int window_Open(vout_window_t *wnd, vout_window_cfg_t *cfg)
+{
+    unsigned width, height;
+
+    if (cfg->type != VOUT_WINDOW_TYPE_INVALID &&
+            cfg->type != VOUT_WINDOW_TYPE_MMAL)
+        return VLC_EGENERIC;
+
+    wnd->type = VOUT_WINDOW_TYPE_MMAL;
+    wnd->control = window_Control;
+
+    if (query_resolution((vlc_object_t*)wnd, &width, &height) >= 0) {
+        msg_Dbg(wnd, "Window report size: %dx%d", width, height);
+        vout_window_ReportSize(wnd, width, height);
+    } else
+        return VLC_EGENERIC;
+
+    return VLC_SUCCESS;
+}
+
+static void window_Close(vout_window_t *wnd)
+{
+    (void) wnd;
+}
+
+/* Vout */
 static int Open(vlc_object_t *object)
 {
     vout_display_t *vd = (vout_display_t *)object;
@@ -192,9 +237,6 @@ static int Open(vlc_object_t *object)
     int ret = VLC_SUCCESS;
     unsigned i;
 
-    if (vout_display_IsWindowed(vd))
-        return VLC_EGENERIC;
-
     sys = calloc(1, sizeof(struct vout_display_sys_t));
     if (!sys)
         return VLC_ENOMEM;
@@ -305,7 +347,7 @@ static int Open(vlc_object_t *object)
 
     vc_tv_register_callback(tvservice_cb, vd);
 
-    if (query_resolution(vd, &sys->display_width, &sys->display_height) >= 0) {
+    if (query_resolution((vlc_object_t*)vd, &sys->display_width, &sys->display_height) >= 0) {
         vout_display_SendEventDisplaySize(vd, sys->display_width, sys->display_height);
     } else {
         sys->display_width = vd->cfg->display.width;
@@ -315,6 +357,13 @@ static int Open(vlc_object_t *object)
     sys->dmx_handle = vc_dispmanx_display_open(0);
     vd->info.subpicture_chromas = subpicture_chromas;
 
+    sys->embed = vout_display_NewWindow(vd, VOUT_WINDOW_TYPE_MMAL);
+    if (!sys->embed) {
+        msg_Err(vd, "Failed to create mmal window");
+        ret = VLC_EGENERIC;
+        goto out;
+    }
+
 out:
     if (ret != VLC_SUCCESS)
         Close(object);
@@ -368,6 +417,9 @@ static void Close(vlc_object_t *object)
             msg_Warn(vd, "Could not reset hvs field mode");
     }
 
+    if (sys->embed)
+        vout_display_DeleteWindow(vd, sys->embed);
+
     free(sys->pictures);
     free(sys);
 
@@ -702,7 +754,7 @@ static void input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
     vlc_mutex_unlock(&sys->buffer_mutex);
 }
 
-static int query_resolution(vout_display_t *vd, unsigned *width, unsigned *height)
+static int query_resolution(vlc_object_t *obj, unsigned *width, unsigned *height)
 {
     TV_DISPLAY_STATE_T display_state;
     int ret = 0;
@@ -715,11 +767,11 @@ static int query_resolution(vout_display_t *vd, unsigned *width, unsigned *heigh
             *width = display_state.display.sdtv.width;
             *height = display_state.display.sdtv.height;
         } else {
-            msg_Warn(vd, "Invalid display state %"PRIx32, display_state.state);
+            msg_Warn(obj, "Invalid display state %"PRIx32, display_state.state);
             ret = -1;
         }
     } else {
-        msg_Warn(vd, "Failed to query display resolution");
+        msg_Warn(obj, "Failed to query display resolution");
         ret = -1;
     }
 
-- 
2.14.2



More information about the vlc-devel mailing list