mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-15 21:21:45 +00:00
Merge branch 'master' of github.com:limelight-stream/limelight-ios
Conflicts: Limelight/StreamFrameViewController.m
This commit is contained in:
@@ -14,5 +14,6 @@
|
||||
@property BOOL paired;
|
||||
|
||||
- (id) initWithHost:(NSNetService*)host;
|
||||
- (id) initWithIp:(NSString*)host;
|
||||
|
||||
@end
|
||||
|
||||
@@ -19,4 +19,13 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithIp:(NSString*)host {
|
||||
self = [super init];
|
||||
|
||||
self.hostName = host;
|
||||
self.displayName = host;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "MDNSManager.h"
|
||||
#import "PairManager.h"
|
||||
#import "StreamConfiguration.h"
|
||||
|
||||
@interface MainFrameViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate, MDNSCallback, NSURLConnectionDelegate, PairCallback>
|
||||
@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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "StreamConfiguration.h"
|
||||
|
||||
@interface StreamManager : NSOperation
|
||||
|
||||
- (id) initWithHost:(NSString*)host renderView:(UIView*)view;
|
||||
- (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view;
|
||||
|
||||
@end
|
||||
|
||||
+10
-15
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user