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
This commit is contained in:
Diego Waxemberg 2014-10-23 23:17:18 -04:00
commit aa3752a905
2 changed files with 29 additions and 41 deletions

View File

@ -28,12 +28,16 @@
- (void) main {
NSData* serverInfo = [_httpManager executeRequestSynchronously:[_httpManager newServerInfoRequest]];
if (serverInfo == NULL) {
[_callback pairFailed:@"Unable to connect to PC"];
return;
}
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 +51,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 +67,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 +85,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 +95,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 +111,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 +119,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];

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,