mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-02-16 10:31:02 +00:00
Merge branch 'master' of github.com:moonlight-stream/moonlight-ios
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
|
||||
@interface Connection : NSOperation <NSStreamDelegate>
|
||||
|
||||
-(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer connectionCallbacks:(id<ConnectionCallbacks>)callbacks serverMajorVersion:(int)serverMajorVersion;
|
||||
-(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer connectionCallbacks:(id<ConnectionCallbacks>)callbacks;
|
||||
-(void) terminate;
|
||||
-(void) main;
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
#include "opus.h"
|
||||
|
||||
@implementation Connection {
|
||||
const char* _host;
|
||||
SERVER_INFORMATION _serverInfo;
|
||||
STREAM_CONFIGURATION _streamConfig;
|
||||
CONNECTION_LISTENER_CALLBACKS _clCallbacks;
|
||||
DECODER_RENDERER_CALLBACKS _drCallbacks;
|
||||
AUDIO_RENDERER_CALLBACKS _arCallbacks;
|
||||
int _serverMajorVersion;
|
||||
}
|
||||
|
||||
static NSLock* initLock;
|
||||
@@ -274,7 +273,7 @@ void ClDisplayTransientMessage(const char* message)
|
||||
});
|
||||
}
|
||||
|
||||
-(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer connectionCallbacks:(id<ConnectionCallbacks>)callbacks serverMajorVersion:(int)serverMajorVersion
|
||||
-(id) initWithConfig:(StreamConfiguration*)config renderer:(VideoDecoderRenderer*)myRenderer connectionCallbacks:(id<ConnectionCallbacks>)callbacks
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@@ -284,10 +283,15 @@ void ClDisplayTransientMessage(const char* message)
|
||||
initLock = [[NSLock alloc] init];
|
||||
}
|
||||
|
||||
_host = [config.host cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
LiInitializeServerInformation(&_serverInfo);
|
||||
_serverInfo.address = [config.host cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
_serverInfo.serverInfoAppVersion = [config.appVersion cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
if (config.gfeVersion != nil) {
|
||||
_serverInfo.serverInfoGfeVersion = [config.gfeVersion cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
renderer = myRenderer;
|
||||
_callbacks = callbacks;
|
||||
_serverMajorVersion = serverMajorVersion;
|
||||
|
||||
LiInitializeStreamConfiguration(&_streamConfig);
|
||||
_streamConfig.width = config.width;
|
||||
@@ -407,12 +411,12 @@ static OSStatus playbackCallback(void *inRefCon,
|
||||
-(void) main
|
||||
{
|
||||
[initLock lock];
|
||||
LiStartConnection(_host,
|
||||
LiStartConnection(&_serverInfo,
|
||||
&_streamConfig,
|
||||
&_clCallbacks,
|
||||
&_drCallbacks,
|
||||
&_arCallbacks,
|
||||
NULL, 0, _serverMajorVersion);
|
||||
NULL, 0);
|
||||
[initLock unlock];
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
@interface StreamConfiguration : NSObject
|
||||
|
||||
@property NSString* host;
|
||||
@property NSString* appVersion;
|
||||
@property NSString* gfeVersion;
|
||||
@property NSString* appID;
|
||||
@property int width;
|
||||
@property int height;
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]];
|
||||
NSString* pairStatus = [serverInfoResp getStringTag:@"PairStatus"];
|
||||
NSString* appversion = [serverInfoResp getStringTag:@"appversion"];
|
||||
NSString* gfeVersion = [serverInfoResp getStringTag:@"GfeVersion"];
|
||||
NSString* serverState = [serverInfoResp getStringTag:@"state"];
|
||||
if (![serverInfoResp isStatusOk] || pairStatus == NULL || appversion == NULL || serverState == NULL) {
|
||||
[_callbacks launchFailed:@"Failed to connect to PC"];
|
||||
@@ -82,11 +83,12 @@
|
||||
[((StreamView*)_renderView) setMouseDeltaFactors:_config.width / screenSize.width
|
||||
y:_config.height / screenSize.height];
|
||||
|
||||
int majorVersion = [[appversion substringToIndex:1] intValue];
|
||||
Log(LOG_I, @"Server is generation %d", majorVersion);
|
||||
// Populate the config's version fields from serverinfo
|
||||
_config.appVersion = appversion;
|
||||
_config.gfeVersion = gfeVersion;
|
||||
|
||||
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks serverMajorVersion:majorVersion];
|
||||
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks];
|
||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||
[opQueue addOperation:_connection];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user