Compare commits

...
Author SHA1 Message Date
Diego Waxemberg 33d6306359 Created beta 9 2014-11-25 18:35:12 -05:00
Diego Waxemberg 5ee9e285e7 created beta 8 2014-11-18 10:28:12 -05:00
Cameron Gutman d8020a367f Update to the new common library 2014-11-11 19:03:46 -08:00
Cameron Gutman 88c917c103 Fix iOS build with new common 2014-10-31 21:43:13 -07:00
Diego Waxemberg 6273f2bb29 Pulled common and created new build 2014-10-27 19:53:50 -04:00
Diego Waxemberg fac48ecf42 Created new build and removed beta builds 2014-10-24 15:56:04 -04:00
Cameron Gutman b5bf26bb2d Add busy warning to pairing 2014-10-23 23:46:41 -04:00
Cameron Gutman 00fab87b4c Merge branch 'master' of github.com:limelight-stream/limelight-ios 2014-10-23 23:41:25 -04:00
Cameron Gutman 3554b40962 Display status messages for failed app launch 2014-10-23 23:41:07 -04:00
Diego Waxemberg aa3752a905 Merge branch 'master' of github.com:limelight-stream/limelight-ios
# By Cameron Gutman
# Via Cameron Gutman
* 'master' of github.com:limelight-stream/limelight-ios:
  Add better messages to pairing
  Fix missing video issue
2014-10-23 23:17:18 -04:00
Cameron Gutman 47850cd658 Add better messages to pairing 2014-10-23 23:11:24 -04:00
Cameron Gutman 1b98870b41 Fix missing video issue 2014-10-23 22:35:59 -04:00
14 changed files with 90 additions and 55 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>9</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSRequiresIPhoneOS</key>
+1
View File
@@ -11,6 +11,7 @@
@interface HttpManager : NSObject <NSURLConnectionDelegate, NSURLConnectionDataDelegate>
+ (NSString*) getStringFromXML:(NSData*)xml tag:(NSString*)tag;
+ (NSString*) getStatusStringFromXML:(NSData*)xml;
- (id) initWithHost:(NSString*) host uniqueId:(NSString*) uniqueId deviceName:(NSString*) deviceName cert:(NSData*) cert;
- (NSURLRequest*) newPairRequest:(NSData*)salt;
+25
View File
@@ -25,6 +25,24 @@
static const NSString* PORT = @"47984";
+ (NSString*) getStatusStringFromXML:(NSData*)xml {
xmlDocPtr docPtr = xmlParseMemory([xml bytes], (int)[xml length]);
if (docPtr == NULL) {
NSLog(@"ERROR: An error occured trying to parse xml.");
return NULL;
}
NSString* string;
xmlNodePtr rootNode = xmlDocGetRootElement(docPtr);
string = [HttpManager getStatusMessage: rootNode];
xmlFree(rootNode);
xmlFree(docPtr);
return string;
}
+ (NSString*) getStringFromXML:(NSData*)xml tag:(NSString*)tag {
xmlDocPtr docPtr = xmlParseMemory([xml bytes], (int)[xml length]);
@@ -60,6 +78,13 @@ static const NSString* PORT = @"47984";
return value;
}
+ (NSString*) getStatusMessage:(xmlNodePtr)docRoot {
xmlChar* statusMsgXml = xmlGetProp(docRoot, (const xmlChar*)"status_message");
NSString* statusMsg = [NSString stringWithUTF8String:(const char*)statusMsgXml];
xmlFree(statusMsgXml);
return statusMsg;
}
+ (bool) verifyStatus:(xmlNodePtr)docRoot {
xmlChar* statusStr = xmlGetProp(docRoot, (const xmlChar*)"status_code");
+17 -17
View File
@@ -28,12 +28,19 @@
- (void) main {
NSData* serverInfo = [_httpManager executeRequestSynchronously:[_httpManager newServerInfoRequest]];
if (![[HttpManager getStringFromXML:serverInfo tag:@"PairStatus"] isEqual:@"1"]) {
if (serverInfo == NULL) {
[_callback pairFailed:@"Unable to connect to PC"];
return;
}
if (![[HttpManager getStringFromXML:serverInfo tag:@"currentgame"] isEqual:@"0"]) {
[_callback pairFailed:@"You must stop streaming before attempting to pair."];
}
else if (![[HttpManager getStringFromXML:serverInfo tag:@"PairStatus"] isEqual:@"1"]) {
[self initiatePair];
} else {
[_callback pairFailed:@"Already Paired"];
[_callback pairFailed:@"This device is already paired."];
}
[_httpManager executeRequestSynchronously:[_httpManager newAppListRequest]];
}
- (void) initiatePair {
@@ -47,8 +54,7 @@
pairedString = [HttpManager getStringFromXML:pairResp tag:@"paired"];
if (pairedString == NULL || ![pairedString isEqualToString:@"1"]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"pairResp failed"];
[_callback pairFailed:@"Pairing was declined by the target."];
return;
}
@@ -64,8 +70,7 @@
pairedString = [HttpManager getStringFromXML:challengeResp tag:@"paired"];
if (pairedString == NULL || ![pairedString isEqualToString:@"1"]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"challengeResp failed"];
[_callback pairFailed:@"Pairing stage #2 failed"];
return;
}
@@ -83,8 +88,7 @@
pairedString = [HttpManager getStringFromXML:secretResp tag:@"paired"];
if (pairedString == NULL || ![pairedString isEqualToString:@"1"]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"secretResp failed"];
[_callback pairFailed:@"Pairing stage #3 failed"];
return;
}
@@ -94,16 +98,14 @@
if (![cryptoMan verifySignature:serverSecret withSignature:serverSignature andCert:[Utils hexToBytes:plainCert]]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"verifySignature failed"];
[_callback pairFailed:@"Server certificate invalid"];
return;
}
NSData* serverChallengeRespHash = [cryptoMan SHA1HashData:[self concatData:[self concatData:randomChallenge with:[CryptoManager getSignatureFromCert:[Utils hexToBytes:plainCert]]] with:serverSecret]];
if (![serverChallengeRespHash isEqual:serverResponse]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"serverChallengeResp failed"];
[_callback pairFailed:@"Incorrect PIN"];
return;
}
@@ -112,8 +114,7 @@
pairedString = [HttpManager getStringFromXML:clientSecretResp tag:@"paired"];
if (pairedString == NULL || ![pairedString isEqualToString:@"1"]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"clientSecretResp failed"];
[_callback pairFailed:@"Pairing stage #4 failed"];
return;
}
@@ -121,8 +122,7 @@
pairedString = [HttpManager getStringFromXML:clientPairChallenge tag:@"paired"];
if (pairedString == NULL || ![pairedString isEqualToString:@"1"]) {
[_httpManager executeRequestSynchronously:[_httpManager newUnpairRequest]];
//TODO: better message
[_callback pairFailed:@"clientPairChallenge failed"];
[_callback pairFailed:@"Pairing stage #5 failed"];
return;
}
[_callback pairSuccessful];
+1 -1
View File
@@ -17,7 +17,7 @@
- (void) stageStarting:(char*)stageName;
- (void) stageComplete:(char*)stageName;
- (void) stageFailed:(char*)stageName withError:(long)errorCode;
- (void) launchFailed;
- (void) launchFailed:(NSString*)message;
- (void) displayMessage:(char*)message;
- (void) displayTransientMessage:(char*)message;
+13 -1
View File
@@ -408,7 +408,19 @@ static OSStatus playbackCallback(void *inRefCon,
-(void) main
{
LiStartConnection(_host, &_streamConfig, &_clCallbacks, &_drCallbacks, &_arCallbacks, NULL, 0);
PLATFORM_CALLBACKS dummyPlCallbacks;
// Only used on Windows
dummyPlCallbacks.threadStart = NULL;
dummyPlCallbacks.debugPrint = NULL;
LiStartConnection(_host,
&_streamConfig,
&_clCallbacks,
&_drCallbacks,
&_arCallbacks,
&dummyPlCallbacks,
NULL, 0);
}
+13 -7
View File
@@ -43,27 +43,25 @@
NSString* currentGame = [HttpManager getStringFromXML:serverInfoResp tag:@"currentgame"];
NSString* pairStatus = [HttpManager getStringFromXML:serverInfoResp tag:@"PairStatus"];
if (currentGame == NULL || pairStatus == NULL) {
[_callbacks launchFailed];
[_callbacks launchFailed:@"Failed to connect to PC"];
return;
}
if (![pairStatus isEqualToString:@"1"]) {
// Not paired
// TODO: Display better error message
[_callbacks launchFailed];
[_callbacks launchFailed:@"Device not paired to PC"];
return;
}
// resumeApp and launchApp handle calling launchFailed
if (![currentGame isEqualToString:@"0"]) {
// App already running, resume it
if (![self resumeApp:hMan]) {
[_callbacks launchFailed];
return;
}
} else {
// Start app
if (![self launchApp:hMan]) {
[_callbacks launchFailed];
return;
}
}
@@ -88,7 +86,11 @@
rikey:[Utils bytesToHex:_config.riKey]
rikeyid:_config.riKeyId]];
NSString *gameSession = [HttpManager getStringFromXML:launchResp tag:@"gamesession"];
if (gameSession == NULL || [gameSession isEqualToString:@"0"]) {
if (launchResp == NULL) {
[_callbacks launchFailed:@"Failed to launch app"];
return FALSE;
} else if (gameSession == NULL || [gameSession isEqualToString:@"0"]) {
[_callbacks launchFailed:[HttpManager getStatusStringFromXML:launchResp]];
return FALSE;
}
@@ -100,7 +102,11 @@
[hMan newResumeRequestWithRiKey:[Utils bytesToHex:_config.riKey]
riKeyId:_config.riKeyId]];
NSString *resume = [HttpManager getStringFromXML:resumeResp tag:@"resume"];
if (resume == NULL || [resume isEqualToString:@"0"]) {
if (resumeResp == NULL) {
[_callbacks launchFailed:@"Failed to resume app"];
return FALSE;
} else if (resume == NULL || [resume isEqualToString:@"0"]) {
[_callbacks launchFailed:[HttpManager getStatusStringFromXML:resumeResp]];
return FALSE;
}
+16 -25
View File
@@ -10,10 +10,9 @@
@implementation VideoDecoderRenderer {
AVSampleBufferDisplayLayer* displayLayer;
Boolean waitingForSps, waitingForPpsA, waitingForPpsB;
Boolean waitingForSps, waitingForPps;
NSData *spsData, *ppsDataA, *ppsDataB;
unsigned char ppsDataAFirstByte;
NSData *spsData, *ppsData;
CMVideoFormatDescriptionRef formatDesc;
}
@@ -30,8 +29,7 @@
// We need some parameter sets before we can properly start decoding frames
waitingForSps = true;
waitingForPpsA = true;
waitingForPpsB = true;
waitingForPps = true;
return self;
}
@@ -114,34 +112,27 @@
unsigned char nalType = data[FRAME_START_PREFIX_SIZE] & 0x1F;
OSStatus status;
if (formatDesc == NULL && (nalType == 0x7 || nalType == 0x8)) {
if (waitingForSps && nalType == 0x7) {
if (nalType == 0x7 || nalType == 0x8) {
if (nalType == 0x7) {
printf("Got SPS\n");
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
waitingForSps = false;
// We got a new SPS so wait for a new PPS to match it
waitingForPps = true;
}
// Nvidia's stream has 2 PPS NALUs so we'll wait for both of them
else if ((waitingForPpsA || waitingForPpsB) && nalType == 0x8) {
// Read the NALU's PPS index to figure out which PPS this is
if (waitingForPpsA) {
printf("Got PPS 1\n");
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
waitingForPpsA = false;
ppsDataAFirstByte = data[FRAME_START_PREFIX_SIZE + 1];
}
else if (data[FRAME_START_PREFIX_SIZE + 1] != ppsDataAFirstByte) {
printf("Got PPS 2\n");
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
waitingForPpsB = false;
}
else if (nalType == 0x8) {
printf("Got PPS\n");
ppsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
waitingForPps = false;
}
// See if we've got all the parameter sets we need
if (!waitingForSps && !waitingForPpsA && !waitingForPpsB) {
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsDataA bytes], [ppsDataB bytes] };
const size_t parameterSetSizes[] = { [spsData length], [ppsDataA length], [ppsDataB length] };
if (!waitingForSps && !waitingForPps) {
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsData bytes] };
const size_t parameterSetSizes[] = { [spsData length], [ppsData length] };
printf("Constructing format description\n");
printf("Constructing new format description\n");
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
2, /* count of parameter sets */
parameterSetPointers,
@@ -91,9 +91,9 @@
[self presentViewController:alert animated:YES completion:nil];
}
- (void) launchFailed {
- (void) launchFailed:(NSString*)message {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed"
message:@"Failed to start app"
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
[self performSegueWithIdentifier:@"returnToMainFrame" sender:self];