added support for different resolutions and frame rates

This commit is contained in:
Diego Waxemberg
2014-10-20 20:54:03 -04:00
parent 85ee4f6518
commit 4c646e36c7
9 changed files with 75 additions and 39 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ void ClDisplayTransientMessage(char* message)
-(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer -(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer
{ {
self = [super init]; self = [super init];
host = config.host; host = config.hostAddr;
renderer = myRenderer; renderer = myRenderer;
streamConfig.width = config.width; streamConfig.width = config.width;
+2 -1
View File
@@ -9,6 +9,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "MDNSManager.h" #import "MDNSManager.h"
#import "PairManager.h" #import "PairManager.h"
#import "StreamConfiguration.h"
@interface MainFrameViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate, MDNSCallback, NSURLConnectionDelegate, PairCallback> @interface MainFrameViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate, MDNSCallback, NSURLConnectionDelegate, PairCallback>
@property (strong, nonatomic) IBOutlet UIPickerView *HostPicker; @property (strong, nonatomic) IBOutlet UIPickerView *HostPicker;
@@ -20,6 +21,6 @@
@property (strong, nonatomic) NSArray* hostPickerVals; @property (strong, nonatomic) NSArray* hostPickerVals;
@property (strong, nonatomic) IBOutlet UITextField *hostTextField; @property (strong, nonatomic) IBOutlet UITextField *hostTextField;
+ (NSString*) getHost; + (StreamConfiguration*) getStreamConfiguration;
@end @end
+38 -4
View File
@@ -13,6 +13,7 @@
#import "Connection.h" #import "Connection.h"
#import "VideoDecoderRenderer.h" #import "VideoDecoderRenderer.h"
#import "StreamManager.h" #import "StreamManager.h"
#import "Utils.h"
@implementation MainFrameViewController { @implementation MainFrameViewController {
NSOperationQueue* _opQueue; NSOperationQueue* _opQueue;
@@ -20,10 +21,10 @@
Computer* _selectedHost; Computer* _selectedHost;
UIAlertView* _pairAlert; UIAlertView* _pairAlert;
} }
static NSString* host; static StreamConfiguration* streamConfig;
+ (NSString*) getHost { + (StreamConfiguration*) getStreamConfiguration {
return host; return streamConfig;
} }
- (void)PairButton:(UIButton *)sender - (void)PairButton:(UIButton *)sender
@@ -73,7 +74,40 @@ static NSString* host;
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text]; _selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
NSLog(@"Using custom host: %@", 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]; [self performSegueWithIdentifier:@"createStreamFrame" sender:self];
} }
+2 -1
View File
@@ -10,7 +10,8 @@
@interface StreamConfiguration : NSObject @interface StreamConfiguration : NSObject
@property int host; @property NSString* host;
@property int hostAddr;
@property int width; @property int width;
@property int height; @property int height;
@property int frameRate; @property int frameRate;
+1 -1
View File
@@ -9,5 +9,5 @@
#import "StreamConfiguration.h" #import "StreamConfiguration.h"
@implementation StreamConfiguration @implementation StreamConfiguration
@synthesize host, width, height, frameRate, bitRate, riKeyId, riKey; @synthesize host, hostAddr, width, height, frameRate, bitRate, riKeyId, riKey;
@end @end
+1 -1
View File
@@ -24,7 +24,7 @@
[UIApplication sharedApplication].idleTimerDisabled = YES; [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]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
[opQueue addOperation:streamMan]; [opQueue addOperation:streamMan];
} }
+2 -1
View File
@@ -7,9 +7,10 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "StreamConfiguration.h"
@interface StreamManager : NSOperation @interface StreamManager : NSOperation
- (id) initWithHost:(NSString*)host renderView:(UIView*)view; - (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view;
@end @end
+10 -15
View File
@@ -11,44 +11,39 @@
#import "HttpManager.h" #import "HttpManager.h"
#import "Utils.h" #import "Utils.h"
#import "Connection.h" #import "Connection.h"
#import "StreamConfiguration.h"
@implementation StreamManager { @implementation StreamManager {
NSString* _host; StreamConfiguration* _config;
UIView* _renderView; UIView* _renderView;
} }
- (id) initWithHost:(NSString*)host renderView:(UIView*)view { - (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view {
self = [super init]; self = [super init];
_host = host; _config = config;
_renderView = view; _renderView = view;
return self; return self;
} }
- (void)main { - (void)main {
[CryptoManager generateKeyPairUsingSSl]; [CryptoManager generateKeyPairUsingSSl];
NSString* uniqueId = [CryptoManager getUniqueID]; NSString* uniqueId = [CryptoManager getUniqueID];
NSData* cert = [CryptoManager readCertFromFile]; 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]; NSData* riKey = [Utils randomBytes:16];
int riKeyId = arc4random(); 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"]; [HttpManager getStringFromXML:launchResp tag:@"gamesession"];
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView]; VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
StreamConfiguration* config = [[StreamConfiguration alloc] init]; _config.bitRate = 10000;
config.host = [Utils resolveHost:_host]; _config.riKey = riKey;
config.width = 1920; _config.riKeyId = riKeyId;
config.height = 1080;
config.frameRate = 30;
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]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
[opQueue addOperation:conn]; [opQueue addOperation:conn];
+18 -14
View File
@@ -16,7 +16,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/> <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J5M-pv-UHA"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J5M-pv-UHA">
<rect key="frame" x="82" y="231" width="156" height="30"/> <rect key="frame" x="82" y="231" width="156" height="30"/>
<state key="normal" title="Start Streaming Steam"> <state key="normal" title="Start Streaming Steam">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -25,7 +25,7 @@
<action selector="StreamButton:" destination="dgh-JZ-Q7z" eventType="touchUpInside" id="3Bj-I0-bKs"/> <action selector="StreamButton:" destination="dgh-JZ-Q7z" eventType="touchUpInside" id="3Bj-I0-bKs"/>
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ATh-Tf-xRL"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ATh-Tf-xRL">
<rect key="frame" x="137" y="269" width="46" height="30"/> <rect key="frame" x="137" y="269" width="46" height="30"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="46" id="mm8-gm-flQ"/> <constraint firstAttribute="width" constant="46" id="mm8-gm-flQ"/>
@@ -37,38 +37,42 @@
<action selector="PairButton:" destination="dgh-JZ-Q7z" eventType="touchUpInside" id="jHN-B5-hsw"/> <action selector="PairButton:" destination="dgh-JZ-Q7z" eventType="touchUpInside" id="jHN-B5-hsw"/>
</connections> </connections>
</button> </button>
<pickerView contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0xb-lk-PHK"> <pickerView contentMode="scaleToFill" verticalHuggingPriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="nFR-to-qQs">
<rect key="frame" x="0.0" y="286" width="320" height="162"/>
<connections>
<outlet property="dataSource" destination="dgh-JZ-Q7z" id="R0Y-EX-neJ"/>
<outlet property="delegate" destination="dgh-JZ-Q7z" id="mkk-oI-y7K"/>
</connections>
</pickerView>
<pickerView contentMode="scaleToFill" verticalHuggingPriority="249" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nFR-to-qQs">
<rect key="frame" x="0.0" y="20" width="320" height="216"/> <rect key="frame" x="0.0" y="20" width="320" height="216"/>
<connections> <connections>
<outlet property="dataSource" destination="dgh-JZ-Q7z" id="C28-Eh-A6L"/> <outlet property="dataSource" destination="dgh-JZ-Q7z" id="C28-Eh-A6L"/>
<outlet property="delegate" destination="dgh-JZ-Q7z" id="dTy-8g-aj1"/> <outlet property="delegate" destination="dgh-JZ-Q7z" id="dTy-8g-aj1"/>
</connections> </connections>
</pickerView> </pickerView>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Geforce Host" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="unc-nO-WPH"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Geforce Host" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="unc-nO-WPH">
<rect key="frame" x="82" y="193" width="156" height="30"/> <rect key="frame" x="82" y="179" width="156" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
</textField> </textField>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0xb-lk-PHK">
<rect key="frame" x="0.0" y="269" width="320" height="162"/>
<connections>
<outlet property="dataSource" destination="dgh-JZ-Q7z" id="R0Y-EX-neJ"/>
<outlet property="delegate" destination="dgh-JZ-Q7z" id="mkk-oI-y7K"/>
</connections>
</pickerView>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="0xb-lk-PHK" firstAttribute="leading" secondItem="2rs-P3-zn7" secondAttribute="leading" id="350-bN-0q6"/> <constraint firstItem="0xb-lk-PHK" firstAttribute="leading" secondItem="2rs-P3-zn7" secondAttribute="leading" id="350-bN-0q6"/>
<constraint firstAttribute="centerX" secondItem="J5M-pv-UHA" secondAttribute="centerX" id="5jf-C1-faJ"/> <constraint firstAttribute="centerX" secondItem="J5M-pv-UHA" secondAttribute="centerX" id="5jf-C1-faJ"/>
<constraint firstItem="unc-nO-WPH" firstAttribute="top" secondItem="0HR-9w-kvY" secondAttribute="bottom" constant="159" id="A1r-Mh-dg7"/>
<constraint firstAttribute="centerX" secondItem="0xb-lk-PHK" secondAttribute="centerX" id="By0-u3-3MA"/> <constraint firstAttribute="centerX" secondItem="0xb-lk-PHK" secondAttribute="centerX" id="By0-u3-3MA"/>
<constraint firstItem="0xb-lk-PHK" firstAttribute="centerX" secondItem="J5M-pv-UHA" secondAttribute="centerX" id="Gab-EA-Il5"/> <constraint firstItem="0xb-lk-PHK" firstAttribute="centerX" secondItem="J5M-pv-UHA" secondAttribute="centerX" id="Gab-EA-Il5"/>
<constraint firstItem="0xb-lk-PHK" firstAttribute="top" secondItem="J5M-pv-UHA" secondAttribute="bottom" constant="25" id="RNw-zD-7u7"/> <constraint firstItem="unc-nO-WPH" firstAttribute="leading" secondItem="J5M-pv-UHA" secondAttribute="leading" id="Qk0-0J-79M"/>
<constraint firstItem="0xb-lk-PHK" firstAttribute="top" secondItem="ATh-Tf-xRL" secondAttribute="bottom" constant="-13" id="TN4-kv-Yli"/> <constraint firstItem="0xb-lk-PHK" firstAttribute="top" secondItem="J5M-pv-UHA" secondAttribute="bottom" constant="8" id="RNw-zD-7u7"/>
<constraint firstItem="0xb-lk-PHK" firstAttribute="top" secondItem="ATh-Tf-xRL" secondAttribute="bottom" constant="-30" id="TN4-kv-Yli"/>
<constraint firstItem="J5M-pv-UHA" firstAttribute="top" secondItem="nFR-to-qQs" secondAttribute="bottom" constant="-5" id="Vcz-ix-cdp"/> <constraint firstItem="J5M-pv-UHA" firstAttribute="top" secondItem="nFR-to-qQs" secondAttribute="bottom" constant="-5" id="Vcz-ix-cdp"/>
<constraint firstItem="nFR-to-qQs" firstAttribute="top" secondItem="0HR-9w-kvY" secondAttribute="bottom" id="XWH-Vw-VfH"/> <constraint firstItem="nFR-to-qQs" firstAttribute="top" secondItem="0HR-9w-kvY" secondAttribute="bottom" id="XWH-Vw-VfH"/>
<constraint firstItem="0xb-lk-PHK" firstAttribute="centerX" secondItem="ATh-Tf-xRL" secondAttribute="centerX" id="bEv-zi-oip"/> <constraint firstItem="0xb-lk-PHK" firstAttribute="centerX" secondItem="ATh-Tf-xRL" secondAttribute="centerX" id="bEv-zi-oip"/>
<constraint firstItem="J5M-pv-UHA" firstAttribute="top" secondItem="unc-nO-WPH" secondAttribute="bottom" constant="22" id="dU2-fJ-SU7"/>
<constraint firstItem="ATh-Tf-xRL" firstAttribute="top" secondItem="J5M-pv-UHA" secondAttribute="bottom" constant="8" id="gNc-KC-Q9G"/> <constraint firstItem="ATh-Tf-xRL" firstAttribute="top" secondItem="J5M-pv-UHA" secondAttribute="bottom" constant="8" id="gNc-KC-Q9G"/>
<constraint firstItem="unc-nO-WPH" firstAttribute="trailing" secondItem="J5M-pv-UHA" secondAttribute="trailing" id="h4a-vk-mBB"/>
<constraint firstAttribute="centerX" secondItem="nFR-to-qQs" secondAttribute="centerX" id="h9S-ek-7bf"/> <constraint firstAttribute="centerX" secondItem="nFR-to-qQs" secondAttribute="centerX" id="h9S-ek-7bf"/>
</constraints> </constraints>
</view> </view>