Commit a6b3e0d6 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Implement libvlc dialog API as class cluster

parent 360249c1
/*****************************************************************************
* VLCCustomDialogProvider.h: an implementation of the libvlc dialog API
* Included to allow custom UIs with full flexibility
*****************************************************************************
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan org>
* Pierre d'Herbemont <pdherbemont # videolan org>
*
* 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.
*****************************************************************************/
#import "VLCDialogProvider.h"
@interface VLCCustomDialogProvider : VLCDialogProvider
/**
* initializer method to run the dialog provider instance on a specific library instance
*
* \param the library instance
* \note if param is NULL, [VLCLibrary sharedLibrary] will be used
* \return the dialog provider instance, can be NULL on malloc failures
*/
- (instancetype __nullable)initWithLibrary:(VLCLibrary * __nullable)library;
@end
/*****************************************************************************
* VLCEmbeddedDialogProvider.h: an implementation of the libvlc dialog API
*****************************************************************************
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* 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.
*****************************************************************************/
#import "VLCDialogProvider.h"
@interface VLCEmbeddedDialogProvider : VLCDialogProvider
/**
* initializer method to run the dialog provider instance on a specific library instance
*
* \param the library instance
* \note if param is NULL, [VLCLibrary sharedLibrary] will be used
* \return the dialog provider instance, can be NULL on malloc failures
*/
- (instancetype __nullable)initWithLibrary:(VLCLibrary * __nullable)library;
@end
/*****************************************************************************
* VLCiOSLegacyDialogProvider.h: an implementation of the libvlc dialog API
* Included for compatiblity with iOS 7
*****************************************************************************
* Copyright (C) 2009, 2014-2015 VLC authors and VideoLAN
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan org>
* Pierre d'Herbemont <pdherbemont # videolan org>
*
* 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.
*****************************************************************************/
#import "VLCDialogProvider.h"
@interface VLCiOSLegacyDialogProvider : VLCDialogProvider
/**
* initializer method to run the dialog provider instance on a specific library instance
*
* \param the library instance
* \note if param is NULL, [VLCLibrary sharedLibrary] will be used
* \return the dialog provider instance, can be NULL on malloc failures
*/
- (instancetype __nullable)initWithLibrary:(VLCLibrary * __nullable)library;
@end
/*****************************************************************************
* VLCDialogProvider.h: an implementation of the libvlc dialog API
*****************************************************************************
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* 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.
*****************************************************************************/
@class VLCLibrary;
typedef NS_ENUM(NSUInteger, VLCDialogQuestionType) {
VLCDialogQuestionNormal,
VLCDialogQuestionWarning,
VLCDialogQuestionCritical,
};
@protocol VLCCustomDialogRendererProtocol <NSObject>
- (void)showErrorWithTitle:(NSString * _Nonnull)error
message:(NSString * _Nonnull)message;
- (void)showLoginWithTitle:(NSString * _Nonnull)title
message:(NSString * _Nonnull)message
defaultUsername:(NSString * _Nullable)username
askingForStorage:(BOOL)askingForStorage
withReference:(NSValue * _Nonnull)reference;
- (void)showQuestionWithTitle:(NSString * _Nonnull)title
message:(NSString * _Nonnull)message
type:(VLCDialogQuestionType)questionType
cancelString:(NSString * _Nullable)cancelString
action1String:(NSString * _Nullable)action1String
action2String:(NSString * _Nullable)action2String
withReference:(NSValue * _Nonnull)reference;
- (void)showProgressWithTitle:(NSString * _Nonnull)title
message:(NSString * _Nonnull)message
isIndeterminate:(BOOL)isIndeterminate
position:(float)position
cancelString:(NSString * _Nullable)cancelString
withReference:(NSValue * _Nonnull)reference;
- (void)updateProgressWithReference:(NSValue * _Nonnull)reference
message:(NSString * _Nullable)message
postion:(float)position;
- (void)cancelDialogWithReference:(NSValue * _Nonnull)reference;
@end
@interface VLCDialogProvider : NSObject
/**
* initializer method to run the dialog provider instance on a specific library instance
*
* \param the library instance
* \param enable custom UI mode
* \note if library param is NULL, [VLCLibrary sharedLibrary] will be used
* \return the dialog provider instance, can be NULL on malloc failures
*/
- (instancetype __nullable)initWithLibrary:(VLCLibrary * __nullable)library customUI:(BOOL)customUI;
/**
* initializer method to run the dialog provider instance on a specific library instance
*
* \param an object implementing the custom dialog rendering API
* \return the object set
*/
@property (weak, readwrite, nonatomic, nullable) id<VLCCustomDialogRendererProtocol> customRenderer;
- (void)postUsername:(NSString * _Nullable)username andPassword:(NSString * _Nullable)password forDialogReference:(NSValue * _Nonnull)dialogReference store:(BOOL)store;
- (void)postAction:(int)buttonNumber forDialogReference:(NSValue * _Nonnull)dialogReference;
- (void)dismissDialogWithReference:(NSValue * _Nonnull)dialogReference;
@end
......@@ -107,4 +107,6 @@
*/
- (void)setApplicationIdentifier:(NSString *)identifier withVersion:(NSString *)version andApplicationIconName:(NSString *)icon;
@property (nonatomic, assign) void *instance;
@end
......@@ -46,10 +46,20 @@
7D1329711BA3057E00BE647E /* VLCMediaDiscoverer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6360B0E311E7F0D300EAD790 /* VLCMediaDiscoverer.h */; };
7D1329721BA3057E00BE647E /* VLCTime.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7A5ECAD811DE8FAB00F66AF3 /* VLCTime.h */; };
7D1329741BA305A200BE647E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D1329731BA305A200BE647E /* Foundation.framework */; };
7D34F5521C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D34F5501C909DDF008A39F0 /* VLCCustomDialogProvider.m */; };
7D34F5531C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D34F5501C909DDF008A39F0 /* VLCCustomDialogProvider.m */; };
7D34F5541C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D34F5501C909DDF008A39F0 /* VLCCustomDialogProvider.m */; };
7D5F800A185B72EB00C2CD75 /* VLCMediaListPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D5F8009185B72EB00C2CD75 /* VLCMediaListPlayer.m */; };
7D5F800C185B733800C2CD75 /* VLCMediaListPlayer.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 7D5F800B185B730F00C2CD75 /* VLCMediaListPlayer.h */; };
7D6C89201C0CA81F00321894 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D6C891F1C0CA81F00321894 /* AVFoundation.framework */; };
7D6C89211C0CA90000321894 /* VLCAudio.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49C5FB1BC3D7870052D40C /* VLCAudio.m */; };
7D803EB61C8F21D200864A9C /* VLCDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EB51C8F21D200864A9C /* VLCDialogProvider.m */; };
7D803EC01C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EBE1C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m */; };
7D803EC11C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EBE1C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m */; };
7D803EC21C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EBE1C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m */; };
7D803EC61C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EC51C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m */; };
7D803EC71C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EC51C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m */; };
7D803EC91C8F2B0900864A9C /* VLCDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D803EB51C8F21D200864A9C /* VLCDialogProvider.m */; };
7D89392C1B500D1C008F2B14 /* DynamicMobileVLCKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D89392B1B500D1C008F2B14 /* DynamicMobileVLCKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
7D8939401B500D50008F2B14 /* VLCEventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A5ECAC411DE8F7300F66AF3 /* VLCEventManager.m */; };
7D8939411B500D50008F2B14 /* VLCLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A5ECAC511DE8F7300F66AF3 /* VLCLibrary.m */; };
......@@ -169,9 +179,17 @@
7D1329761BA306DE00BE647E /* vlc-plugins-iPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "vlc-plugins-iPhone.h"; path = "MobileVLCKit/vlc-plugins-iPhone.h"; sourceTree = "<group>"; };
7D1329771BA306E600BE647E /* vlc-plugins-AppleTV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "vlc-plugins-AppleTV.h"; path = "MobileVLCKit/vlc-plugins-AppleTV.h"; sourceTree = "<group>"; };
7D1329791BA3074100BE647E /* vlc-plugins-iPhone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "vlc-plugins-iPhone.xcconfig"; path = "MobileVLCKit/vlc-plugins-iPhone.xcconfig"; sourceTree = "<group>"; };
7D34F5501C909DDF008A39F0 /* VLCCustomDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCCustomDialogProvider.m; path = Sources/VLCCustomDialogProvider.m; sourceTree = "<group>"; };
7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCCustomDialogProvider.h; path = Headers/Internal/VLCCustomDialogProvider.h; sourceTree = "<group>"; };
7D5F8009185B72EB00C2CD75 /* VLCMediaListPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCMediaListPlayer.m; path = Sources/VLCMediaListPlayer.m; sourceTree = "<group>"; };
7D5F800B185B730F00C2CD75 /* VLCMediaListPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListPlayer.h; path = Headers/Public/VLCMediaListPlayer.h; sourceTree = "<group>"; };
7D6C891F1C0CA81F00321894 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
7D803EB51C8F21D200864A9C /* VLCDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCDialogProvider.m; path = Sources/VLCDialogProvider.m; sourceTree = "<group>"; };
7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCDialogProvider.h; path = Headers/Public/VLCDialogProvider.h; sourceTree = "<group>"; };
7D803EBE1C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCEmbeddedDialogProvider.m; path = Sources/VLCEmbeddedDialogProvider.m; sourceTree = "<group>"; };
7D803EC31C8F2AEF00864A9C /* VLCEmbeddedDialogProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCEmbeddedDialogProvider.h; path = Headers/Internal/VLCEmbeddedDialogProvider.h; sourceTree = "<group>"; };
7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCiOSLegacyDialogProvider.h; path = Headers/Internal/VLCiOSLegacyDialogProvider.h; sourceTree = "<group>"; };
7D803EC51C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCiOSLegacyDialogProvider.m; path = Sources/VLCiOSLegacyDialogProvider.m; sourceTree = "<group>"; };
7D8938BB1B5008E9008F2B14 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7D8938E81B500984008F2B14 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
7D8938EA1B50098C008F2B14 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
......@@ -312,6 +330,7 @@
636E975711EBC67A002FE8A9 /* VLCMediaThumbnailer.m */,
6360B0E111E7F0C000EAD790 /* VLCMediaDiscoverer.m */,
7A5ECAC911DE8F7300F66AF3 /* VLCTime.m */,
7D34F5571C909E13008A39F0 /* Dialogs */,
);
name = Sources;
sourceTree = "<group>";
......@@ -339,6 +358,7 @@
7A5ECAD711DE8FAB00F66AF3 /* VLCMediaPlayer.h */,
7D5F800B185B730F00C2CD75 /* VLCMediaListPlayer.h */,
6360B0E311E7F0D300EAD790 /* VLCMediaDiscoverer.h */,
7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */,
7A5ECAD811DE8FAB00F66AF3 /* VLCTime.h */,
);
name = Headers;
......@@ -351,6 +371,9 @@
7D1329771BA306E600BE647E /* vlc-plugins-AppleTV.h */,
7A5ECAE411DE8FEF00F66AF3 /* VLCLibVLCBridging.h */,
7A5ECAE511DE8FEF00F66AF3 /* VLCEventManager.h */,
7D803EC31C8F2AEF00864A9C /* VLCEmbeddedDialogProvider.h */,
7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */,
7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */,
);
name = Internal;
sourceTree = "<group>";
......@@ -363,6 +386,17 @@
path = TVVLCKit;
sourceTree = "<group>";
};
7D34F5571C909E13008A39F0 /* Dialogs */ = {
isa = PBXGroup;
children = (
7D803EB51C8F21D200864A9C /* VLCDialogProvider.m */,
7D34F5501C909DDF008A39F0 /* VLCCustomDialogProvider.m */,
7D803EC51C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m */,
7D803EBE1C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m */,
);
name = Dialogs;
sourceTree = "<group>";
};
7D8938B91B5008E9008F2B14 /* MobileVLCKit-dynamic */ = {
isa = PBXGroup;
children = (
......@@ -551,15 +585,18 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7D803EC21C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */,
0E159EC41BC6B2890015BA7C /* VLCAudio.m in Sources */,
7D1329621BA3056800BE647E /* VLCEventManager.m in Sources */,
7D1329631BA3056800BE647E /* VLCLibrary.m in Sources */,
7D803EB61C8F21D200864A9C /* VLCDialogProvider.m in Sources */,
7D1329641BA3056800BE647E /* VLCMedia.m in Sources */,
7D1329651BA3056800BE647E /* VLCMediaList.m in Sources */,
7D1329661BA3056800BE647E /* VLCMediaPlayer.m in Sources */,
7D1329671BA3056800BE647E /* VLCMediaListPlayer.m in Sources */,
7D1329681BA3056800BE647E /* VLCMediaThumbnailer.m in Sources */,
7D1329691BA3056800BE647E /* VLCMediaDiscoverer.m in Sources */,
7D34F5541C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */,
7D13296A1BA3056800BE647E /* VLCTime.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -568,8 +605,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7D803EC11C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */,
7D6C89211C0CA90000321894 /* VLCAudio.m in Sources */,
7D8939401B500D50008F2B14 /* VLCEventManager.m in Sources */,
7D803EC71C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */,
7D8939411B500D50008F2B14 /* VLCLibrary.m in Sources */,
7D8939421B500D50008F2B14 /* VLCMedia.m in Sources */,
7D8939431B500D50008F2B14 /* VLCMediaList.m in Sources */,
......@@ -577,6 +616,7 @@
7D8939451B500D51008F2B14 /* VLCMediaListPlayer.m in Sources */,
7D8939461B500D51008F2B14 /* VLCMediaThumbnailer.m in Sources */,
7D8939471B500D51008F2B14 /* VLCMediaDiscoverer.m in Sources */,
7D34F5531C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */,
7D8939481B500D51008F2B14 /* VLCTime.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -593,14 +633,18 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7D803EC01C8F2AB400864A9C /* VLCEmbeddedDialogProvider.m in Sources */,
7A5ECACB11DE8F7300F66AF3 /* VLCEventManager.m in Sources */,
7D5F800A185B72EB00C2CD75 /* VLCMediaListPlayer.m in Sources */,
7D803EC61C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */,
7A5ECACC11DE8F7300F66AF3 /* VLCLibrary.m in Sources */,
7A5ECACD11DE8F7300F66AF3 /* VLCMedia.m in Sources */,
7D803EC91C8F2B0900864A9C /* VLCDialogProvider.m in Sources */,
7A5ECACE11DE8F7300F66AF3 /* VLCMediaList.m in Sources */,
7A5ECACF11DE8F7300F66AF3 /* VLCMediaPlayer.m in Sources */,
7A5ECAD011DE8F7300F66AF3 /* VLCTime.m in Sources */,
6360B0E211E7F0C000EAD790 /* VLCMediaDiscoverer.m in Sources */,
7D34F5521C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */,
4B49C5FC1BC3D7870052D40C /* VLCAudio.m in Sources */,
636E975811EBC67A002FE8A9 /* VLCMediaThumbnailer.m in Sources */,
);
......
......@@ -13,3 +13,12 @@
#else
#define VKLog(format, ...)
#endif
NSString *toNSStr(const char *str) {
return str != NULL ? [NSString stringWithUTF8String:str] : @"";
}
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[UIDevice currentDevice] systemVersion].floatValue >= [v floatValue])
#define SYSTEM_RUNS_IOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
......@@ -40,6 +40,9 @@ New APIs:
- VLCAudio
- setMuted:
- VLCDialogProvider
- new class to handle user interaction with VLC events
Deprecated APIs:
- VLCMediaPlayer
- titles, chaptersForTitleIndex:, countOfTitles, framesPerSecond
......
/*****************************************************************************
* VLCCustomDialogProvider.m: an implementation of the libvlc dialog API
* Included to allow custom UIs with full flexibility
*****************************************************************************
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan org>
* Pierre d'Herbemont <pdherbemont # videolan org>
*
* 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.
*****************************************************************************/
#import "VLCCustomDialogProvider.h"
#import "VLCLibrary.h"
@interface VLCCustomDialogProvider ()
{
VLCLibrary *_libraryInstance;
}
- (void)displayError:(NSArray * _Nonnull)dialogData;
- (void)displayLoginDialog:(NSArray * _Nonnull)dialogData;
- (void)displayQuestion:(NSArray * _Nonnull)dialogData;
- (void)displayProgressDialog:(NSArray * _Nonnull)dialogData;
- (void)updateDisplayedProgressDialog:(NSArray * _Nonnull)dialogData;
- (void)cancelDialog:(NSValue *)dialogId;
@end
static void displayErrorCallback(const char *psz_title,
const char *psz_text,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(displayError:)
withObject:@[toNSStr(psz_title),
toNSStr(psz_text)]
waitUntilDone:NO];
}
}
static void displayLoginCallback(libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
const char *psz_default_username,
bool b_ask_store,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(displayLoginDialog:)
withObject:@[[NSValue valueWithPointer:p_id],
toNSStr(psz_title),
toNSStr(psz_text),
toNSStr(psz_default_username),
@(b_ask_store)]
waitUntilDone:NO];
}
}
static void displayQuestionCallback(libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
libvlc_dialog_question_type i_type,
const char *psz_cancel,
const char *psz_action1,
const char *psz_action2,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(displayQuestion:)
withObject:@[[NSValue valueWithPointer:p_id],
toNSStr(psz_title),
toNSStr(psz_text),
@(i_type),
toNSStr(psz_cancel),
toNSStr(psz_action1),
toNSStr(psz_action2)]
waitUntilDone:NO];
}
}
static void displayProgressCallback(libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
bool b_indeterminate,
float f_position,
const char *psz_cancel,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(displayProgressDialog:)
withObject:@[[NSValue valueWithPointer:p_id],
toNSStr(psz_title),
toNSStr(psz_text),
@(b_indeterminate),
@(f_position),
toNSStr(psz_cancel)]
waitUntilDone:NO];
}
}
static void cancelCallback(libvlc_dialog_id *p_id,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(displayProgressDialog:)
withObject:[NSValue valueWithPointer:p_id]
waitUntilDone:NO];
}
}
static void updateProgressCallback(libvlc_dialog_id *p_id,
float f_value,
const char *psz_text,
void *p_data)
{
@autoreleasepool {
VLCCustomDialogProvider *dialogProvider = (__bridge VLCCustomDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(updateDisplayedProgressDialog:)
withObject:@[[NSValue valueWithPointer:p_id],
@(f_value),
toNSStr(psz_text)]
waitUntilDone:NO];
}
}
@implementation VLCCustomDialogProvider
- (void)dealloc
{
libvlc_dialog_set_callbacks(_libraryInstance.instance,
NULL,
NULL);
}
- (instancetype)initWithLibrary:(VLCLibrary *)library
{
self = [super init];
if (self != nil) {
if (library == nil) {
library = [VLCLibrary sharedLibrary];
}
_libraryInstance = library;
/* callback setup */
const libvlc_dialog_cbs cbs = {
displayErrorCallback,
displayLoginCallback,
displayQuestionCallback,
displayProgressCallback,
cancelCallback,
updateProgressCallback
};
libvlc_dialog_set_callbacks(_libraryInstance.instance,
&cbs,
(__bridge void *)self);
}
return self;
}
- (void)displayError:(NSArray * _Nonnull)dialogData
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(showErrorWithTitle:message:)]) {
[self.customRenderer showErrorWithTitle:dialogData[0] message:dialogData[1]];
}
}
- (void)displayLoginDialog:(NSArray * _Nonnull)dialogData
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(showLoginWithTitle:message:defaultUsername:askingForStorage:withReference:)]) {
[self.customRenderer showLoginWithTitle:dialogData[1]
message:dialogData[2]
defaultUsername:[dialogData[3] isEqualToString:@""] ? NULL : dialogData[3]
askingForStorage:[dialogData[4] boolValue]
withReference:dialogData[0]];
}
}
- (void)postUsername:(NSString *)username andPassword:(NSString *)password forDialogReference:(NSValue *)dialogReference store:(BOOL)store
{
libvlc_dialog_post_login([dialogReference pointerValue],
username != nil ? [username UTF8String] : NULL,
password != nil ? [password UTF8String] : NULL,
store);
}
- (void)displayQuestion:(NSArray * _Nonnull)dialogData
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(showQuestionWithTitle:message:type:cancelString:action1String:action2String:withReference:)]) {
[self.customRenderer showQuestionWithTitle:dialogData[1]
message:dialogData[2]
type:[dialogData[3] unsignedIntegerValue]
cancelString:[dialogData[4] isEqualToString:@""] ? NULL : dialogData[4]
action1String:[dialogData[5] isEqualToString:@""] ? NULL : dialogData[5]
action2String:[dialogData[6] isEqualToString:@""] ? NULL : dialogData[6]
withReference:dialogData[0]];
}
}
- (void)postAction:(int)buttonNumber forDialogReference:(NSValue *)dialogReference
{
libvlc_dialog_post_action([dialogReference pointerValue],
buttonNumber);
}
- (void)displayProgressDialog:(NSArray * _Nonnull)dialogData
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(showProgressWithTitle:message:isIndeterminate:position:cancelString:withReference:)]) {
[self.customRenderer showProgressWithTitle:dialogData[1]
message:dialogData[2]
isIndeterminate:dialogData[3]
position:[dialogData[4] floatValue]
cancelString:[dialogData[5] isEqualToString:@""] ? NULL : dialogData[5]
withReference:dialogData[0]];
}
}
- (void)updateDisplayedProgressDialog:(NSArray * _Nonnull)dialogData
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(updateProgressWithReference:message:postion:)]) {
[self.customRenderer updateProgressWithReference:dialogData[0]
message:dialogData[1]
postion:[dialogData[2] floatValue]];
}
}
- (void)cancelDialog:(NSValue *)dialogId
{
if (!self.customRenderer) {
return;
}
if ([self.customRenderer respondsToSelector:@selector(cancelDialogWithReference:)]) {
[self.customRenderer cancelDialogWithReference:dialogId];
}
}
- (void)dismissDialogWithReference:(NSValue *)dialogReference
{
libvlc_dialog_dismiss([dialogReference pointerValue]);
}
@end
/*****************************************************************************
* VLCDialogProvider.m: an implementation of the libvlc dialog API
*****************************************************************************
* Copyright (C) 2016 VideoLabs SAS
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* 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.
*****************************************************************************/
#import "VLCDialogProvider.h"
#import "VLCiOSLegacyDialogProvider.h"
#import "VLCEmbeddedDialogProvider.h"
#import "VLCCustomDialogProvider.h"
/* We are the root of a class cluster, not much to see */
@implementation VLCDialogProvider
- (instancetype)initWithLibrary:(VLCLibrary *)library customUI:(BOOL)customUI
{
#if TARGET_OS_IPHONE
#if( __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0)
if (customUI)
return [[VLCCustomDialogProvider alloc] initWithLibrary:library];
return [[VLCiOSLegacyDialogProvider alloc] initWithLibrary:library];