// // MasterViewController.m // LinphoneTester // // Created by guillaume on 28/05/2014. // // #import "MasterViewController.h" #import "LogsViewController.h" #import "DetailViewController.h" #include "linphone/liblinphone_tester.h" #include "mediastreamer2/msutils.h" @interface MasterViewController () { NSMutableArray *_objects; NSString* bundlePath; NSString* documentPath; } @end @implementation MasterViewController - (void)awakeFromNib { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { self.clearsSelectionOnViewWillAppear = NO; self.preferredContentSize = CGSizeMake(320.0, 600.0); } [super awakeFromNib]; } NSMutableArray* lastLogs = nil; NSMutableArray* logsBuffer = nil; static int const kLastLogsCapacity = 5000; static int const kLogsBufferCapacity = 10; NSString* const kLogsUpdateNotification = @"kLogsUpdateNotification"; void LSLog(NSString* fmt, ...){ va_list args; va_start(args, fmt); linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args); va_end(args); } static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) { NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args]; NSLog(@"%@",log); } - (void)setupLogging { lastLogs = [[NSMutableArray alloc] initWithCapacity:kLastLogsCapacity]; logsBuffer = [NSMutableArray arrayWithCapacity:kLogsBufferCapacity]; linphone_core_set_log_handler(linphone_log_function); linphone_core_set_log_level(ORTP_DEBUG|ORTP_ERROR|ORTP_FATAL|ORTP_WARNING|ORTP_MESSAGE|ORTP_TRACE); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; [self setupLogging]; bundlePath = [[NSBundle mainBundle] bundlePath]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); documentPath = [paths objectAtIndex:0]; bc_tester_init((void (*)(int, const char *fm, va_list))linphone_log_function, ORTP_MESSAGE, ORTP_ERROR); liblinphone_tester_add_suites(); bc_tester_read_dir_prefix = ms_strdup([bundlePath UTF8String]); bc_tester_writable_dir_prefix = ms_strdup([documentPath UTF8String]); LSLog(@"Bundle path: %@", bundlePath); LSLog(@"Document path: %@", documentPath); int count = bc_tester_nb_suites(); _objects = [[NSMutableArray alloc] initWithCapacity:count]; for (int i=0; i