From 1131c5b2498dd617499a955d6cce8e684f7cc8d5 Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Sun, 17 May 2020 17:59:29 +0800 Subject: [PATCH 1/8] working on adding external screen support --- .../StreamFrameViewController.m | 57 +++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index a85d8ab1..2988e926 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -26,6 +26,10 @@ @implementation StreamFrameViewController { UITextView *_overlayView; StreamView *_streamView; BOOL _userIsInteracting; + UIWindow *_extWindow; + UIView *_renderView; + UIView *_totalView; + UIWindow *_deviceWindow; } - (void)viewDidAppear:(BOOL)animated @@ -61,8 +65,10 @@ - (void)viewDidLoad _controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig presenceDelegate:self]; _inactivityTimer = nil; - + _deviceWindow = self.view.window; _streamView = (StreamView*)self.view; + _renderView = [[UIView alloc] initWithFrame:_deviceWindow.bounds]; + [_streamView addSubview:_renderView]; [_streamView setupStreamView:_controllerSupport swipeDelegate:self interactionDelegate:self config:self.streamConfig]; #if TARGET_OS_TV @@ -89,9 +95,12 @@ - (void)viewDidLoad [self.tipLabel sizeToFit]; self.tipLabel.textAlignment = NSTextAlignmentCenter; self.tipLabel.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height * 0.9); - +// Check if screen is already connected + if (UIScreen.screens.count > 1) { + [self prepExtScreen:UIScreen.screens.lastObject]; + }; _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig - renderView:self.view + renderView:_renderView connectionCallbacks:self]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; [opQueue addOperation:_streamMan]; @@ -110,6 +119,16 @@ - (void)viewDidLoad selector: @selector(applicationDidEnterBackground:) name: UIApplicationDidEnterBackgroundNotification object: nil]; + //check to see if external screen is connected/disconnected + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(extScreenDidConnect:) + name: UIScreenDidConnectNotification + object: nil]; + + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(extScreenDidDisconnect:) + name: UIScreenDidDisconnectNotification + object: nil]; } - (void)willMoveToParentViewController:(UIViewController *)parent { @@ -160,8 +179,36 @@ - (void)updateOverlayText:(NSString*)text { - (void) returnToMainFrame { [self.navigationController popToRootViewControllerAnimated:YES]; + if (_extWindow != nil) { + _extWindow.hidden = YES; + } } +// External Screen connected +- (void)extScreenDidConnect:(NSNotification *)notification { + Log(LOG_I, @"External Screen Connected"); + [self prepExtScreen:notification.object]; +} + +// External Screen disconnected +- (void)extScreenDidDisconnect:(NSNotification *)notification { + Log(LOG_I, @"External Screen Disconnected"); + _extWindow.hidden = YES; + _renderView.frame = _deviceWindow.bounds; + [self.view insertSubview:_renderView atIndex:0]; +} + +// Prepare Screen +- (void)prepExtScreen:(UIScreen*)extScreen { + Log(LOG_I, @"Preparing External Screen"); + CGRect frame = extScreen.bounds; + _extWindow = [[UIWindow alloc] initWithFrame:frame]; + _extWindow.screen = extScreen; + _extWindow.hidden = NO; + _renderView.frame = extScreen.bounds; + [_extWindow addSubview:_renderView]; + +} // This will fire if the user opens control center or gets a low battery message - (void)applicationWillResignActive:(NSNotification *)notification { if (_inactivityTimer != nil) { @@ -221,12 +268,12 @@ - (void)edgeSwiped { - (void) connectionStarted { Log(LOG_I, @"Connection started"); dispatch_async(dispatch_get_main_queue(), ^{ - // Leave the spinner spinning until it's obscured by - // the first frame of video. self.stageLabel.hidden = YES; self.tipLabel.hidden = YES; [self->_streamView showOnScreenControls]; + self.spinner.hidden = YES; + }); } From 22eaa65193f942b1bf655120981dad730e6b4546 Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Tue, 19 May 2020 11:09:41 +0800 Subject: [PATCH 2/8] adding some debug messages --- Limelight/Stream/VideoDecoderRenderer.m | 4 +- .../StreamFrameViewController.m | 80 ++++++++++++------- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index 8dcddabf..fa7c5050 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -12,7 +12,7 @@ #include "Limelight.h" @implementation VideoDecoderRenderer { - StreamView* _view; + OSView* _view; AVSampleBufferDisplayLayer* displayLayer; Boolean waitingForSps, waitingForPps, waitingForVps; @@ -61,7 +61,7 @@ - (void)reinitializeDisplayLayer } } -- (id)initWithView:(StreamView*)view +- (id)initWithView:(UIView*)view { self = [super init]; diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 2988e926..2b11e014 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -36,6 +36,31 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + _deviceWindow = self.view.window; + [_deviceWindow insertSubview:_renderView aboveSubview:(self.view)]; + if (UIScreen.screens.count > 1) { + [self prepExtScreen:UIScreen.screens.lastObject]; + } + _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig + renderView:_renderView + connectionCallbacks:self]; + NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; + [opQueue addOperation:_streamMan]; + // check to see if external screen is connected/disconnected + + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(extScreenDidConnect:) + name: UIScreenDidConnectNotification + object: nil]; + + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(extScreenDidDisconnect:) + name: UIScreenDidDisconnectNotification + object: nil]; + + + + #if !TARGET_OS_TV [[self revealViewController] setPrimaryViewController:self]; #endif @@ -65,10 +90,9 @@ - (void)viewDidLoad _controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig presenceDelegate:self]; _inactivityTimer = nil; - _deviceWindow = self.view.window; + _renderView = [[UIView alloc] initWithFrame:self.view.bounds]; + _renderView.bounds = _renderView.frame; _streamView = (StreamView*)self.view; - _renderView = [[UIView alloc] initWithFrame:_deviceWindow.bounds]; - [_streamView addSubview:_renderView]; [_streamView setupStreamView:_controllerSupport swipeDelegate:self interactionDelegate:self config:self.streamConfig]; #if TARGET_OS_TV @@ -95,15 +119,6 @@ - (void)viewDidLoad [self.tipLabel sizeToFit]; self.tipLabel.textAlignment = NSTextAlignmentCenter; self.tipLabel.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height * 0.9); -// Check if screen is already connected - if (UIScreen.screens.count > 1) { - [self prepExtScreen:UIScreen.screens.lastObject]; - }; - _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig - renderView:_renderView - connectionCallbacks:self]; - NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; - [opQueue addOperation:_streamMan]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) @@ -119,16 +134,6 @@ - (void)viewDidLoad selector: @selector(applicationDidEnterBackground:) name: UIApplicationDidEnterBackgroundNotification object: nil]; - //check to see if external screen is connected/disconnected - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(extScreenDidConnect:) - name: UIScreenDidConnectNotification - object: nil]; - - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(extScreenDidDisconnect:) - name: UIScreenDidDisconnectNotification - object: nil]; } - (void)willMoveToParentViewController:(UIViewController *)parent { @@ -179,9 +184,7 @@ - (void)updateOverlayText:(NSString*)text { - (void) returnToMainFrame { [self.navigationController popToRootViewControllerAnimated:YES]; - if (_extWindow != nil) { - _extWindow.hidden = YES; - } + _extWindow = nil; } // External Screen connected @@ -193,9 +196,10 @@ - (void)extScreenDidConnect:(NSNotification *)notification { // External Screen disconnected - (void)extScreenDidDisconnect:(NSNotification *)notification { Log(LOG_I, @"External Screen Disconnected"); - _extWindow.hidden = YES; - _renderView.frame = _deviceWindow.bounds; - [self.view insertSubview:_renderView atIndex:0]; + if(UIScreen.screens.count < 2) + { + [self removeExtScreen]; + } } // Prepare Screen @@ -204,11 +208,25 @@ - (void)prepExtScreen:(UIScreen*)extScreen { CGRect frame = extScreen.bounds; _extWindow = [[UIWindow alloc] initWithFrame:frame]; _extWindow.screen = extScreen; - _extWindow.hidden = NO; - _renderView.frame = extScreen.bounds; [_extWindow addSubview:_renderView]; - + _renderView.bounds = extScreen.bounds; + Log(LOG_I, @"Changing bounds to H:%f,W:%f", _renderView.bounds.size.height, _renderView.bounds.size.width); + Log(LOG_I, @"Checking layer bounds: H:%f,W:%f", _renderView.layer.bounds.size.height, _renderView.layer.bounds.size.width); + Log(LOG_I, @"Checking layer frame: to H:%f,W:%f", _renderView.layer.frame.size.height, _renderView.layer.frame.size.width); + _extWindow.hidden = NO; } + +- (void)removeExtScreen { + Log(LOG_I, @"Removing External Screen"); + _extWindow.hidden = YES; + _renderView.bounds = _deviceWindow.bounds; + Log(LOG_I, @"Changing bounds to H:%f,W:%f", _renderView.bounds.size.height, _renderView.bounds.size.width); + Log(LOG_I, @"Checking layer bounds: H:%f,W:%f", _renderView.layer.bounds.size.height, _renderView.layer.bounds.size.width); + Log(LOG_I, @"Checking layer frame: to H:%f,W:%f", _renderView.layer.frame.size.height, _renderView.layer.frame.size.width); + [_renderView removeFromSuperview]; + [self.view insertSubview:_renderView atIndex:0]; +} + // This will fire if the user opens control center or gets a low battery message - (void)applicationWillResignActive:(NSNotification *)notification { if (_inactivityTimer != nil) { From 5af7d29d26833861521ac2e9232c9804628ce66e Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Tue, 19 May 2020 11:11:16 +0800 Subject: [PATCH 3/8] adding debug messages and tidy external screen code --- Limelight/Stream/VideoDecoderRenderer.m | 2 +- Limelight/ViewControllers/StreamFrameViewController.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index fa7c5050..f83db749 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -31,7 +31,7 @@ - (void)reinitializeDisplayLayer displayLayer = [[AVSampleBufferDisplayLayer alloc] init]; displayLayer.bounds = _view.bounds; displayLayer.backgroundColor = [OSColor blackColor].CGColor; - + Log(LOG_I, @"displayLayer bounds: %f x %f", displayLayer.bounds.size.height, displayLayer.bounds.size.width); displayLayer.position = CGPointMake(CGRectGetMidX(_view.bounds), CGRectGetMidY(_view.bounds)); displayLayer.videoGravity = AVLayerVideoGravityResizeAspect; diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 2b11e014..a9194596 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -30,6 +30,7 @@ @implementation StreamFrameViewController { UIView *_renderView; UIView *_totalView; UIWindow *_deviceWindow; + VideoDecoderRenderer *_video; } - (void)viewDidAppear:(BOOL)animated From d341c10b17eed5d046fc3113bfb819292909ee4b Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Wed, 20 May 2020 09:28:23 +0800 Subject: [PATCH 4/8] fixed audio stuttering and added --- .../StreamFrameViewController.m | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index a9194596..d5823393 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -28,7 +28,6 @@ @implementation StreamFrameViewController { BOOL _userIsInteracting; UIWindow *_extWindow; UIView *_renderView; - UIView *_totalView; UIWindow *_deviceWindow; VideoDecoderRenderer *_video; } @@ -38,15 +37,16 @@ - (void)viewDidAppear:(BOOL)animated [super viewDidAppear:animated]; _deviceWindow = self.view.window; - [_deviceWindow insertSubview:_renderView aboveSubview:(self.view)]; + if (UIScreen.screens.count > 1) { [self prepExtScreen:UIScreen.screens.lastObject]; } - _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig - renderView:_renderView - connectionCallbacks:self]; - NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; - [opQueue addOperation:_streamMan]; + else { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.view insertSubview:self->_renderView atIndex:0]; + }); + } + // check to see if external screen is connected/disconnected [[NSNotificationCenter defaultCenter] addObserver: self @@ -91,9 +91,9 @@ - (void)viewDidLoad _controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig presenceDelegate:self]; _inactivityTimer = nil; - _renderView = [[UIView alloc] initWithFrame:self.view.bounds]; - _renderView.bounds = _renderView.frame; + _renderView = (StreamView*)[[UIView alloc] initWithFrame:self.view.frame]; _streamView = (StreamView*)self.view; + _renderView.bounds = _streamView.bounds; [_streamView setupStreamView:_controllerSupport swipeDelegate:self interactionDelegate:self config:self.streamConfig]; #if TARGET_OS_TV @@ -121,6 +121,11 @@ - (void)viewDidLoad self.tipLabel.textAlignment = NSTextAlignmentCenter; self.tipLabel.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height * 0.9); + _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig + renderView:_renderView + connectionCallbacks:self]; + NSOperationQueue* opQueue = [[NSOperationQueue alloc] init]; + [opQueue addOperation:_streamMan]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification @@ -205,27 +210,30 @@ - (void)extScreenDidDisconnect:(NSNotification *)notification { // Prepare Screen - (void)prepExtScreen:(UIScreen*)extScreen { + dispatch_async(dispatch_get_main_queue(), ^{ Log(LOG_I, @"Preparing External Screen"); CGRect frame = extScreen.bounds; - _extWindow = [[UIWindow alloc] initWithFrame:frame]; - _extWindow.screen = extScreen; - [_extWindow addSubview:_renderView]; - _renderView.bounds = extScreen.bounds; - Log(LOG_I, @"Changing bounds to H:%f,W:%f", _renderView.bounds.size.height, _renderView.bounds.size.width); - Log(LOG_I, @"Checking layer bounds: H:%f,W:%f", _renderView.layer.bounds.size.height, _renderView.layer.bounds.size.width); - Log(LOG_I, @"Checking layer frame: to H:%f,W:%f", _renderView.layer.frame.size.height, _renderView.layer.frame.size.width); - _extWindow.hidden = NO; + self->_extWindow = [[UIWindow alloc] initWithFrame:frame]; + self->_extWindow.screen = extScreen; + self->_renderView.bounds = frame; + self->_renderView.frame = frame; + [self->_extWindow addSubview:self->_renderView]; + Log(LOG_I, @"Changing bounds to H:%f,W:%f", self->_renderView.bounds.size.height, self->_renderView.bounds.size.width); + Log(LOG_I, @"Checking frame H:%f,W:%f (%f,%f)", self->_renderView.frame.size.height, self->_renderView.bounds.size.width, self->_renderView.frame.origin.x,self->_renderView.frame.origin.y); + self->_extWindow.hidden = NO; + }); } - (void)removeExtScreen { + dispatch_async(dispatch_get_main_queue(), ^{ Log(LOG_I, @"Removing External Screen"); - _extWindow.hidden = YES; - _renderView.bounds = _deviceWindow.bounds; - Log(LOG_I, @"Changing bounds to H:%f,W:%f", _renderView.bounds.size.height, _renderView.bounds.size.width); - Log(LOG_I, @"Checking layer bounds: H:%f,W:%f", _renderView.layer.bounds.size.height, _renderView.layer.bounds.size.width); - Log(LOG_I, @"Checking layer frame: to H:%f,W:%f", _renderView.layer.frame.size.height, _renderView.layer.frame.size.width); - [_renderView removeFromSuperview]; - [self.view insertSubview:_renderView atIndex:0]; + self->_extWindow.hidden = YES; + self->_renderView.bounds = self->_deviceWindow.bounds; + self->_renderView.frame = self->_deviceWindow.frame; + Log(LOG_I, @"Changing bounds to H:%f,W:%f", self->_renderView.bounds.size.height, self->_renderView.bounds.size.width); + Log(LOG_I, @"Checking frame H:%f,W:%f (%f,%f)", self->_renderView.frame.size.height, self->_renderView.bounds.size.width, self->_renderView.frame.origin.x,self->_renderView.frame.origin.y); + [self.view insertSubview:self->_renderView atIndex:0]; + }); } // This will fire if the user opens control center or gets a low battery message From 1c75b7055ae64f6bba292a82d2db85a1260db745 Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Wed, 20 May 2020 14:33:25 +0800 Subject: [PATCH 5/8] fixed external resizing on screen change and removed debuging log writes --- Limelight/Stream/StreamManager.h | 1 + Limelight/Stream/VideoDecoderRenderer.m | 12 ++++-- .../StreamFrameViewController.m | 40 +++++++++---------- Moonlight.xcodeproj/project.pbxproj | 4 +- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Limelight/Stream/StreamManager.h b/Limelight/Stream/StreamManager.h index 44954564..7583d8a4 100644 --- a/Limelight/Stream/StreamManager.h +++ b/Limelight/Stream/StreamManager.h @@ -15,4 +15,5 @@ - (void) stopStream; + @end diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index f83db749..ae1d7432 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -23,7 +23,7 @@ @implementation VideoDecoderRenderer { CADisplayLink* _displayLink; } - + - (void)reinitializeDisplayLayer { CALayer *oldLayer = displayLayer; @@ -31,7 +31,6 @@ - (void)reinitializeDisplayLayer displayLayer = [[AVSampleBufferDisplayLayer alloc] init]; displayLayer.bounds = _view.bounds; displayLayer.backgroundColor = [OSColor blackColor].CGColor; - Log(LOG_I, @"displayLayer bounds: %f x %f", displayLayer.bounds.size.height, displayLayer.bounds.size.width); displayLayer.position = CGPointMake(CGRectGetMidX(_view.bounds), CGRectGetMidY(_view.bounds)); displayLayer.videoGravity = AVLayerVideoGravityResizeAspect; @@ -68,7 +67,14 @@ - (id)initWithView:(UIView*)view _view = view; [self reinitializeDisplayLayer]; - + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(reinitializeDisplayLayer) + name:@"ScreenConnected" + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(reinitializeDisplayLayer) + name:@"ScreenDisconnected" + object:nil]; return self; } diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index d5823393..b25bca18 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -29,7 +29,6 @@ @implementation StreamFrameViewController { UIWindow *_extWindow; UIView *_renderView; UIWindow *_deviceWindow; - VideoDecoderRenderer *_video; } - (void)viewDidAppear:(BOOL)animated @@ -196,7 +195,9 @@ - (void) returnToMainFrame { // External Screen connected - (void)extScreenDidConnect:(NSNotification *)notification { Log(LOG_I, @"External Screen Connected"); + dispatch_async(dispatch_get_main_queue(), ^{ [self prepExtScreen:notification.object]; + }); } // External Screen disconnected @@ -204,36 +205,35 @@ - (void)extScreenDidDisconnect:(NSNotification *)notification { Log(LOG_I, @"External Screen Disconnected"); if(UIScreen.screens.count < 2) { + dispatch_async(dispatch_get_main_queue(), ^{ [self removeExtScreen]; + }); } } // Prepare Screen - (void)prepExtScreen:(UIScreen*)extScreen { - dispatch_async(dispatch_get_main_queue(), ^{ Log(LOG_I, @"Preparing External Screen"); CGRect frame = extScreen.bounds; - self->_extWindow = [[UIWindow alloc] initWithFrame:frame]; - self->_extWindow.screen = extScreen; - self->_renderView.bounds = frame; - self->_renderView.frame = frame; - [self->_extWindow addSubview:self->_renderView]; - Log(LOG_I, @"Changing bounds to H:%f,W:%f", self->_renderView.bounds.size.height, self->_renderView.bounds.size.width); - Log(LOG_I, @"Checking frame H:%f,W:%f (%f,%f)", self->_renderView.frame.size.height, self->_renderView.bounds.size.width, self->_renderView.frame.origin.x,self->_renderView.frame.origin.y); - self->_extWindow.hidden = NO; - }); + extScreen.overscanCompensation = 3; + _extWindow = [[UIWindow alloc] initWithFrame:frame]; + _extWindow.screen = extScreen; + _renderView.bounds = frame; + _renderView.frame = frame; + NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; + [nc postNotificationName:@"ScreenConnected" object:self]; + [_extWindow addSubview:_renderView]; + _extWindow.hidden = NO; } - (void)removeExtScreen { - dispatch_async(dispatch_get_main_queue(), ^{ Log(LOG_I, @"Removing External Screen"); - self->_extWindow.hidden = YES; - self->_renderView.bounds = self->_deviceWindow.bounds; - self->_renderView.frame = self->_deviceWindow.frame; - Log(LOG_I, @"Changing bounds to H:%f,W:%f", self->_renderView.bounds.size.height, self->_renderView.bounds.size.width); - Log(LOG_I, @"Checking frame H:%f,W:%f (%f,%f)", self->_renderView.frame.size.height, self->_renderView.bounds.size.width, self->_renderView.frame.origin.x,self->_renderView.frame.origin.y); - [self.view insertSubview:self->_renderView atIndex:0]; - }); + _extWindow.hidden = YES; + _renderView.bounds = _deviceWindow.bounds; + _renderView.frame = _deviceWindow.frame; + NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; + [nc postNotificationName:@"ScreenDisconnected" object:self]; + [self.view insertSubview:_renderView atIndex:0]; } // This will fire if the user opens control center or gets a low battery message @@ -344,8 +344,8 @@ - (void)connectionTerminated:(int)errorCode { } - (void) stageStarting:(const char*)stageName { - Log(LOG_I, @"Starting %s", stageName); dispatch_async(dispatch_get_main_queue(), ^{ + Log(LOG_I, @"Starting %s", stageName); NSString* lowerCase = [NSString stringWithFormat:@"%s in progress...", stageName]; NSString* titleCase = [[[lowerCase substringToIndex:1] uppercaseString] stringByAppendingString:[lowerCase substringFromIndex:1]]; [self.stageLabel setText:titleCase]; diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 3fb9fedb..43523f97 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -867,7 +867,6 @@ }; }; FB290CED19B2C406004C83CF = { - DevelopmentTeam = DM46QST4M7; LastSwiftMigration = 1140; }; }; @@ -1278,6 +1277,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 2; + DEVELOPMENT_TEAM = 38F466R9F7; ENABLE_BITCODE = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Limelight/Limelight-Prefix.pch"; @@ -1296,7 +1296,7 @@ "$(PROJECT_DIR)/libs/openssl/lib/iOS", ); MARKETING_VERSION = 5.0.2; - PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlightmatt"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SKIP_INSTALL = NO; From 3d3897335c24a76fc322ae869c2f3e15dedab12e Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Wed, 20 May 2020 14:42:05 +0800 Subject: [PATCH 6/8] remove line additions --- Limelight/Stream/StreamManager.h | 1 - Limelight/Stream/VideoDecoderRenderer.m | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Limelight/Stream/StreamManager.h b/Limelight/Stream/StreamManager.h index 7583d8a4..44954564 100644 --- a/Limelight/Stream/StreamManager.h +++ b/Limelight/Stream/StreamManager.h @@ -15,5 +15,4 @@ - (void) stopStream; - @end diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index ae1d7432..5e7b02cf 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -22,8 +22,7 @@ @implementation VideoDecoderRenderer { CMVideoFormatDescriptionRef formatDesc; CADisplayLink* _displayLink; -} - +} - (void)reinitializeDisplayLayer { CALayer *oldLayer = displayLayer; From 36a53f9efe2af5ad29f175bcd34719a90c8cb3ca Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Wed, 20 May 2020 14:52:46 +0800 Subject: [PATCH 7/8] tidy --- Moonlight.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 43523f97..3fb9fedb 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -867,6 +867,7 @@ }; }; FB290CED19B2C406004C83CF = { + DevelopmentTeam = DM46QST4M7; LastSwiftMigration = 1140; }; }; @@ -1277,7 +1278,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = 38F466R9F7; ENABLE_BITCODE = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Limelight/Limelight-Prefix.pch"; @@ -1296,7 +1296,7 @@ "$(PROJECT_DIR)/libs/openssl/lib/iOS", ); MARKETING_VERSION = 5.0.2; - PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlightmatt"; + PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SKIP_INSTALL = NO; From fa0b82100d79829e20ecf63cfaff9b38cd7e5fe9 Mon Sep 17 00:00:00 2001 From: Matt Russell <_matt@live.com.au> Date: Wed, 20 May 2020 15:15:19 +0800 Subject: [PATCH 8/8] tidy --- Limelight/Stream/VideoDecoderRenderer.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index 5e7b02cf..c6992be4 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -12,7 +12,7 @@ #include "Limelight.h" @implementation VideoDecoderRenderer { - OSView* _view; + StreamView* _view; AVSampleBufferDisplayLayer* displayLayer; Boolean waitingForSps, waitingForPps, waitingForVps; @@ -59,7 +59,7 @@ - (void)reinitializeDisplayLayer } } -- (id)initWithView:(UIView*)view +- (id)initWithView:(StreamView*)view { self = [super init];