mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-15 21:21:45 +00:00
Created logger with log levels
This commit is contained in:
@@ -65,6 +65,7 @@
|
|||||||
FB9AFD3D1A7E111600872C98 /* AppAssetResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3C1A7E111600872C98 /* AppAssetResponse.m */; };
|
FB9AFD3D1A7E111600872C98 /* AppAssetResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3C1A7E111600872C98 /* AppAssetResponse.m */; };
|
||||||
FB9AFD401A7E127D00872C98 /* AppListResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */; };
|
FB9AFD401A7E127D00872C98 /* AppListResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */; };
|
||||||
FB9AFD431A7F0C6900872C98 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD421A7F0C6900872C98 /* Controller.m */; };
|
FB9AFD431A7F0C6900872C98 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD421A7F0C6900872C98 /* Controller.m */; };
|
||||||
|
FBD1C8E21A8AD71400C6703C /* Logger.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD1C8E11A8AD71400C6703C /* Logger.m */; };
|
||||||
FBD3494319FC9C04002D2A60 /* AppAssetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494219FC9C04002D2A60 /* AppAssetManager.m */; };
|
FBD3494319FC9C04002D2A60 /* AppAssetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494219FC9C04002D2A60 /* AppAssetManager.m */; };
|
||||||
FBD3495019FF2174002D2A60 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494F19FF2174002D2A60 /* SettingsViewController.m */; };
|
FBD3495019FF2174002D2A60 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494F19FF2174002D2A60 /* SettingsViewController.m */; };
|
||||||
FBD3495319FF36FB002D2A60 /* SWRevealViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3495219FF36FB002D2A60 /* SWRevealViewController.m */; };
|
FBD3495319FF36FB002D2A60 /* SWRevealViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3495219FF36FB002D2A60 /* SWRevealViewController.m */; };
|
||||||
@@ -268,6 +269,8 @@
|
|||||||
FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppListResponse.m; sourceTree = "<group>"; };
|
FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppListResponse.m; sourceTree = "<group>"; };
|
||||||
FB9AFD411A7F0C6900872C98 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = "<group>"; };
|
FB9AFD411A7F0C6900872C98 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = "<group>"; };
|
||||||
FB9AFD421A7F0C6900872C98 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = "<group>"; };
|
FB9AFD421A7F0C6900872C98 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = "<group>"; };
|
||||||
|
FBD1C8E01A8AD69E00C6703C /* Logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logger.h; sourceTree = "<group>"; };
|
||||||
|
FBD1C8E11A8AD71400C6703C /* Logger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Logger.m; sourceTree = "<group>"; };
|
||||||
FBD3494119FC9C04002D2A60 /* AppAssetManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppAssetManager.h; sourceTree = "<group>"; };
|
FBD3494119FC9C04002D2A60 /* AppAssetManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppAssetManager.h; sourceTree = "<group>"; };
|
||||||
FBD3494219FC9C04002D2A60 /* AppAssetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppAssetManager.m; sourceTree = "<group>"; };
|
FBD3494219FC9C04002D2A60 /* AppAssetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppAssetManager.m; sourceTree = "<group>"; };
|
||||||
FBD3494E19FF2174002D2A60 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
|
FBD3494E19FF2174002D2A60 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
|
||||||
@@ -509,6 +512,8 @@
|
|||||||
FBDE86E819F82315001C18A8 /* App.m */,
|
FBDE86E819F82315001C18A8 /* App.m */,
|
||||||
FB89462119F646E200339C8A /* Utils.h */,
|
FB89462119F646E200339C8A /* Utils.h */,
|
||||||
FB89462219F646E200339C8A /* Utils.m */,
|
FB89462219F646E200339C8A /* Utils.m */,
|
||||||
|
FBD1C8E01A8AD69E00C6703C /* Logger.h */,
|
||||||
|
FBD1C8E11A8AD71400C6703C /* Logger.m */,
|
||||||
);
|
);
|
||||||
path = Utility;
|
path = Utility;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -893,6 +898,7 @@
|
|||||||
FB4678FA1A55FFAD00377732 /* DiscoveryManager.m in Sources */,
|
FB4678FA1A55FFAD00377732 /* DiscoveryManager.m in Sources */,
|
||||||
FBD3495B1A004411002D2A60 /* Host.m in Sources */,
|
FBD3495B1A004411002D2A60 /* Host.m in Sources */,
|
||||||
FB89463519F646E200339C8A /* MainFrameViewController.m in Sources */,
|
FB89463519F646E200339C8A /* MainFrameViewController.m in Sources */,
|
||||||
|
FBD1C8E21A8AD71400C6703C /* Logger.m in Sources */,
|
||||||
FB89463619F646E200339C8A /* StreamFrameViewController.m in Sources */,
|
FB89463619F646E200339C8A /* StreamFrameViewController.m in Sources */,
|
||||||
FB89462819F646E200339C8A /* CryptoManager.m in Sources */,
|
FB89462819F646E200339C8A /* CryptoManager.m in Sources */,
|
||||||
FB89462E19F646E200339C8A /* PairManager.m in Sources */,
|
FB89462E19F646E200339C8A /* PairManager.m in Sources */,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static NSOperationQueue* mainQueue;
|
|||||||
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
|
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
|
||||||
// Replace this implementation with code to handle the error appropriately.
|
// Replace this implementation with code to handle the error appropriately.
|
||||||
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
Log(LOG_E, @"Unresolved error %@, %@", error, [error userInfo]);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ static NSOperationQueue* mainQueue;
|
|||||||
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
|
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
Log(LOG_E, @"Unresolved error %@, %@", error, [error userInfo]);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static NSData* p12 = nil;
|
|||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
|
||||||
if (!x509) {
|
if (!x509) {
|
||||||
NSLog(@"ERROR: unable to parse certificate in memory");
|
Log(LOG_E, @"Unable to parse certificate in memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ static NSData* p12 = nil;
|
|||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
|
||||||
if (!pkey) {
|
if (!pkey) {
|
||||||
NSLog(@"ERROR: unable to parse private key in memory!");
|
Log(LOG_E, @"Unable to parse private key in memory!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ static NSData* p12 = nil;
|
|||||||
x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
|
x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (!x509) {
|
if (!x509) {
|
||||||
NSLog(@"ERROR: unable to parse certificate in memory!");
|
Log(LOG_E, @"Unable to parse certificate in memory!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return [NSData dataWithBytes:x509->signature->data length:x509->signature->length];
|
return [NSData dataWithBytes:x509->signature->data length:x509->signature->length];
|
||||||
@@ -206,7 +206,7 @@ static NSData* p12 = nil;
|
|||||||
dispatch_once(&pred, ^{
|
dispatch_once(&pred, ^{
|
||||||
if (![CryptoManager keyPairExists]) {
|
if (![CryptoManager keyPairExists]) {
|
||||||
|
|
||||||
NSLog(@"Generating Certificate... ");
|
Log(LOG_I, @"Generating Certificate... ");
|
||||||
CertKeyPair certKeyPair = generateCertKeyPair();
|
CertKeyPair certKeyPair = generateCertKeyPair();
|
||||||
|
|
||||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||||
@@ -215,10 +215,10 @@ static NSData* p12 = nil;
|
|||||||
NSString* keyPairFile = [documentsDirectory stringByAppendingPathComponent:@"client.key"];
|
NSString* keyPairFile = [documentsDirectory stringByAppendingPathComponent:@"client.key"];
|
||||||
NSString* p12File = [documentsDirectory stringByAppendingPathComponent:@"client.p12"];
|
NSString* p12File = [documentsDirectory stringByAppendingPathComponent:@"client.p12"];
|
||||||
|
|
||||||
//NSLog(@"Writing cert and key to: \n%@\n%@", certFile, keyPairFile);
|
//Log(LOG_D, @"Writing cert and key to: \n%@\n%@", certFile, keyPairFile);
|
||||||
saveCertKeyPair([certFile UTF8String], [p12File UTF8String], [keyPairFile UTF8String], certKeyPair);
|
saveCertKeyPair([certFile UTF8String], [p12File UTF8String], [keyPairFile UTF8String], certKeyPair);
|
||||||
freeCertKeyPair(certKeyPair);
|
freeCertKeyPair(certKeyPair);
|
||||||
NSLog(@"Certificate created");
|
Log(LOG_I, @"Certificate created");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ static NSData* p12 = nil;
|
|||||||
NSMutableString* uniqueId = [NSMutableString stringWithString:[idString substringFromIndex:19]];
|
NSMutableString* uniqueId = [NSMutableString stringWithString:[idString substringFromIndex:19]];
|
||||||
[uniqueId deleteCharactersInRange:NSMakeRange(4, 1)];
|
[uniqueId deleteCharactersInRange:NSMakeRange(4, 1)];
|
||||||
|
|
||||||
//NSLog(@"Unique ID: %@", uniqueId);
|
//Log(LOG_D, @"Unique ID: %@", uniqueId);
|
||||||
return [NSString stringWithString:uniqueId];
|
return [NSString stringWithString:uniqueId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
NSError* error;
|
NSError* error;
|
||||||
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
||||||
NSLog(@"ERROR: Unable to save settings to database");
|
Log(LOG_E, @"Unable to save settings to database: %@", error);
|
||||||
}
|
}
|
||||||
[self.appDelegate saveContext];
|
[self.appDelegate saveContext];
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
- (void) saveHosts {
|
- (void) saveHosts {
|
||||||
NSError* error;
|
NSError* error;
|
||||||
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
||||||
NSLog(@"ERROR: Unable to save hosts to database");
|
Log(LOG_E, @"Unable to save hosts to database: %@", error);
|
||||||
}
|
}
|
||||||
[self.appDelegate saveContext];
|
[self.appDelegate saveContext];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"ERROR: Tried to register controller callbacks on NULL controller");
|
Log(LOG_W, @"Tried to register controller callbacks on NULL controller");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@
|
|||||||
limeController.playerIndex = i;
|
limeController.playerIndex = i;
|
||||||
[_controllers setObject:limeController forKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
[_controllers setObject:limeController forKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||||
|
|
||||||
NSLog(@"Assigning controller index: %d", i);
|
Log(LOG_I, @"Assigning controller index: %d", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@
|
|||||||
_controllers = [[NSMutableDictionary alloc] init];
|
_controllers = [[NSMutableDictionary alloc] init];
|
||||||
_controllerNumbers = 0;
|
_controllerNumbers = 0;
|
||||||
|
|
||||||
NSLog(@"Number of controllers connected: %ld", (long)[[GCController controllers] count]);
|
Log(LOG_I, @"Number of controllers connected: %ld", (long)[[GCController controllers] count]);
|
||||||
for (GCController* controller in [GCController controllers]) {
|
for (GCController* controller in [GCController controllers]) {
|
||||||
[self assignController:controller];
|
[self assignController:controller];
|
||||||
[self registerControllerCallbacks:controller];
|
[self registerControllerCallbacks:controller];
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||||
NSLog(@"Controller connected!");
|
Log(LOG_I, @"Controller connected!");
|
||||||
|
|
||||||
GCController* controller = note.object;
|
GCController* controller = note.object;
|
||||||
[self assignController:controller];
|
[self assignController:controller];
|
||||||
@@ -311,13 +311,13 @@
|
|||||||
[self updateAutoOnScreenControlMode];
|
[self updateAutoOnScreenControlMode];
|
||||||
}];
|
}];
|
||||||
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||||
NSLog(@"Controller disconnected!");
|
Log(LOG_I, @"Controller disconnected!");
|
||||||
|
|
||||||
GCController* controller = note.object;
|
GCController* controller = note.object;
|
||||||
[self unregisterControllerCallbacks:controller];
|
[self unregisterControllerCallbacks:controller];
|
||||||
[_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
[_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||||
_controllerNumbers &= ~(1 << controller.playerIndex);
|
_controllerNumbers &= ~(1 << controller.playerIndex);
|
||||||
NSLog(@"Unassigning controller index: %ld", (long)controller.playerIndex);
|
Log(LOG_I, @"Unassigning controller index: %ld", (long)controller.playerIndex);
|
||||||
|
|
||||||
// Re-evaluate the on-screen control mode
|
// Re-evaluate the on-screen control mode
|
||||||
[self updateAutoOnScreenControlMode];
|
[self updateAutoOnScreenControlMode];
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ static float L3_Y;
|
|||||||
[self hideL3R3]; // Full controls don't need these they have the sticks
|
[self hideL3R3]; // Full controls don't need these they have the sticks
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NSLog(@"Unknown on-screen controls level: %d", (int)_level);
|
Log(LOG_W, @"Unknown on-screen controls level: %d", (int)_level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@
|
|||||||
[controllerSupport initAutoOnScreenControlMode:onScreenControls];
|
[controllerSupport initAutoOnScreenControlMode:onScreenControls];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSLog(@"Setting manual on-screen controls level: %d", (int)level);
|
Log(LOG_I, @"Setting manual on-screen controls level: %d", (int)level);
|
||||||
[onScreenControls setLevel:level];
|
[onScreenControls setLevel:level];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
NSLog(@"Touch down");
|
Log(LOG_D, @"Touch down");
|
||||||
if (![onScreenControls handleTouchDownEvent:touches]) {
|
if (![onScreenControls handleTouchDownEvent:touches]) {
|
||||||
UITouch *touch = [[event allTouches] anyObject];
|
UITouch *touch = [[event allTouches] anyObject];
|
||||||
touchLocation = [touch locationInView:self];
|
touchLocation = [touch locationInView:self];
|
||||||
@@ -88,11 +88,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
NSLog(@"Touch up");
|
Log(LOG_D, @"Touch up");
|
||||||
if (![onScreenControls handleTouchUpEvent:touches]) {
|
if (![onScreenControls handleTouchUpEvent:touches]) {
|
||||||
if (!touchMoved) {
|
if (!touchMoved) {
|
||||||
if ([[event allTouches] count] == 2) {
|
if ([[event allTouches] count] == 2) {
|
||||||
NSLog(@"Sending right mouse button press");
|
Log(LOG_D, @"Sending right mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Sending left mouse button press");
|
Log(LOG_D, @"Sending left mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <CoreData/CoreData.h>
|
#import <CoreData/CoreData.h>
|
||||||
|
#import "Logger.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
Host* oldHost = _host;
|
Host* oldHost = _host;
|
||||||
_host = host;
|
_host = host;
|
||||||
BOOL useCache = [oldHost.uuid isEqualToString:_host.uuid];
|
BOOL useCache = [oldHost.uuid isEqualToString:_host.uuid];
|
||||||
NSLog(@"Using cached app images: %d", useCache);
|
Log(LOG_I, @"Using cached app images: %d", useCache);
|
||||||
if (!useCache) {
|
if (!useCache) {
|
||||||
[_imageCache removeAllObjects];
|
[_imageCache removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
|
|||||||
- (void) parseData {
|
- (void) parseData {
|
||||||
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
||||||
if (docPtr == NULL) {
|
if (docPtr == NULL) {
|
||||||
NSLog(@"ERROR: An error occured trying to parse xml.");
|
Log(LOG_W, @"An error occured trying to parse xml.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
NSLog(@"ERROR: No root XML element.");
|
Log(LOG_W, @"No root XML element.");
|
||||||
xmlFreeDoc(docPtr);
|
xmlFreeDoc(docPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
|
|||||||
node = node->children;
|
node = node->children;
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
//NSLog(@"node: %s", node->name);
|
//Log(LOG_D, @"node: %s", node->name);
|
||||||
if (!xmlStrcmp(node->name, (xmlChar*)TAG_APP)) {
|
if (!xmlStrcmp(node->name, (xmlChar*)TAG_APP)) {
|
||||||
xmlNodePtr appInfoNode = node->xmlChildrenNode;
|
xmlNodePtr appInfoNode = node->xmlChildrenNode;
|
||||||
NSString* appName;
|
NSString* appName;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) startDiscovery {
|
- (void) startDiscovery {
|
||||||
NSLog(@"Starting discovery");
|
Log(LOG_I, @"Starting discovery");
|
||||||
shouldDiscover = YES;
|
shouldDiscover = YES;
|
||||||
[_mdnsMan searchForHosts];
|
[_mdnsMan searchForHosts];
|
||||||
for (Host* host in _hostQueue) {
|
for (Host* host in _hostQueue) {
|
||||||
@@ -72,19 +72,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopDiscovery {
|
- (void) stopDiscovery {
|
||||||
NSLog(@"Stopping discovery");
|
Log(LOG_I, @"Stopping discovery");
|
||||||
shouldDiscover = NO;
|
shouldDiscover = NO;
|
||||||
[_mdnsMan stopSearching];
|
[_mdnsMan stopSearching];
|
||||||
[_opQueue cancelAllOperations];
|
[_opQueue cancelAllOperations];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopDiscoveryBlocking {
|
- (void) stopDiscoveryBlocking {
|
||||||
NSLog(@"Stopping discovery and waiting for workers to stop");
|
Log(LOG_I, @"Stopping discovery and waiting for workers to stop");
|
||||||
shouldDiscover = NO;
|
shouldDiscover = NO;
|
||||||
[_mdnsMan stopSearching];
|
[_mdnsMan stopSearching];
|
||||||
[_opQueue cancelAllOperations];
|
[_opQueue cancelAllOperations];
|
||||||
[_opQueue waitUntilAllOperationsAreFinished];
|
[_opQueue waitUntilAllOperationsAreFinished];
|
||||||
NSLog(@"All discovery workers stopped");
|
Log(LOG_I, @"All discovery workers stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) addHostToDiscovery:(Host *)host {
|
- (BOOL) addHostToDiscovery:(Host *)host {
|
||||||
@@ -113,15 +113,15 @@
|
|||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
// Discover the hosts before adding to eliminate duplicates
|
// Discover the hosts before adding to eliminate duplicates
|
||||||
for (Host* host in hosts) {
|
for (Host* host in hosts) {
|
||||||
NSLog(@"Found host through MDNS: %@:", host.name);
|
Log(LOG_I, @"Found host through MDNS: %@:", host.name);
|
||||||
// Since this is on a background thread, we do not need to use the opQueue
|
// Since this is on a background thread, we do not need to use the opQueue
|
||||||
DiscoveryWorker* worker = (DiscoveryWorker*)[self createWorkerForHost:host];
|
DiscoveryWorker* worker = (DiscoveryWorker*)[self createWorkerForHost:host];
|
||||||
[worker discoverHost];
|
[worker discoverHost];
|
||||||
if ([self addHostToDiscovery:host]) {
|
if ([self addHostToDiscovery:host]) {
|
||||||
NSLog(@"Adding host to discovery: %@", host.name);
|
Log(LOG_I, @"Adding host to discovery: %@", host.name);
|
||||||
[_callback updateAllHosts:_hostQueue];
|
[_callback updateAllHosts:_hostQueue];
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Not adding host to discovery: %@", host.name);
|
Log(LOG_I, @"Not adding host to discovery: %@", host.name);
|
||||||
[dataMan removeHost:host];
|
[dataMan removeHost:host];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
|||||||
}
|
}
|
||||||
_host.online = receivedResponse;
|
_host.online = receivedResponse;
|
||||||
if (receivedResponse) {
|
if (receivedResponse) {
|
||||||
NSLog(@"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
|||||||
[response populateHost:_host];
|
[response populateHost:_host];
|
||||||
return YES;
|
return YES;
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Received response from incorrect host: %@ expected: %@", [response getStringTag:TAG_UNIQUE_ID], _host.uuid);
|
Log(LOG_I, @"Received response from incorrect host: %@ expected: %@", [response getStringTag:TAG_UNIQUE_ID], _host.uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static const NSString* PORT = @"47984";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) executeRequestSynchronously:(HttpRequest*)request {
|
- (void) executeRequestSynchronously:(HttpRequest*)request {
|
||||||
NSLog(@"Making Request: %@", request);
|
Log(LOG_D, @"Making Request: %@", request);
|
||||||
[_respData setLength:0];
|
[_respData setLength:0];
|
||||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||||
[NSURLConnection connectionWithRequest:request.request delegate:self];
|
[NSURLConnection connectionWithRequest:request.request delegate:self];
|
||||||
@@ -154,11 +154,11 @@ static const NSString* PORT = @"47984";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
||||||
NSLog(@"Received response: %@", response);
|
Log(LOG_D, @"Received response: %@", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
|
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
|
||||||
NSLog(@"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
Log(LOG_D, @"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
||||||
[_respData appendData:data];
|
[_respData appendData:data];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,11 +202,11 @@ static const NSString* PORT = @"47984";
|
|||||||
OSStatus securityError = SecPKCS12Import(p12Data, options, &items);
|
OSStatus securityError = SecPKCS12Import(p12Data, options, &items);
|
||||||
|
|
||||||
if (securityError == errSecSuccess) {
|
if (securityError == errSecSuccess) {
|
||||||
//NSLog(@"Success opening p12 certificate. Items: %ld", CFArrayGetCount(items));
|
//Log(LOG_D, @"Success opening p12 certificate. Items: %ld", CFArrayGetCount(items));
|
||||||
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
|
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
|
||||||
identityApp = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
|
identityApp = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Error opening Certificate.");
|
Log(LOG_E, @"Error opening Certificate.");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(options);
|
CFRelease(options);
|
||||||
@@ -216,7 +216,7 @@ static const NSString* PORT = @"47984";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
||||||
NSLog(@"connection error: %@", error);
|
Log(LOG_W, @"connection error: %@", error);
|
||||||
dispatch_semaphore_signal(_requestLock);
|
dispatch_semaphore_signal(_requestLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,13 @@
|
|||||||
_elements = [[NSMutableDictionary alloc] init];
|
_elements = [[NSMutableDictionary alloc] init];
|
||||||
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
||||||
if (docPtr == NULL) {
|
if (docPtr == NULL) {
|
||||||
NSLog(@"ERROR: An error occured trying to parse xml.");
|
Log(LOG_W, @"An error occured trying to parse xml.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
NSLog(@"ERROR: No root XML element.");
|
Log(LOG_W, @"No root XML element.");
|
||||||
xmlFreeDoc(docPtr);
|
xmlFreeDoc(docPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) searchForHosts {
|
- (void) searchForHosts {
|
||||||
NSLog(@"Starting mDNS discovery");
|
Log(LOG_I, @"Starting mDNS discovery");
|
||||||
scanActive = TRUE;
|
scanActive = TRUE;
|
||||||
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopSearching {
|
- (void) stopSearching {
|
||||||
NSLog(@"Stopping mDNS discovery");
|
Log(LOG_I, @"Stopping mDNS discovery");
|
||||||
scanActive = FALSE;
|
scanActive = FALSE;
|
||||||
[mDNSBrowser stop];
|
[mDNSBrowser stop];
|
||||||
}
|
}
|
||||||
@@ -60,12 +60,12 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)netServiceDidResolveAddress:(NSNetService *)service {
|
- (void)netServiceDidResolveAddress:(NSNetService *)service {
|
||||||
NSLog(@"Resolved address: %@ -> %@", service, service.hostName);
|
Log(LOG_I, @"Resolved address: %@ -> %@", service, service.hostName);
|
||||||
[self.callback updateHosts:[self getFoundHosts]];
|
[self.callback updateHosts:[self getFoundHosts]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict {
|
- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict {
|
||||||
NSLog(@"Did not resolve address for: %@\n%@", sender, [errorDict description]);
|
Log(LOG_W, @"Did not resolve address for: %@\n%@", sender, [errorDict description]);
|
||||||
|
|
||||||
// Schedule a retry in 2 seconds
|
// Schedule a retry in 2 seconds
|
||||||
[NSTimer scheduledTimerWithTimeInterval:2.0
|
[NSTimer scheduledTimerWithTimeInterval:2.0
|
||||||
@@ -76,7 +76,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
||||||
NSLog(@"Found service: %@", aNetService);
|
Log(LOG_I, @"Found service: %@", aNetService);
|
||||||
[aNetService setDelegate:self];
|
[aNetService setDelegate:self];
|
||||||
[aNetService resolveWithTimeout:5];
|
[aNetService resolveWithTimeout:5];
|
||||||
|
|
||||||
@@ -85,13 +85,12 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didRemoveService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didRemoveService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
||||||
NSLog(@"Removing service: %@", aNetService);
|
Log(LOG_I, @"Removing service: %@", aNetService);
|
||||||
[services removeObject:aNetService];
|
[services removeObject:aNetService];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict {
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict {
|
||||||
NSLog(@"Did not perform search");
|
Log(LOG_W, @"Did not perform search: \n%@", [errorDict description]);
|
||||||
NSLog(@"%@", [errorDict description]);
|
|
||||||
|
|
||||||
// Schedule a retry in 2 seconds
|
// Schedule a retry in 2 seconds
|
||||||
[NSTimer scheduledTimerWithTimeInterval:2.0
|
[NSTimer scheduledTimerWithTimeInterval:2.0
|
||||||
@@ -107,7 +106,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLog(@"Retrying mDNS search");
|
Log(LOG_I, @"Retrying mDNS search");
|
||||||
[mDNSBrowser stop];
|
[mDNSBrowser stop];
|
||||||
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
||||||
}
|
}
|
||||||
@@ -118,7 +117,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLog(@"Retrying mDNS resolution");
|
Log(LOG_I, @"Retrying mDNS resolution");
|
||||||
for (NSNetService* service in services) {
|
for (NSNetService* service in services) {
|
||||||
if (service.hostName == nil) {
|
if (service.hostName == nil) {
|
||||||
[service setDelegate:self];
|
[service setDelegate:self];
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
- (void) initiatePair {
|
- (void) initiatePair {
|
||||||
NSString* PIN = [self generatePIN];
|
NSString* PIN = [self generatePIN];
|
||||||
NSData* salt = [self saltPIN:PIN];
|
NSData* salt = [self saltPIN:PIN];
|
||||||
NSLog(@"PIN: %@, saltedPIN: %@", PIN, salt);
|
Log(LOG_I, @"PIN: %@, saltedPIN: %@", PIN, salt);
|
||||||
[_callback showPIN:PIN];
|
[_callback showPIN:PIN];
|
||||||
|
|
||||||
HttpResponse* pairResp = [[HttpResponse alloc] init];
|
HttpResponse* pairResp = [[HttpResponse alloc] init];
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
|||||||
CFSocketRef wolSocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
|
CFSocketRef wolSocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
|
||||||
if (!wolSocket) {
|
if (!wolSocket) {
|
||||||
CFRelease(dataPayload);
|
CFRelease(dataPayload);
|
||||||
NSLog(@"Failed to create WOL socket");
|
Log(LOG_E, @"Failed to create WOL socket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"WOL socket created");
|
Log(LOG_I, @"WOL socket created");
|
||||||
|
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@@ -48,7 +48,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
|||||||
// try all ports
|
// try all ports
|
||||||
for (int j = 0; j < numPorts; j++) {
|
for (int j = 0; j < numPorts; j++) {
|
||||||
addr.sin_port = htons(ports[j]);
|
addr.sin_port = htons(ports[j]);
|
||||||
NSLog(@"Sending WOL packet");
|
Log(LOG_I, @"Sending WOL packet");
|
||||||
CFSocketSendData(wolSocket, dataAddress, dataPayload, 0);
|
CFSocketSendData(wolSocket, dataAddress, dataPayload, 0);
|
||||||
}
|
}
|
||||||
CFRelease(dataAddress);
|
CFRelease(dataAddress);
|
||||||
@@ -76,7 +76,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
|||||||
|
|
||||||
+ (NSData*) macStringToBytes:(NSString*)mac {
|
+ (NSData*) macStringToBytes:(NSString*)mac {
|
||||||
NSString* macString = [mac stringByReplacingOccurrencesOfString:@":" withString:@""];
|
NSString* macString = [mac stringByReplacingOccurrencesOfString:@":" withString:@""];
|
||||||
NSLog(@"MAC: %@", macString);
|
Log(LOG_D, @"MAC: %@", macString);
|
||||||
return [Utils hexToBytes:macString];
|
return [Utils hexToBytes:macString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void ArInit(void)
|
|||||||
status = AudioComponentInstanceNew(AudioComponentFindNext(NULL, &audioDesc), &audioUnit);
|
status = AudioComponentInstanceNew(AudioComponentFindNext(NULL, &audioDesc), &audioUnit);
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to instantiate new AudioComponent: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to instantiate new AudioComponent: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioStreamBasicDescription audioFormat = {0};
|
AudioStreamBasicDescription audioFormat = {0};
|
||||||
@@ -132,7 +132,7 @@ void ArInit(void)
|
|||||||
&audioFormat,
|
&audioFormat,
|
||||||
sizeof(audioFormat));
|
sizeof(audioFormat));
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to set audio unit to input: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to set audio unit to input: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AURenderCallbackStruct callbackStruct = {0};
|
AURenderCallbackStruct callbackStruct = {0};
|
||||||
@@ -146,12 +146,12 @@ void ArInit(void)
|
|||||||
&callbackStruct,
|
&callbackStruct,
|
||||||
sizeof(callbackStruct));
|
sizeof(callbackStruct));
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to set audio unit callback: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to set audio unit callback: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = AudioUnitInitialize(audioUnit);
|
status = AudioUnitInitialize(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to initialize audioUnit: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to initialize audioUnit: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ void ArRelease(void)
|
|||||||
|
|
||||||
OSStatus status = AudioUnitUninitialize(audioUnit);
|
OSStatus status = AudioUnitUninitialize(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to uninitialize audioUnit: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to uninitialize audioUnit: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio session is now inactive
|
// Audio session is now inactive
|
||||||
@@ -186,7 +186,7 @@ void ArStart(void)
|
|||||||
{
|
{
|
||||||
OSStatus status = AudioOutputUnitStart(audioUnit);
|
OSStatus status = AudioOutputUnitStart(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to start audioUnit: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to start audioUnit: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ void ArStop(void)
|
|||||||
{
|
{
|
||||||
OSStatus status = AudioOutputUnitStop(audioUnit);
|
OSStatus status = AudioOutputUnitStop(audioUnit);
|
||||||
if (status) {
|
if (status) {
|
||||||
NSLog(@"Unable to stop audioUnit: %d", (int32_t)status);
|
Log(LOG_E, @"Unable to stop audioUnit: %d", (int32_t)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ void ArDecodeAndPlaySample(char* sampleData, int sampleLength)
|
|||||||
|
|
||||||
[audioLock lock];
|
[audioLock lock];
|
||||||
if (audioBufferQueueLength > MAX_QUEUE_ENTRIES) {
|
if (audioBufferQueueLength > MAX_QUEUE_ENTRIES) {
|
||||||
NSLog(@"Audio player too slow. Dropping all decoded samples!");
|
Log(LOG_W, @"Audio player too slow. Dropping all decoded samples!");
|
||||||
|
|
||||||
// Clear all values from the buffer queue
|
// Clear all values from the buffer queue
|
||||||
struct AUDIO_BUFFER_QUEUE_ENTRY *entry;
|
struct AUDIO_BUFFER_QUEUE_ENTRY *entry;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
y:_config.height / screenSize.height];
|
y:_config.height / screenSize.height];
|
||||||
|
|
||||||
int majorVersion = [[appversion substringToIndex:1] intValue];
|
int majorVersion = [[appversion substringToIndex:1] intValue];
|
||||||
NSLog(@"Server is generation %d", majorVersion);
|
Log(LOG_I, @"Server is generation %d", majorVersion);
|
||||||
|
|
||||||
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||||
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks serverMajorVersion:majorVersion];
|
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks serverMajorVersion:majorVersion];
|
||||||
@@ -121,11 +121,11 @@
|
|||||||
NSString *gameSession = [launchResp getStringTag:@"gamesession"];
|
NSString *gameSession = [launchResp getStringTag:@"gamesession"];
|
||||||
if (launchResp == NULL || ![launchResp isStatusOk]) {
|
if (launchResp == NULL || ![launchResp isStatusOk]) {
|
||||||
[_callbacks launchFailed:@"Failed to launch app"];
|
[_callbacks launchFailed:@"Failed to launch app"];
|
||||||
NSLog(@"Failed Launch Response: %@", launchResp.statusMessage);
|
Log(LOG_E, @"Failed Launch Response: %@", launchResp.statusMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (gameSession == NULL || [gameSession isEqualToString:@"0"]) {
|
} else if (gameSession == NULL || [gameSession isEqualToString:@"0"]) {
|
||||||
[_callbacks launchFailed:launchResp.statusMessage];
|
[_callbacks launchFailed:launchResp.statusMessage];
|
||||||
NSLog(@"Failed to parse game session. Code: %ld Response: %@", (long)launchResp.statusCode, launchResp.statusMessage);
|
Log(LOG_E, @"Failed to parse game session. Code: %ld Response: %@", (long)launchResp.statusCode, launchResp.statusMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,11 +140,11 @@
|
|||||||
NSString* resume = [resumeResp getStringTag:@"resume"];
|
NSString* resume = [resumeResp getStringTag:@"resume"];
|
||||||
if (resumeResp == NULL || ![resumeResp isStatusOk]) {
|
if (resumeResp == NULL || ![resumeResp isStatusOk]) {
|
||||||
[_callbacks launchFailed:@"Failed to resume app"];
|
[_callbacks launchFailed:@"Failed to resume app"];
|
||||||
NSLog(@"Failed Resume Response: %@", resumeResp.statusMessage);
|
Log(LOG_E, @"Failed Resume Response: %@", resumeResp.statusMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (resume == NULL || [resume isEqualToString:@"0"]) {
|
} else if (resume == NULL || [resume isEqualToString:@"0"]) {
|
||||||
[_callbacks launchFailed:resumeResp.statusMessage];
|
[_callbacks launchFailed:resumeResp.statusMessage];
|
||||||
NSLog(@"Failed to parse resume response. Code: %ld Response: %@", (long)resumeResp.statusCode, resumeResp.statusMessage);
|
Log(LOG_E, @"Failed to parse resume response. Code: %ld Response: %@", (long)resumeResp.statusCode, resumeResp.statusMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
NULL, 0, nalLength + 1, 0);
|
NULL, 0, nalLength + 1, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
kCFAllocatorDefault, NULL, 0,
|
kCFAllocatorDefault, NULL, 0,
|
||||||
NAL_LENGTH_PREFIX_SIZE, 0);
|
NAL_LENGTH_PREFIX_SIZE, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferAppendMemoryBlock failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferAppendMemoryBlock failed: %d", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
kCFAllocatorNull, // Don't deallocate data on free
|
kCFAllocatorNull, // Don't deallocate data on free
|
||||||
NULL, 0, dataLength, 0);
|
NULL, 0, dataLength, 0);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
|
|
||||||
// Check for previous decoder errors before doing anything
|
// Check for previous decoder errors before doing anything
|
||||||
if (displayLayer.status == AVQueuedSampleBufferRenderingStatusFailed) {
|
if (displayLayer.status == AVQueuedSampleBufferRenderingStatusFailed) {
|
||||||
NSLog(@"Display layer rendering failed: %@", displayLayer.error);
|
Log(LOG_E, @"Display layer rendering failed: %@", displayLayer.error);
|
||||||
|
|
||||||
// Recreate the display layer
|
// Recreate the display layer
|
||||||
[self reinitializeDisplayLayer];
|
[self reinitializeDisplayLayer];
|
||||||
@@ -152,14 +152,14 @@
|
|||||||
|
|
||||||
if (nalType == NAL_TYPE_SPS || nalType == NAL_TYPE_PPS) {
|
if (nalType == NAL_TYPE_SPS || nalType == NAL_TYPE_PPS) {
|
||||||
if (nalType == NAL_TYPE_SPS) {
|
if (nalType == NAL_TYPE_SPS) {
|
||||||
NSLog(@"Got SPS");
|
Log(LOG_I, @"Got SPS");
|
||||||
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForSps = false;
|
waitingForSps = false;
|
||||||
|
|
||||||
// We got a new SPS so wait for a new PPS to match it
|
// We got a new SPS so wait for a new PPS to match it
|
||||||
waitingForPps = true;
|
waitingForPps = true;
|
||||||
} else if (nalType == NAL_TYPE_PPS) {
|
} else if (nalType == NAL_TYPE_PPS) {
|
||||||
NSLog(@"Got PPS");
|
Log(LOG_I, @"Got PPS");
|
||||||
ppsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
ppsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForPps = false;
|
waitingForPps = false;
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsData bytes] };
|
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsData bytes] };
|
||||||
const size_t parameterSetSizes[] = { [spsData length], [ppsData length] };
|
const size_t parameterSetSizes[] = { [spsData length], [ppsData length] };
|
||||||
|
|
||||||
NSLog(@"Constructing new format description");
|
Log(LOG_I, @"Constructing new format description");
|
||||||
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
||||||
2, /* count of parameter sets */
|
2, /* count of parameter sets */
|
||||||
parameterSetPointers,
|
parameterSetPointers,
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
NAL_LENGTH_PREFIX_SIZE,
|
NAL_LENGTH_PREFIX_SIZE,
|
||||||
&formatDesc);
|
&formatDesc);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"Failed to create format description: %d", (int)status);
|
Log(LOG_E, @"Failed to create format description: %d", (int)status);
|
||||||
formatDesc = NULL;
|
formatDesc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
|
|
||||||
status = CMBlockBufferCreateEmpty(NULL, 0, 0, &blockBuffer);
|
status = CMBlockBufferCreateEmpty(NULL, 0, 0, &blockBuffer);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMBlockBufferCreateEmpty failed: %d", (int)status);
|
Log(LOG_E, @"CMBlockBufferCreateEmpty failed: %d", (int)status);
|
||||||
free(data);
|
free(data);
|
||||||
return DR_NEED_IDR;
|
return DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
NULL, 0, NULL,
|
NULL, 0, NULL,
|
||||||
&sampleBuffer);
|
&sampleBuffer);
|
||||||
if (status != noErr) {
|
if (status != noErr) {
|
||||||
NSLog(@"CMSampleBufferCreate failed: %d", (int)status);
|
Log(LOG_E, @"CMSampleBufferCreate failed: %d", (int)status);
|
||||||
CFRelease(blockBuffer);
|
CFRelease(blockBuffer);
|
||||||
return DR_NEED_IDR;
|
return DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// Logger.h
|
||||||
|
// Limelight
|
||||||
|
//
|
||||||
|
// Created by Diego Waxemberg on 2/10/15.
|
||||||
|
// Copyright (c) 2015 Limelight Stream. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef Limelight_Logger_h
|
||||||
|
#define Limelight_Logger_h
|
||||||
|
|
||||||
|
#import <stdarg.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LOG_D,
|
||||||
|
LOG_I,
|
||||||
|
LOG_W,
|
||||||
|
LOG_E
|
||||||
|
} LogLevel;
|
||||||
|
|
||||||
|
#define PRFX_DEBUG @"<DEBUG>"
|
||||||
|
#define PRFX_INFO @"<INFO>"
|
||||||
|
#define PRFX_WARN @"<WARN>"
|
||||||
|
#define PRFX_ERROR @"<ERROR>"
|
||||||
|
|
||||||
|
void Log(LogLevel level, NSString* fmt, ...);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// Logger.m
|
||||||
|
// Limelight
|
||||||
|
//
|
||||||
|
// Created by Diego Waxemberg on 2/10/15.
|
||||||
|
// Copyright (c) 2015 Limelight Stream. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "Logger.h"
|
||||||
|
|
||||||
|
void Log(LogLevel level, NSString* fmt, ...) {
|
||||||
|
NSString* levelPrefix = @"";
|
||||||
|
|
||||||
|
switch(level) {
|
||||||
|
case LOG_D:
|
||||||
|
levelPrefix = PRFX_DEBUG;
|
||||||
|
break;
|
||||||
|
case LOG_I:
|
||||||
|
levelPrefix = PRFX_INFO;
|
||||||
|
break;
|
||||||
|
case LOG_W:
|
||||||
|
levelPrefix = PRFX_WARN;
|
||||||
|
break;
|
||||||
|
case LOG_E:
|
||||||
|
levelPrefix = PRFX_ERROR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
NSString* prefixedString = [NSString stringWithFormat:@"%@ %@", levelPrefix, fmt];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
NSLogv(prefixedString, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
@@ -56,18 +56,18 @@ NSString *const deviceName = @"roth";
|
|||||||
if (inet_addr([host UTF8String]) != INADDR_NONE) {
|
if (inet_addr([host UTF8String]) != INADDR_NONE) {
|
||||||
// Already an IP address
|
// Already an IP address
|
||||||
int addr = inet_addr([host UTF8String]);
|
int addr = inet_addr([host UTF8String]);
|
||||||
NSLog(@"host address: %d", addr);
|
Log(LOG_I, @"host address: %d", addr);
|
||||||
return addr;
|
return addr;
|
||||||
} else {
|
} else {
|
||||||
hostent = gethostbyname([host UTF8String]);
|
hostent = gethostbyname([host UTF8String]);
|
||||||
if (hostent != NULL) {
|
if (hostent != NULL) {
|
||||||
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
|
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
|
||||||
NSLog(@"Resolved %@ -> %s", host, ipstr);
|
Log(LOG_I, @"Resolved %@ -> %s", host, ipstr);
|
||||||
int addr = inet_addr(ipstr);
|
int addr = inet_addr(ipstr);
|
||||||
NSLog(@"host address: %d", addr);
|
Log(LOG_I, @"host address: %d", addr);
|
||||||
return addr;
|
return addr;
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Failed to resolve host: %d", h_errno);
|
Log(LOG_W, @"Failed to resolve host: %d", h_errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ static NSArray* appList;
|
|||||||
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
||||||
if (appListResp == nil || ![appListResp isStatusOk]) {
|
if (appListResp == nil || ![appListResp isStatusOk]) {
|
||||||
NSLog(@"Failed to get applist: %@", appListResp.statusMessage);
|
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
||||||
} else {
|
} else {
|
||||||
appList = [appListResp getAppList];
|
appList = [appListResp getAppList];
|
||||||
if (appList == nil) {
|
if (appList == nil) {
|
||||||
NSLog(@"Failed to parse applist");
|
Log(LOG_W, @"Failed to parse applist");
|
||||||
} else {
|
} else {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self updateApps];
|
[self updateApps];
|
||||||
@@ -112,21 +112,21 @@ static NSArray* appList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) hostClicked:(Host *)host {
|
- (void) hostClicked:(Host *)host {
|
||||||
NSLog(@"Clicked host: %@", host.name);
|
Log(LOG_D, @"Clicked host: %@", host.name);
|
||||||
_selectedHost = host;
|
_selectedHost = host;
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[hMan newServerInfoRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[hMan newServerInfoRequest]]];
|
||||||
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
||||||
NSLog(@"Failed to get server info: %@", serverInfoResp.statusMessage);
|
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
Log(LOG_D, @"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
||||||
if ([[serverInfoResp getStringTag:@"PairStatus"] isEqualToString:@"1"]) {
|
if ([[serverInfoResp getStringTag:@"PairStatus"] isEqualToString:@"1"]) {
|
||||||
NSLog(@"Already Paired");
|
Log(LOG_I, @"Already Paired");
|
||||||
[self alreadyPaired];
|
[self alreadyPaired];
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Trying to pair");
|
Log(LOG_I, @"Trying to pair");
|
||||||
// Polling the server while pairing causes the server to screw up
|
// Polling the server while pairing causes the server to screw up
|
||||||
[_discMan stopDiscoveryBlocking];
|
[_discMan stopDiscoveryBlocking];
|
||||||
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:_cert callback:self];
|
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:_cert callback:self];
|
||||||
@@ -137,7 +137,7 @@ static NSArray* appList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)hostLongClicked:(Host *)host view:(UIView *)view {
|
- (void)hostLongClicked:(Host *)host view:(UIView *)view {
|
||||||
NSLog(@"Long clicked host: %@", host.name);
|
Log(LOG_D, @"Long clicked host: %@", host.name);
|
||||||
UIAlertController* longClickAlert = [UIAlertController alertControllerWithTitle:host.name message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
|
UIAlertController* longClickAlert = [UIAlertController alertControllerWithTitle:host.name message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
|
||||||
if (host.online) {
|
if (host.online) {
|
||||||
[longClickAlert addAction:[UIAlertAction actionWithTitle:@"Unpair" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
[longClickAlert addAction:[UIAlertAction actionWithTitle:@"Unpair" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||||
@@ -185,7 +185,7 @@ static NSArray* appList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) addHostClicked {
|
- (void) addHostClicked {
|
||||||
NSLog(@"Clicked add host");
|
Log(LOG_D, @"Clicked add host");
|
||||||
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Host Address" message:@"Please enter a hostname or IP address" preferredStyle:UIAlertControllerStyleAlert];
|
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Host Address" message:@"Please enter a hostname or IP address" preferredStyle:UIAlertControllerStyleAlert];
|
||||||
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
||||||
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||||
@@ -215,7 +215,7 @@ static NSArray* appList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) appClicked:(App *)app {
|
- (void) appClicked:(App *)app {
|
||||||
NSLog(@"Clicked app: %@", app.appName);
|
Log(LOG_D, @"Clicked app: %@", app.appName);
|
||||||
_streamConfig = [[StreamConfiguration alloc] init];
|
_streamConfig = [[StreamConfiguration alloc] init];
|
||||||
_streamConfig.host = _selectedHost.address;
|
_streamConfig.host = _selectedHost.address;
|
||||||
_streamConfig.hostAddr = [Utils resolveHost:_selectedHost.address];
|
_streamConfig.hostAddr = [Utils resolveHost:_selectedHost.address];
|
||||||
@@ -245,12 +245,12 @@ static NSArray* appList;
|
|||||||
message: [app.appId isEqualToString:currentApp.appId] ? @"" : [NSString stringWithFormat:@"%@ is currently running", currentApp.appName]preferredStyle:UIAlertControllerStyleAlert];
|
message: [app.appId isEqualToString:currentApp.appId] ? @"" : [NSString stringWithFormat:@"%@ is currently running", currentApp.appName]preferredStyle:UIAlertControllerStyleAlert];
|
||||||
[alertController addAction:[UIAlertAction
|
[alertController addAction:[UIAlertAction
|
||||||
actionWithTitle:[app.appId isEqualToString:currentApp.appId] ? @"Resume App" : @"Resume Running App" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
actionWithTitle:[app.appId isEqualToString:currentApp.appId] ? @"Resume App" : @"Resume Running App" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||||
NSLog(@"Resuming application: %@", currentApp.appName);
|
Log(LOG_I, @"Resuming application: %@", currentApp.appName);
|
||||||
[self performSegueWithIdentifier:@"createStreamFrame" sender:nil];
|
[self performSegueWithIdentifier:@"createStreamFrame" sender:nil];
|
||||||
}]];
|
}]];
|
||||||
[alertController addAction:[UIAlertAction actionWithTitle:
|
[alertController addAction:[UIAlertAction actionWithTitle:
|
||||||
[app.appId isEqualToString:currentApp.appId] ? @"Quit App" : @"Quit Running App and Start" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
|
[app.appId isEqualToString:currentApp.appId] ? @"Quit App" : @"Quit Running App and Start" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
|
||||||
NSLog(@"Quitting application: %@", currentApp.appName);
|
Log(LOG_I, @"Quitting application: %@", currentApp.appName);
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[hMan newQuitAppRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[hMan newQuitAppRequest]]];
|
||||||
@@ -380,9 +380,9 @@ static NSArray* appList;
|
|||||||
|
|
||||||
- (void) updateAllHosts:(NSArray *)hosts {
|
- (void) updateAllHosts:(NSArray *)hosts {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSLog(@"New host list:");
|
Log(LOG_D, @"New host list:");
|
||||||
for (Host* host in hosts) {
|
for (Host* host in hosts) {
|
||||||
NSLog(@"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online);
|
Log(LOG_D, @"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online);
|
||||||
}
|
}
|
||||||
@synchronized(hostList) {
|
@synchronized(hostList) {
|
||||||
[hostList removeAllObjects];
|
[hostList removeAllObjects];
|
||||||
@@ -393,7 +393,7 @@ static NSArray* appList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateHosts {
|
- (void)updateHosts {
|
||||||
NSLog(@"Updating hosts...");
|
Log(LOG_I, @"Updating hosts...");
|
||||||
[[hostScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
[[hostScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||||
UIComputerView* addComp = [[UIComputerView alloc] initForAddWithCallback:self];
|
UIComputerView* addComp = [[UIComputerView alloc] initForAddWithCallback:self];
|
||||||
UIComputerView* compView;
|
UIComputerView* compView;
|
||||||
|
|||||||
@@ -1140,7 +1140,7 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
// forbid gesture if the initial translation is not horizontal
|
// forbid gesture if the initial translation is not horizontal
|
||||||
UIView *recognizerView = _panGestureRecognizer.view;
|
UIView *recognizerView = _panGestureRecognizer.view;
|
||||||
CGPoint translation = [_panGestureRecognizer translationInView:recognizerView];
|
CGPoint translation = [_panGestureRecognizer translationInView:recognizerView];
|
||||||
// NSLog( @"translation:%@", NSStringFromCGPoint(translation) );
|
// Log(LOG_D, @"translation:%@", NSStringFromCGPoint(translation) );
|
||||||
// if ( fabs(translation.y/translation.x) > 1 )
|
// if ( fabs(translation.y/translation.x) > 1 )
|
||||||
// return NO;
|
// return NO;
|
||||||
|
|
||||||
@@ -1252,7 +1252,7 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
|
|
||||||
CGFloat xLocation = frontView.frame.origin.x;
|
CGFloat xLocation = frontView.frame.origin.x;
|
||||||
CGFloat velocity = [recognizer velocityInView:_contentView].x;
|
CGFloat velocity = [recognizer velocityInView:_contentView].x;
|
||||||
//NSLog( @"Velocity:%1.4f", velocity);
|
//Log(LOG_D, @"Velocity:%1.4f", velocity);
|
||||||
|
|
||||||
// depending on position we compute a simetric replacement of widths and positions
|
// depending on position we compute a simetric replacement of widths and positions
|
||||||
int symetry = xLocation<0 ? -1 : 1;
|
int symetry = xLocation<0 ? -1 : 1;
|
||||||
|
|||||||
@@ -59,13 +59,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)edgeSwiped {
|
- (void)edgeSwiped {
|
||||||
NSLog(@"User swiped to end stream");
|
Log(LOG_D, @"User swiped to end stream");
|
||||||
[_streamMan stopStream];
|
[_streamMan stopStream];
|
||||||
[self returnToMainFrame];
|
[self returnToMainFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) connectionStarted {
|
- (void) connectionStarted {
|
||||||
NSLog(@"Connection started");
|
Log(LOG_I, @"Connection started");
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.spinner stopAnimating];
|
[self.spinner stopAnimating];
|
||||||
[self.stageLabel setText:@"Waiting for first frame..."];
|
[self.stageLabel setText:@"Waiting for first frame..."];
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
UIScreenEdgePanGestureRecognizer* swipeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
UIScreenEdgePanGestureRecognizer* swipeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
||||||
swipeGesture.edges = UIRectEdgeLeft;
|
swipeGesture.edges = UIRectEdgeLeft;
|
||||||
if (swipeGesture == nil) {
|
if (swipeGesture == nil) {
|
||||||
NSLog(@"An error occured trying to create UIScreenEdgePanGestureRecognizer");
|
Log(LOG_E, @"An error occured trying to create UIScreenEdgePanGestureRecognizer");
|
||||||
} else {
|
} else {
|
||||||
[self.view addGestureRecognizer:swipeGesture];
|
[self.view addGestureRecognizer:swipeGesture];
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)connectionTerminated:(long)errorCode {
|
- (void)connectionTerminated:(long)errorCode {
|
||||||
NSLog(@"Connection terminated: %ld", errorCode);
|
Log(LOG_I, @"Connection terminated: %ld", errorCode);
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection was terminated" preferredStyle:UIAlertControllerStyleAlert];
|
UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection was terminated" preferredStyle:UIAlertControllerStyleAlert];
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) stageStarting:(char*)stageName {
|
- (void) stageStarting:(char*)stageName {
|
||||||
NSLog(@"Starting %s", stageName);
|
Log(LOG_I, @"Starting %s", stageName);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSString* lowerCase = [NSString stringWithFormat:@"%s in progress...", stageName];
|
NSString* lowerCase = [NSString stringWithFormat:@"%s in progress...", stageName];
|
||||||
NSString* titleCase = [[[lowerCase substringToIndex:1] uppercaseString] stringByAppendingString:[lowerCase substringFromIndex:1]];
|
NSString* titleCase = [[[lowerCase substringToIndex:1] uppercaseString] stringByAppendingString:[lowerCase substringFromIndex:1]];
|
||||||
@@ -131,11 +131,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) displayMessage:(char*)message {
|
- (void) displayMessage:(char*)message {
|
||||||
NSLog(@"Display message: %s", message);
|
Log(LOG_I, @"Display message: %s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) displayTransientMessage:(char*)message {
|
- (void) displayTransientMessage:(char*)message {
|
||||||
NSLog(@"Display transient message: %s", message);
|
Log(LOG_I, @"Display transient message: %s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
|||||||
Reference in New Issue
Block a user