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

Library: implement logging including support for different levels

parent 624139ce
......@@ -54,26 +54,41 @@
*/
- (instancetype)initWithOptions:(NSArray*)options;
/**
* enables/disables debug logging
* \param BOOL value to enable/disable
* \note we will always log using NSLog
* \return debug logging state
*/
@property (readwrite, nonatomic) BOOL debugLogging;
/**
* gets/sets the debug logging level
* \param int set level from 0 (all) to 4 (just error messages)
* \return int debug level
*/
@property (readwrite, nonatomic) int debugLoggingLevel;
/**
* Returns the library's version
* \return The library version example "0.9.0-git Grishenko".
*/
@property (readonly, copy) NSString * version;
@property (readonly, copy) NSString *version;
/**
* Returns the compiler used to build the libvlc binary
* \return The compiler version string.
*/
@property (readonly, copy) NSString * compiler;
@property (readonly, copy) NSString *compiler;
/**
* Returns the library's changeset
* \return The library version example "adfee99".
*/
@property (readonly, copy) NSString * changeset;
@property (readonly, copy) NSString *changeset;
/**
* sets the application name and HTTP User Agend
......
Version 3.0.0:
--------------
New APIs:
- VLCLibrary
- added properties: debugLogging, debugLoggingLevel
- VLCMediaPlayer
- added properties: titleDescriptions, indexOfLongestTitle
- added selector: chaptersForTitleIndex:
......
......@@ -36,6 +36,12 @@
#include <vlc/vlc.h>
#include <vlc/libvlc_structures.h>
static void HandleMessage(void *,
int,
const libvlc_log_t *,
const char *,
va_list);
static VLCLibrary * sharedLibrary = nil;
@interface VLCLibrary()
......@@ -50,7 +56,7 @@ static VLCLibrary * sharedLibrary = nil;
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedLibrary = [[self alloc] init];
sharedLibrary = [[VLCLibrary alloc] init];
});
return sharedLibrary;
}
......@@ -107,7 +113,6 @@ static VLCLibrary * sharedLibrary = nil;
#ifndef NOSCARYCODECS
@"--avcodec-fast",
#endif
@"--verbose=0",
@"--text-renderer=quartztext",
@"--avi-index=3",
@"--extraintf=ios_dialog_provider"];
......@@ -134,6 +139,18 @@ static VLCLibrary * sharedLibrary = nil;
return vlcParams;
}
- (void)setDebugLogging:(BOOL)debugLogging
{
if (!_instance)
return;
if (debugLogging) {
libvlc_log_set(_instance, HandleMessage, (__bridge void *)(self));
} else {
libvlc_log_unset(_instance);
}
}
- (NSString *)version
{
return @(libvlc_get_version());
......@@ -168,3 +185,25 @@ static VLCLibrary * sharedLibrary = nil;
}
@end
static void HandleMessage(void *data,
int level,
const libvlc_log_t *ctx,
const char *fmt,
va_list args)
{
VLCLibrary *libraryInstance = (__bridge VLCLibrary *)data;
if (level < libraryInstance.debugLoggingLevel)
return;
char *str;
if (vasprintf(&str, fmt, args) == -1) {
return;
}
if (!str)
return;
VKLog(@"%@", [NSString stringWithUTF8String:str]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment