[vlc-devel] [PATCH] bin: add iosvlc.m for iOS development

Rémi Denis-Courmont remi at remlab.net
Wed May 6 11:02:19 CEST 2020


Hi,

Why do you make a static plugin here? Can't you use the dummy interface and have a proper stand-alone window provider, essentially like CLI VLC does on Unix?

Le 6 mai 2020 11:51:37 GMT+03:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
>iosvlc.m provides a binary usable as an iOS application, forwarding the
>VLC arguments just like VLC on desktop. It allows easier iteration on
>vlccore development for iOS, without the need to test in a VLCKit
>application like VLC for iOS or new external application.
>
>It must be built with dynamic plugins, just like --enable-vlc require
>it already in the configure.ac file.
>
>To develop with it, you must generate a .ipa archive containing both
>the resulting binary as executable, a PkgInfo file, an Info.plist file
>describing the package and the libs (libvlc.dylib, libvlccore.dylib,
>and
>every plugin .dylib or additional convenience libraries that are not
>linked statically in the Frameworks/ directory. It must then be signed
>with a developer certificate allowed by Apple and provisionned with a
>mobileprovision file allowing installation on the given device for the
>same developer certificate.
>
>Then, tools like libimobiledevice can be used to start the application
>with additional arguments or environment variables. They can also be
>added in XCode through the "Edit Scheme" menu.
>
>A big part of the iOS-specific code has been originally written by
>Marvin Scholz in a more complete libVLC ios sample.
>
>Co-authored-by: Marvin Scholz <epirat07 at gmail.com>
>---
> bin/Makefile.am |  10 ++++-
> bin/iosvlc.m    | 111 ++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 120 insertions(+), 1 deletion(-)
> create mode 100644 bin/iosvlc.m
>
>diff --git a/bin/Makefile.am b/bin/Makefile.am
>index 699fbd4bf0b..b752d968588 100644
>--- a/bin/Makefile.am
>+++ b/bin/Makefile.am
>@@ -5,10 +5,19 @@ if HAVE_OSX
> bin_PROGRAMS = vlc-osx
> noinst_PROGRAMS = vlc-osx-static
> else
>+if HAVE_IOS
>+vlc_ios_SOURCES = iosvlc.m
>+vlc_ios_LDFLAGS = $(LDFLAGS_vlc)
>-Wl,-framework,Foundation,-framework,UIKit
>+vlc_ios_LDFLAGS += -Xlinker -rpath -Xlinker "$(libdir)"
>+vlc_ios_CFLAGS = -fobjc-arc
>+vlc_ios_LDADD = ../lib/libvlc.la ../src/libvlccore.la
>+bin_PROGRAMS = vlc-ios
>+else
> bin_PROGRAMS = vlc
> noinst_PROGRAMS = vlc-static
> endif
> endif
>+endif
> EXTRA_DIST = vlc_win32_rc.rc.in
> CLEANFILES = vlc_win32_rc.rc
> 
>@@ -70,7 +79,6 @@ vlc_osx_static_OBJCFLAGS +=
>-F$(CONTRIB_DIR)/Frameworks
> vlc_osx_static_CPPFLAGS = -DHAVE_BREAKPAD
> endif
> 
>-
> #
> # Static (debug) VLC executable
> #
>diff --git a/bin/iosvlc.m b/bin/iosvlc.m
>new file mode 100644
>index 00000000000..f671615e602
>--- /dev/null
>+++ b/bin/iosvlc.m
>@@ -0,0 +1,111 @@
>+/*****************************************************************************
>+ * iosvlc.m: iOS specific development main executable for VLC media
>player
>+
>*****************************************************************************
>+ * Copyright (C) 2020 Videolabs
>+ *
>+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
>+ *          Alexandre Janniaux <ajanni at videolabs.io>
>+ *
>+ * 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.
>+
>*****************************************************************************/
>+
>+#ifdef HAVE_CONFIG_H
>+# include "config.h"
>+#endif
>+
>+#import <UIKit/UIKit.h>
>+#include <vlc/vlc.h>
>+
>+#include <vlc_common.h>
>+#include <vlc_variables.h>
>+#include <vlc_plugin.h>
>+
>+ at interface AppDelegate : UIResponder <UIApplicationDelegate> {
>+    @public
>+    libvlc_instance_t *_libvlc;
>+    UIWindow *window;
>+}
>+ at end
>+
>+
>+ at implementation AppDelegate
>+/* Called after application launch */
>+- (BOOL)application:(UIApplication *)application
>didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
>+{
>+    /* Set VLC_PLUGIN_PATH for dynamic loading */
>+    NSString *pluginsDirectory = [[NSBundle mainBundle]
>privateFrameworksPath];
>+    setenv("VLC_PLUGIN_PATH", [pluginsDirectory UTF8String], 1);
>+
>+    /* Store startup arguments to forward them to libvlc */
>+    NSArray *arguments = [[NSProcessInfo processInfo] arguments];
>+    unsigned vlc_argc = [arguments count];
>+    char **vlc_argv = (char **)malloc(vlc_argc * sizeof(char*));
>+    if (vlc_argv == NULL)
>+        return NO;
>+
>+    for (unsigned i = 0; i < vlc_argc; i++)
>+         vlc_argv[i] = [[arguments objectAtIndex:i] UTF8String];
>+
>+    /* Initialize libVLC */
>+    _libvlc = libvlc_new(vlc_argc, (const char * const*)vlc_argv);
>+    free(vlc_argv);
>+
>+    if (_libvlc == NULL)
>+        return NO;
>+
>+    /* Initialize main window */
>+    window = [[UIWindow alloc]
>initWithFrame:UIScreen.mainScreen.bounds];
>+    window.rootViewController = [UIViewController alloc];
>+    window.backgroundColor = [UIColor whiteColor];
>+    [window makeKeyAndVisible];
>+
>+    /* Start glue interface, see code below */
>+    libvlc_add_intf(_libvlc, "ios_interface,none");
>+
>+    /* Start parsing arguments and eventual playback */
>+    libvlc_playlist_play(_libvlc);
>+
>+    return YES;
>+}
>+ at end
>+
>+int main(int argc, char * argv[]) {
>+    @autoreleasepool {
>+        return UIApplicationMain(argc, argv, nil,
>NSStringFromClass([AppDelegate class]));
>+    }
>+}
>+
>+/* Glue interface code, define drawable-nsobject for display module */
>+static int Open(vlc_object_t *obj)
>+{
>+    AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication]
>delegate];
>+    assert(d != nil && d->window != nil);
>+    var_SetAddress(vlc_object_instance(obj), "drawable-nsobject",
>d->window);
>+
>+    return VLC_SUCCESS;
>+}
>+
>+#define MODULE_NAME ios_interface
>+#define MODULE_STRING "ios_interface"
>+vlc_module_begin()
>+    set_capability("interface", 0)
>+    set_callback(Open)
>+vlc_module_end()
>+
>+/* Inject the glue interface as a static module */
>+typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
>+
>+__attribute__((visibility("default")))
>+vlc_plugin_cb vlc_static_modules[] = { vlc_entry__ios_interface, NULL
>};
>-- 
>2.26.2
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200506/7324b334/attachment.html>


More information about the vlc-devel mailing list