mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-02-16 10:31:02 +00:00
joining stream works
This commit is contained in:
@@ -14,5 +14,6 @@
|
||||
@property BOOL paired;
|
||||
|
||||
- (id) initWithHost:(NSNetService*)host;
|
||||
- (int) resolveHost;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#import "Computer.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
@implementation Computer
|
||||
|
||||
- (id) initWithHost:(NSNetService *)host {
|
||||
@@ -19,4 +23,29 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int) resolveHost
|
||||
{
|
||||
struct hostent *hostent;
|
||||
|
||||
if (inet_addr([self.hostName UTF8String]) != INADDR_NONE)
|
||||
{
|
||||
// Already an IP address
|
||||
return inet_addr([self.hostName UTF8String]);
|
||||
}
|
||||
else
|
||||
{
|
||||
hostent = gethostbyname([self.hostName UTF8String]);
|
||||
if (hostent != NULL)
|
||||
{
|
||||
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
|
||||
NSLog(@"Resolved %@ -> %s", self.hostName, ipstr);
|
||||
return inet_addr(ipstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to resolve host: %d", h_errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
- (id) initWithCallback:(id<MDNSCallback>) callback;
|
||||
- (void) searchForHosts;
|
||||
- (NSArray*) getFoundHosts;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
@property (strong, nonatomic) NSArray* streamConfigVals;
|
||||
@property (strong, nonatomic) NSArray* hostPickerVals;
|
||||
|
||||
+ (const char*)getHostAddr;
|
||||
- (int) getHostAddr;
|
||||
- (void) segueIntoStream;
|
||||
|
||||
@end
|
||||
|
||||
@@ -12,14 +12,17 @@
|
||||
#import "CryptoManager.h"
|
||||
#import "HttpManager.h"
|
||||
#import "PairManager.h"
|
||||
#import "Connection.h"
|
||||
#import "VideoDecoderRenderer.h"
|
||||
|
||||
@implementation MainFrameViewController
|
||||
NSString* hostAddr;
|
||||
MDNSManager* mDNSManager;
|
||||
@implementation MainFrameViewController {
|
||||
NSOperationQueue* _opQueue;
|
||||
MDNSManager* _mDNSManager;
|
||||
Computer* _selectedHost;
|
||||
}
|
||||
|
||||
+ (const char*)getHostAddr
|
||||
{
|
||||
return [hostAddr UTF8String];
|
||||
- (int)getHostAddr {
|
||||
return [_selectedHost resolveHost];
|
||||
}
|
||||
|
||||
- (void)PairButton:(UIButton *)sender
|
||||
@@ -29,17 +32,16 @@ MDNSManager* mDNSManager;
|
||||
NSString* uniqueId = [CryptoManager getUniqueID];
|
||||
NSData* cert = [CryptoManager readCertFromFile];
|
||||
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:hostAddr uniqueId:uniqueId deviceName:@"roth" cert:cert];
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.hostName uniqueId:uniqueId deviceName:@"roth" cert:cert];
|
||||
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:cert];
|
||||
|
||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||
[opQueue addOperation:pMan];
|
||||
|
||||
[_opQueue addOperation:pMan];
|
||||
}
|
||||
|
||||
- (void)StreamButton:(UIButton *)sender
|
||||
{
|
||||
NSLog(@"Stream Button Pressed!");
|
||||
[ConnectionHandler streamWithHost:hostAddr viewController:self];
|
||||
[self segueIntoStream];
|
||||
}
|
||||
|
||||
- (void) segueIntoStream {
|
||||
@@ -59,11 +61,8 @@ MDNSManager* mDNSManager;
|
||||
|
||||
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
|
||||
{
|
||||
self.hostPickerVals = [mDNSManager getFoundHosts];
|
||||
|
||||
[self.HostPicker reloadAllComponents];
|
||||
if (pickerView == self.HostPicker) {
|
||||
hostAddr = ((Computer*)([self.hostPickerVals objectAtIndex:[self.HostPicker selectedRowInComponent:0]])).hostName;
|
||||
_selectedHost = (Computer*)([self.hostPickerVals objectAtIndex:[self.HostPicker selectedRowInComponent:0]]);
|
||||
}
|
||||
|
||||
//TODO: figure out how to save this info!!
|
||||
@@ -95,13 +94,15 @@ MDNSManager* mDNSManager;
|
||||
self.hostPickerVals = [[NSArray alloc] init];
|
||||
|
||||
|
||||
mDNSManager = [[MDNSManager alloc] initWithCallback:self];
|
||||
[mDNSManager searchForHosts];
|
||||
_mDNSManager = [[MDNSManager alloc] initWithCallback:self];
|
||||
[_mDNSManager searchForHosts];
|
||||
_opQueue = [[NSOperationQueue alloc] init];
|
||||
}
|
||||
|
||||
- (void)updateHosts:(NSArray *)hosts {
|
||||
self.hostPickerVals = hosts;
|
||||
[self.HostPicker reloadAllComponents];
|
||||
_selectedHost = (Computer*)([self.hostPickerVals objectAtIndex:[self.HostPicker selectedRowInComponent:0]]);
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
||||
@@ -20,7 +20,13 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation StreamFrameViewController
|
||||
@implementation StreamFrameViewController {
|
||||
int _host;
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
_host = [sender getHostAddr];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
@@ -30,7 +36,7 @@
|
||||
|
||||
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:self.view];
|
||||
|
||||
Connection* conn = [[Connection alloc] initWithHost:inet_addr([[ConnectionHandler resolveHost:[NSString stringWithUTF8String:[MainFrameViewController getHostAddr]]] UTF8String]) width:1280 height:720
|
||||
Connection* conn = [[Connection alloc] initWithHost:_host width:1280 height:720
|
||||
renderer: renderer];
|
||||
|
||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||
|
||||
Reference in New Issue
Block a user