From 7ed6b22cac127c6b7085c08783f065904a06f380 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 2 Jul 2021 17:31:45 -0500 Subject: [PATCH] Pass RTSP session URL to moonlight-common-c for dynamic ports --- Limelight/Stream/Connection.m | 9 +++++++++ Limelight/Stream/StreamConfiguration.h | 1 + Limelight/Stream/StreamConfiguration.m | 2 +- Limelight/Stream/StreamManager.m | 14 ++++++++++---- moonlight-common/moonlight-common-c | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Limelight/Stream/Connection.m b/Limelight/Stream/Connection.m index 59e8a8b..a418165 100644 --- a/Limelight/Stream/Connection.m +++ b/Limelight/Stream/Connection.m @@ -25,6 +25,7 @@ char _hostString[256]; char _appVersionString[32]; char _gfeVersionString[32]; + char _rtspSessionUrl[128]; } static NSLock* initLock; @@ -408,6 +409,11 @@ void ClConnectionStatusUpdate(int status) [config.gfeVersion cStringUsingEncoding:NSUTF8StringEncoding], sizeof(_gfeVersionString)); } + if (config.rtspSessionUrl != nil) { + strncpy(_rtspSessionUrl, + [config.rtspSessionUrl cStringUsingEncoding:NSUTF8StringEncoding], + sizeof(_rtspSessionUrl)); + } LiInitializeServerInformation(&_serverInfo); _serverInfo.address = _hostString; @@ -415,6 +421,9 @@ void ClConnectionStatusUpdate(int status) if (config.gfeVersion != nil) { _serverInfo.serverInfoGfeVersion = _gfeVersionString; } + if (config.rtspSessionUrl != nil) { + _serverInfo.rtspSessionUrl = _rtspSessionUrl; + } renderer = myRenderer; _callbacks = callbacks; diff --git a/Limelight/Stream/StreamConfiguration.h b/Limelight/Stream/StreamConfiguration.h index cff6648..1113a97 100644 --- a/Limelight/Stream/StreamConfiguration.h +++ b/Limelight/Stream/StreamConfiguration.h @@ -13,6 +13,7 @@ @property NSString* gfeVersion; @property NSString* appID; @property NSString* appName; +@property NSString* rtspSessionUrl; @property int width; @property int height; @property int frameRate; diff --git a/Limelight/Stream/StreamConfiguration.m b/Limelight/Stream/StreamConfiguration.m index 3eefdd4..fe7e0e4 100644 --- a/Limelight/Stream/StreamConfiguration.m +++ b/Limelight/Stream/StreamConfiguration.m @@ -9,5 +9,5 @@ #import "StreamConfiguration.h" @implementation StreamConfiguration -@synthesize host, appID, width, height, frameRate, bitRate, riKeyId, riKey, gamepadMask, appName, optimizeGameSettings, playAudioOnPC, audioConfiguration, enableHdr, multiController, allowHevc, serverCert; +@synthesize host, appID, width, height, frameRate, bitRate, riKeyId, riKey, gamepadMask, appName, optimizeGameSettings, playAudioOnPC, audioConfiguration, enableHdr, multiController, allowHevc, serverCert, rtspSessionUrl; @end diff --git a/Limelight/Stream/StreamManager.m b/Limelight/Stream/StreamManager.m index fe232cc..6437862 100644 --- a/Limelight/Stream/StreamManager.m +++ b/Limelight/Stream/StreamManager.m @@ -78,18 +78,22 @@ } // resumeApp and launchApp handle calling launchFailed + NSString* sessionUrl; if ([serverState hasSuffix:@"_SERVER_BUSY"]) { // App already running, resume it - if (![self resumeApp:hMan]) { + if (![self resumeApp:hMan receiveSessionUrl:&sessionUrl]) { return; } } else { // Start app - if (![self launchApp:hMan]) { + if (![self launchApp:hMan receiveSessionUrl:&sessionUrl]) { return; } } + // Populate RTSP session URL from launch/resume response + _config.rtspSessionUrl = sessionUrl; + // Populate the config's version fields from serverinfo _config.appVersion = appversion; _config.gfeVersion = gfeVersion; @@ -108,7 +112,7 @@ [_connection terminate]; } -- (BOOL) launchApp:(HttpManager*)hMan { +- (BOOL) launchApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl { HttpResponse* launchResp = [[HttpResponse alloc] init]; [hMan executeRequestSynchronously:[HttpRequest requestForResponse:launchResp withUrlRequest:[hMan newLaunchRequest:_config]]]; NSString *gameSession = [launchResp getStringTag:@"gamesession"]; @@ -122,10 +126,11 @@ return FALSE; } + *sessionUrl = [launchResp getStringTag:@"sessionUrl0"]; return TRUE; } -- (BOOL) resumeApp:(HttpManager*)hMan { +- (BOOL) resumeApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl { HttpResponse* resumeResp = [[HttpResponse alloc] init]; [hMan executeRequestSynchronously:[HttpRequest requestForResponse:resumeResp withUrlRequest:[hMan newResumeRequest:_config]]]; NSString* resume = [resumeResp getStringTag:@"resume"]; @@ -139,6 +144,7 @@ return FALSE; } + *sessionUrl = [resumeResp getStringTag:@"sessionUrl0"]; return TRUE; } diff --git a/moonlight-common/moonlight-common-c b/moonlight-common/moonlight-common-c index 7c346c3..3b9d8a3 160000 --- a/moonlight-common/moonlight-common-c +++ b/moonlight-common/moonlight-common-c @@ -1 +1 @@ -Subproject commit 7c346c31040c6ed736d9d4b3a7cbc4b0aca1849c +Subproject commit 3b9d8a31763be77c921bd2581b5e75f4d40a1b11