[PATCH] Add API for making a (SDL) window full-screen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

The attached patch adds a cap which allows a window to be togged
full-screen. It's currently only implemented for the SDL renderer device.

Hope that's useful and can be included in the projetc.


Cheers,

-- 
Saúl
From d6fb3d6e4941c1f120c334b7460214cfb74ac08b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= <saghul@xxxxxxxxx>
Date: Thu, 26 Jan 2017 12:18:40 -0600
Subject: [PATCH] pjmedia: add ability to set a SDL window fullscreen

---
 pjmedia/include/pjmedia/videodev.h     | 11 ++++++++++
 pjmedia/src/pjmedia-videodev/sdl_dev.c | 23 ++++++++++++++++++++
 pjmedia/src/pjmedia/videodev.c         |  6 +++++-
 pjsip/include/pjsua-lib/pjsua.h        | 11 ++++++++++
 pjsip/src/pjsua-lib/pjsua_vid.c        | 29 ++++++++++++++++++++++++++
 5 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/pjmedia/include/pjmedia/videodev.h b/pjmedia/include/pjmedia/videodev.h
index adc81b7d3..92a4f8eec 100644
--- a/pjmedia/include/pjmedia/videodev.h
+++ b/pjmedia/include/pjmedia/videodev.h
@@ -274,6 +274,11 @@ typedef enum pjmedia_vid_dev_cap
      */
     PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS = 512,
 
+    /**
+     * Support for setting the output video window full screen.
+     */
+    PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN = 1024,
+
     /**
      * End of standard capability
      */
@@ -463,6 +468,12 @@ typedef struct pjmedia_vid_dev_param
      */
     unsigned window_flags;
 
+    /**
+     * Video window's full screen status. This setting is optional, and will only be
+     * used if PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN is set in the flags.
+     */
+    pj_bool_t window_fullscreen;
+
 } pjmedia_vid_dev_param;
 
 
diff --git a/pjmedia/src/pjmedia-videodev/sdl_dev.c b/pjmedia/src/pjmedia-videodev/sdl_dev.c
index ce593e031..c16fe2eb9 100644
--- a/pjmedia/src/pjmedia-videodev/sdl_dev.c
+++ b/pjmedia/src/pjmedia-videodev/sdl_dev.c
@@ -701,6 +701,12 @@ static pj_status_t sdl_create_window(struct sdl_stream *strm,
             flags |= SDL_WINDOW_HIDDEN;
         }
 
+        if (!((strm->param.flags & PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN) &&
+            strm->param.window_fullscreen))
+        {
+            flags |= SDL_WINDOW_FULLSCREEN;
+        }
+
 #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL
         if (strm->param.rend_id == OPENGL_DEV_IDX)
             flags |= SDL_WINDOW_OPENGL;
@@ -1017,6 +1023,11 @@ static pj_status_t sdl_stream_get_param(pjmedia_vid_dev_stream *s,
     {
 	pi->flags |= PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS;
     }
+    if (sdl_stream_get_cap(s, PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN,
+			   &pi->window_fullscreen) == PJ_SUCCESS)
+    {
+	pi->flags |= PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN;
+    }
 
     return PJ_SUCCESS;
 }
@@ -1093,6 +1104,10 @@ static pj_status_t get_cap(void *data)
         if (flag & SDL_WINDOW_RESIZABLE)
             *wnd_flags |= PJMEDIA_VID_DEV_WND_RESIZABLE;
 	return PJ_SUCCESS;
+    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN) {
+	Uint32 flag = SDL_GetWindowFlags(strm->window);
+	*((pj_bool_t *)pval) = (flag & SDL_WINDOW_FULLSCREEN)? PJ_TRUE: PJ_FALSE;
+	return PJ_SUCCESS;
     }
 
     return PJMEDIA_EVID_INVCAP;
@@ -1188,6 +1203,14 @@ static pj_status_t set_cap(void *data)
 		      "Re-initializing SDL with native window %d",
 		      hwnd->info.window));
 	return status;	
+    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN) {
+        int flag;
+        if (*(pj_bool_t *)pval)
+            flag = SDL_WINDOW_FULLSCREEN;
+        else
+            flag = 0;
+        SDL_SetWindowFullscreen(strm->window, flag);
+	return PJ_SUCCESS;
     }
 
     return PJMEDIA_EVID_INVCAP;
diff --git a/pjmedia/src/pjmedia/videodev.c b/pjmedia/src/pjmedia/videodev.c
index 84d260697..a9584ebe2 100644
--- a/pjmedia/src/pjmedia/videodev.c
+++ b/pjmedia/src/pjmedia/videodev.c
@@ -47,7 +47,8 @@ static struct cap_info
     DEFINE_CAP("preview",       "Input preview"),
     DEFINE_CAP("orientation",   "Video orientation"),
     DEFINE_CAP("switch",        "Switch device"),
-    DEFINE_CAP("wndflags",      "Window flags")
+    DEFINE_CAP("wndflags",      "Window flags"),
+    DEFINE_CAP("fullscreen",    "Renderer fullscreen")
 };
 
 
@@ -140,6 +141,9 @@ static pj_status_t get_cap_pointer(const pjmedia_vid_dev_param *param,
     case PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS:
 	FIELD_INFO(window_flags);
 	break;
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN:
+	FIELD_INFO(window_fullscreen);
+	break;
     default:
 	return PJMEDIA_EVID_INVCAP;
     }
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 8aec32173..a81fcb94d 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -8053,6 +8053,17 @@ PJ_DECL(pj_status_t) pjsua_vid_win_rotate(pjsua_vid_win_id wid,
 					  int angle);
 
 
+/**
+ * Set video window full-screen.
+ *
+ * @param wid		The video window ID.
+ * @param enabled   	True if full screen is desired, false otherwise.
+ *
+ * @return		PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsua_vid_win_set_fullscreen(pjsua_vid_win_id wid,
+                                                  pj_bool_t enabled);
+
 /*
  * Video codecs API
  */
diff --git a/pjsip/src/pjsua-lib/pjsua_vid.c b/pjsip/src/pjsua-lib/pjsua_vid.c
index 222b71dd7..4bf59f0ff 100644
--- a/pjsip/src/pjsua-lib/pjsua_vid.c
+++ b/pjsip/src/pjsua-lib/pjsua_vid.c
@@ -1719,6 +1719,35 @@ PJ_DEF(pj_status_t) pjsua_vid_win_rotate( pjsua_vid_win_id wid,
 }
 
 
+/*
+ * Set video window fullscreen.
+ */
+PJ_DEF(pj_status_t) pjsua_vid_win_set_fullscreen( pjsua_vid_win_id wid,
+                                                  pj_bool_t enabled)
+{
+    pjsua_vid_win *w;
+    pjmedia_vid_dev_stream *s;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(wid >= 0 && wid < PJSUA_MAX_VID_WINS, PJ_EINVAL);
+
+    PJSUA_LOCK();
+
+    w = &pjsua_var.win[wid];
+    s = pjmedia_vid_port_get_stream(w->vp_rend? w->vp_rend: w->vp_cap);
+    if (s == NULL) {
+	PJSUA_UNLOCK();
+	return PJ_EINVAL;
+    }
+
+    status = pjmedia_vid_dev_stream_set_cap(s,
+			    PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN, &enabled);
+
+    PJSUA_UNLOCK();
+
+    return status;
+}
+
 static void call_get_vid_strm_info(pjsua_call *call,
 				   int *first_active,
 				   int *first_inactive,
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux