diff --git a/Limelight/Computer.h b/Limelight/Computer.h index 17fec12..854a3dd 100644 --- a/Limelight/Computer.h +++ b/Limelight/Computer.h @@ -14,5 +14,6 @@ @property BOOL paired; - (id) initWithHost:(NSNetService*)host; +- (id) initWithIp:(NSString*)host; @end diff --git a/Limelight/Computer.m b/Limelight/Computer.m index 2d03366..6a7cb22 100644 --- a/Limelight/Computer.m +++ b/Limelight/Computer.m @@ -19,4 +19,13 @@ return self; } +- (id) initWithIp:(NSString*)host { + self = [super init]; + + self.hostName = host; + self.displayName = host; + + return self; +} + @end diff --git a/Limelight/Connection.m b/Limelight/Connection.m index 37c3196..1f27fcf 100644 --- a/Limelight/Connection.m +++ b/Limelight/Connection.m @@ -196,7 +196,7 @@ void ClDisplayTransientMessage(char* message) -(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer { self = [super init]; - host = config.host; + host = config.hostAddr; renderer = myRenderer; streamConfig.width = config.width; diff --git a/Limelight/MainFrameViewController.h b/Limelight/MainFrameViewController.h index 3dcb829..c178a73 100644 --- a/Limelight/MainFrameViewController.h +++ b/Limelight/MainFrameViewController.h @@ -9,6 +9,7 @@ #import #import "MDNSManager.h" #import "PairManager.h" +#import "StreamConfiguration.h" @interface MainFrameViewController : UIViewController @property (strong, nonatomic) IBOutlet UIPickerView *HostPicker; @@ -18,9 +19,8 @@ @property (strong, nonatomic) IBOutlet UIPickerView *StreamConfigs; @property (strong, nonatomic) NSArray* streamConfigVals; @property (strong, nonatomic) NSArray* hostPickerVals; +@property (strong, nonatomic) IBOutlet UITextField *hostTextField; -- (void) segueIntoStream; - -+ (NSString*) getHost; ++ (StreamConfiguration*) getStreamConfiguration; @end diff --git a/Limelight/MainFrameViewController.m b/Limelight/MainFrameViewController.m index 726eb43..7ad189c 100644 --- a/Limelight/MainFrameViewController.m +++ b/Limelight/MainFrameViewController.m @@ -13,6 +13,7 @@ #import "Connection.h" #import "VideoDecoderRenderer.h" #import "StreamManager.h" +#import "Utils.h" @implementation MainFrameViewController { NSOperationQueue* _opQueue; @@ -20,15 +21,19 @@ Computer* _selectedHost; UIAlertView* _pairAlert; } -static NSString* host; +static StreamConfiguration* streamConfig; -+ (NSString*) getHost { - return host; ++ (StreamConfiguration*) getStreamConfiguration { + return streamConfig; } - (void)PairButton:(UIButton *)sender { NSLog(@"Pair Button Pressed!"); + if ([self.hostTextField.text length] > 0) { + _selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text]; + NSLog(@"Using custom host: %@", self.hostTextField.text); + } [CryptoManager generateKeyPairUsingSSl]; NSString* uniqueId = [CryptoManager getUniqueID]; NSData* cert = [CryptoManager readCertFromFile]; @@ -65,7 +70,44 @@ static NSString* host; - (void)StreamButton:(UIButton *)sender { NSLog(@"Stream Button Pressed!"); - host = _selectedHost.hostName; + if ([self.hostTextField.text length] > 0) { + _selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text]; + NSLog(@"Using custom host: %@", self.hostTextField.text); + } + streamConfig = [[StreamConfiguration alloc] init]; + streamConfig.host = _selectedHost.hostName; + streamConfig.hostAddr = [Utils resolveHost:_selectedHost.hostName]; + + int selectedConf = [self.StreamConfigs selectedRowInComponent:0]; + NSLog(@"selectedConf: %d", selectedConf); + switch (selectedConf) { + case 0: + streamConfig.width = 1280; + streamConfig.height = 720; + streamConfig.frameRate = 30; + break; + case 1: + streamConfig.width = 1280; + streamConfig.height = 720; + streamConfig.frameRate = 60; + break; + case 2: + streamConfig.width = 1920; + streamConfig.height = 720; + streamConfig.frameRate = 30; + break; + case 3: + streamConfig.width = 1920; + streamConfig.height = 1080; + streamConfig.frameRate = 60; + break; + default: + streamConfig.width = 1280; + streamConfig.height = 720; + streamConfig.frameRate = 60; + break; + } + NSLog(@"StreamConfig: %@, %d, %dx%dx%d", streamConfig.host, streamConfig.hostAddr, streamConfig.width, streamConfig.height, streamConfig.frameRate); [self performSegueWithIdentifier:@"createStreamFrame" sender:self]; } diff --git a/Limelight/StreamConfiguration.h b/Limelight/StreamConfiguration.h index 7842358..6129ed3 100644 --- a/Limelight/StreamConfiguration.h +++ b/Limelight/StreamConfiguration.h @@ -10,7 +10,8 @@ @interface StreamConfiguration : NSObject -@property int host; +@property NSString* host; +@property int hostAddr; @property int width; @property int height; @property int frameRate; diff --git a/Limelight/StreamConfiguration.m b/Limelight/StreamConfiguration.m index e31ebd1..b2607bb 100644 --- a/Limelight/StreamConfiguration.m +++ b/Limelight/StreamConfiguration.m @@ -9,5 +9,5 @@ #import "StreamConfiguration.h" @implementation StreamConfiguration -@synthesize host, width, height, frameRate, bitRate, riKeyId, riKey; +@synthesize host, hostAddr, width, height, frameRate, bitRate, riKeyId, riKey; @end diff --git a/Limelight/StreamFrameViewController.m b/Limelight/StreamFrameViewController.m index 4a0fc60..4bf4b5b 100644 --- a/Limelight/StreamFrameViewController.m +++ b/Limelight/StreamFrameViewController.m @@ -29,7 +29,7 @@ _controllerSupport = [[ControllerSupport alloc] init]; - StreamManager* streamMan = [[StreamManager alloc] initWithHost:[MainFrameViewController getHost] renderView:self.view]; + StreamManager* streamMan = [[StreamManager alloc] initWithConfig:[MainFrameViewController getStreamConfiguration] renderView:self.view]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; [opQueue addOperation:streamMan]; } diff --git a/Limelight/StreamManager.h b/Limelight/StreamManager.h index a4973dc..a08aa57 100644 --- a/Limelight/StreamManager.h +++ b/Limelight/StreamManager.h @@ -7,9 +7,10 @@ // #import +#import "StreamConfiguration.h" @interface StreamManager : NSOperation -- (id) initWithHost:(NSString*)host renderView:(UIView*)view; +- (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view; @end diff --git a/Limelight/StreamManager.m b/Limelight/StreamManager.m index 4a9e786..5506b77 100644 --- a/Limelight/StreamManager.m +++ b/Limelight/StreamManager.m @@ -11,44 +11,39 @@ #import "HttpManager.h" #import "Utils.h" #import "Connection.h" -#import "StreamConfiguration.h" @implementation StreamManager { - NSString* _host; + StreamConfiguration* _config; UIView* _renderView; } -- (id) initWithHost:(NSString*)host renderView:(UIView*)view { +- (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view { self = [super init]; - _host = host; + _config = config; _renderView = view; return self; } + - (void)main { [CryptoManager generateKeyPairUsingSSl]; NSString* uniqueId = [CryptoManager getUniqueID]; NSData* cert = [CryptoManager readCertFromFile]; - HttpManager* hMan = [[HttpManager alloc] initWithHost:_host uniqueId:uniqueId deviceName:@"roth" cert:cert]; + HttpManager* hMan = [[HttpManager alloc] initWithHost:_config.host uniqueId:uniqueId deviceName:@"roth" cert:cert]; NSData* riKey = [Utils randomBytes:16]; int riKeyId = arc4random(); - NSData* launchResp = [hMan executeRequestSynchronously:[hMan newLaunchRequest:@"67339056" width:1920 height:1080 refreshRate:30 rikey:[Utils bytesToHex:riKey] rikeyid:riKeyId]]; + NSData* launchResp = [hMan executeRequestSynchronously:[hMan newLaunchRequest:@"67339056" width:_config.width height:_config.height refreshRate:_config.frameRate rikey:[Utils bytesToHex:riKey] rikeyid:riKeyId]]; [HttpManager getStringFromXML:launchResp tag:@"gamesession"]; VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView]; - StreamConfiguration* config = [[StreamConfiguration alloc] init]; - config.host = [Utils resolveHost:_host]; - config.width = 1920; - config.height = 1080; - config.frameRate = 30; - config.bitRate = 10000; - config.riKey = riKey; - config.riKeyId = riKeyId; + _config.bitRate = 10000; + _config.riKey = riKey; + _config.riKeyId = riKeyId; - Connection* conn = [[Connection alloc] initWithConfig:config renderer:renderer]; + Connection* conn = [[Connection alloc] initWithConfig:_config renderer:renderer]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; [opQueue addOperation:conn]; diff --git a/MainFrame-iPad.storyboard b/MainFrame-iPad.storyboard index beb2966..18c5087 100644 --- a/MainFrame-iPad.storyboard +++ b/MainFrame-iPad.storyboard @@ -1,7 +1,7 @@ - + - + @@ -50,6 +50,11 @@ + + + + + @@ -57,6 +62,7 @@ + diff --git a/MainFrame-iPhone.storyboard b/MainFrame-iPhone.storyboard index b00cd4e..f25c60d 100644 --- a/MainFrame-iPhone.storyboard +++ b/MainFrame-iPhone.storyboard @@ -1,8 +1,7 @@ - + - - + @@ -17,7 +16,7 @@ - - - - - - - - - - + + + + + + + + + + + + + + - - + + + + + @@ -73,6 +81,7 @@ +