From 4c646e36c7c21721a57fccae0128975579813d07 Mon Sep 17 00:00:00 2001 From: Diego Waxemberg Date: Mon, 20 Oct 2014 20:54:03 -0400 Subject: [PATCH] added support for different resolutions and frame rates --- Limelight/Connection.m | 2 +- Limelight/MainFrameViewController.h | 3 +- Limelight/MainFrameViewController.m | 42 ++++++++++++++++++++++++--- Limelight/StreamConfiguration.h | 3 +- Limelight/StreamConfiguration.m | 2 +- Limelight/StreamFrameViewController.m | 2 +- Limelight/StreamManager.h | 3 +- Limelight/StreamManager.m | 25 +++++++--------- MainFrame-iPhone.storyboard | 32 +++++++++++--------- 9 files changed, 75 insertions(+), 39 deletions(-) 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 93a70c6..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; @@ -20,6 +21,6 @@ @property (strong, nonatomic) NSArray* hostPickerVals; @property (strong, nonatomic) IBOutlet UITextField *hostTextField; -+ (NSString*) getHost; ++ (StreamConfiguration*) getStreamConfiguration; @end diff --git a/Limelight/MainFrameViewController.m b/Limelight/MainFrameViewController.m index 4d78225..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,10 +21,10 @@ Computer* _selectedHost; UIAlertView* _pairAlert; } -static NSString* host; +static StreamConfiguration* streamConfig; -+ (NSString*) getHost { - return host; ++ (StreamConfiguration*) getStreamConfiguration { + return streamConfig; } - (void)PairButton:(UIButton *)sender @@ -73,7 +74,40 @@ static NSString* host; _selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text]; NSLog(@"Using custom host: %@", self.hostTextField.text); } - host = _selectedHost.hostName; + 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 1f4d5d1..fc35ae4 100644 --- a/Limelight/StreamFrameViewController.m +++ b/Limelight/StreamFrameViewController.m @@ -24,7 +24,7 @@ [UIApplication sharedApplication].idleTimerDisabled = YES; - 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-iPhone.storyboard b/MainFrame-iPhone.storyboard index 8418625..f25c60d 100644 --- a/MainFrame-iPhone.storyboard +++ b/MainFrame-iPhone.storyboard @@ -16,7 +16,7 @@ - - - - - - - - - - + - - + + + + + + + + + + - - + + + + +