Skip to content
Snippets Groups Projects
Commit a24a9b28 authored by Alexandre Janniaux's avatar Alexandre Janniaux
Browse files

inhibit: add UIKit-based inhibiter

The inhibiter code is taken from VLCKit inhibiter's handling, and is
meant to replace this handling.
parent 9c051972
No related branches found
No related tags found
No related merge requests found
Pipeline #88513 passed with stages
in 26 minutes and 5 seconds
......@@ -52,6 +52,17 @@ libiokit_inhibit_plugin_la_LDFLAGS = $(AM_LDFLAGS) -Wl,-framework,CoreFoundation
misc_LTLIBRARIES += libiokit_inhibit_plugin.la
endif
libuikit_inhibit_plugin_la_SOURCES = misc/inhibit/uikit-inhibit.m
libuikit_inhibit_plugin_la_LDFLAGS = $(AM_LDFLAGS) -Wl,-framework,UIKit,-framework,Foundation
libuikit_inhibit_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
if HAVE_IOS
misc_LTLIBRARIES += libuikit_inhibit_plugin.la
endif
if HAVE_TVOS
misc_LTLIBRARIES += libuikit_inhibit_plugin.la
endif
libxdg_screensaver_plugin_la_SOURCES = misc/inhibit/xdg.c
if HAVE_XCB
if !HAVE_WIN32
......@@ -129,4 +140,3 @@ libmedialibrary_plugin_la_LIBADD = $(MEDIALIBRARY_LIBS)
libmedialibrary_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(miscdir)'
EXTRA_LTLIBRARIES += libmedialibrary_plugin.la
misc_LTLIBRARIES += $(LTLIBmedialibrary)
/*****************************************************************************
* Copyright © 2021 Videolabs
*
* 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.
*****************************************************************************/
/**
* \file uikit-inhibit.m
* \brief iOS display and idle sleep inhibitor using UIKit
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_inhibit.h>
#include <vlc_vout_window.h>
#include <UIKit/UIKit.h>
static void UpdateInhibit(vlc_inhibit_t *ih, unsigned mask)
{
[UIApplication sharedApplication].idleTimerDisabled =
(mask & VLC_INHIBIT_DISPLAY) == VLC_INHIBIT_DISPLAY;
}
static int OpenInhibit(vlc_object_t *obj)
{
vlc_inhibit_t *ih = (vlc_inhibit_t *)obj;
vout_window_t *wnd = vlc_inhibit_GetWindow(ih);
if (wnd->type != VOUT_WINDOW_TYPE_NSOBJECT)
return VLC_EGENERIC;
UIView * view = (__bridge UIView*)wnd->handle.nsobject;
if (unlikely(![view respondsToSelector:@selector(isKindOfClass:)]))
return VLC_EGENERIC;
if (![view isKindOfClass:[UIView class]])
return VLC_EGENERIC;
ih->inhibit = UpdateInhibit;
return VLC_SUCCESS;
}
vlc_module_begin()
set_shortname("UIKit sleep inhibition")
set_description("UIKit screen sleep inhibition for iOS and tvOS")
set_category(CAT_ADVANCED)
set_subcategory(SUBCAT_ADVANCED_MISC)
set_capability("inhibit", 10)
set_callback(OpenInhibit)
vlc_module_end()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment