get stream real time setting menu working

This commit is contained in:
True Zhuanjia
2024-07-08 23:59:42 +08:00
parent 6f1773d512
commit 38343c20cb
5 changed files with 87 additions and 47 deletions
+3
View File
@@ -28,7 +28,10 @@
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
config:(StreamConfiguration*)streamConfig;
- (void) showOnScreenControls;
- (void) setOnScreenControls;
- (void) disableOnScreenControls;
- (void) reloadOnScreenControlsRealtimeWith:(ControllerSupport*)controllerSupport
andConfig:(StreamConfiguration*)streamConfig;
- (void) reloadOnScreenControlsWith:(ControllerSupport*)controllerSupport
andConfig:(StreamConfiguration*)streamConfig;
- (CGSize) getVideoAreaSize;
+16 -1
View File
@@ -271,16 +271,31 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[onScreenControls show];
#endif
}
- (void) setOnScreenControls{
}
- (void) disableOnScreenControls {
#if !TARGET_OS_TV
[onScreenControls setLevel:OnScreenControlsLevelOff];
#endif
}
- (void) reloadOnScreenControlsRealtimeWith:(ControllerSupport*)controllerSupport
andConfig:(StreamConfiguration*)streamConfig {
[self reloadOnScreenControlsWith:controllerSupport andConfig:streamConfig];
bool oscEnabled = (settings.touchMode.intValue == RELATIVE_TOUCH || settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && settings.onscreenControls.intValue != OnScreenControlsLevelOff;
if(oscEnabled) [self showOnScreenControls];
else [self disableOnScreenControls];
}
- (void) reloadOnScreenControlsWith:(ControllerSupport*)controllerSupport
andConfig:(StreamConfiguration*)streamConfig {
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport streamConfig:streamConfig];
[onScreenControls setLevel:OnScreenControlsLevelCustom];
[onScreenControls setLevel:(OnScreenControlsLevel)settings.onscreenControls.intValue];
}
- (OnScreenControlsLevel) getCurrentOscState {
@@ -22,6 +22,7 @@
@property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton;
-(void)simulateSettingsButtonPress;
-(void)reloadStreamConfig;
#endif
@end
@@ -177,7 +177,7 @@ static NSMutableSet* hostList;
AppListResponse* appListResp = [ConnectionHelper getAppListForHost:host];
[self->_discMan resumeDiscoveryForHost:host];
if (![appListResp isStatusOk] || [appListResp getAppList] == nil) {
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
dispatch_async(dispatch_get_main_queue(), ^{
@@ -200,7 +200,7 @@ static NSMutableSet* hostList;
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateApplist:[appListResp getAppList] forHost:host];
if (host != self->_selectedHost) {
[self hideLoadingFrame: nil];
return;
@@ -218,7 +218,7 @@ static NSMutableSet* hostList;
- (void) updateAppEntry:(TemporaryApp*)app forHost:(TemporaryHost*)host {
DataManager* database = [[DataManager alloc] init];
NSMutableSet* newHostAppList = [NSMutableSet setWithSet:host.appList];
for (TemporaryApp* savedApp in newHostAppList) {
if ([app.id isEqualToString:savedApp.id]) {
savedApp.name = app.name;
@@ -226,13 +226,13 @@ static NSMutableSet* hostList;
savedApp.hidden = app.hidden;
host.appList = newHostAppList;
[database updateAppsForExistingHost:host];
return;
}
}
}
- (void) updateApplist:(NSSet*) newList forHost:(TemporaryHost*)host {
DataManager* database = [[DataManager alloc] init];
NSMutableSet* newHostAppList = [NSMutableSet setWithSet:host.appList];
@@ -285,7 +285,7 @@ static NSMutableSet* hostList;
} while (appWasRemoved);
host.appList = newHostAppList;
[database updateAppsForExistingHost:host];
// This host may be eligible for a shortcut now that the app list
@@ -397,7 +397,7 @@ static NSMutableSet* hostList;
}
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Connection Failed"]
message:serverInfoResp.statusMessage
message:serverInfoResp.statusMessage
preferredStyle:UIAlertControllerStyleAlert];
[Utils addHelpOptionToDialog:applistAlert];
[applistAlert addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Ok"] style:UIAlertActionStyleDefault handler:nil]];
@@ -443,11 +443,11 @@ static NSMutableSet* hostList;
- (UIViewController*) activeViewController {
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
@@ -468,7 +468,7 @@ static NSMutableSet* hostList;
message = [LocalizationHelper localizedStringForKey:@"Online - Not Paired"];
}
break;
case StateUnknown:
message = [LocalizationHelper localizedStringForKey:@"Connecting"];
break;
@@ -614,7 +614,11 @@ static NSMutableSet* hostList;
_streamConfig.appID = app.id;
_streamConfig.appName = app.name;
_streamConfig.serverCert = app.host.serverCert;
_streamConfig.serverCodecModeSupport = app.host.serverCodecModeSupport;
[self reloadStreamConfig];
}
- (void) reloadStreamConfig {
DataManager* dataMan = [[DataManager alloc] init];
TemporarySettings* streamSettings = [dataMan getSettings];
@@ -666,7 +670,6 @@ static NSMutableSet* hostList;
_streamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
}
_streamConfig.serverCodecModeSupport = app.host.serverCodecModeSupport;
switch (streamSettings.preferredCodec) {
case CODEC_PREF_AV1:
@@ -59,8 +59,54 @@
#endif
}
- (void)reConfigStreamView{
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig];
- (void)configOscLayoutTool{
[self.view removeGestureRecognizer:_oscLayoutTapRecoginizer];
if((_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom){
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
_oscLayoutTapRecoginizer.numberOfTouchesRequired = 4; //tap 4 fingers to invoke OSC rebase
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 1;
_oscLayoutTapRecoginizer.delaysTouchesBegan = NO;
_oscLayoutTapRecoginizer.delaysTouchesEnded = NO;
[self.view addGestureRecognizer:_oscLayoutTapRecoginizer];
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
_layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init];
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
if (isIPhone) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
_layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
}
else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
_layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
_layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
}
_layoutOnScreenControlsVC.view.backgroundColor = UIColor.clearColor;
_layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
}
- (void)configExitGesture{
[self.view removeGestureRecognizer:_exitSwipeRecognizer];
_exitSwipeRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(expandSettingsView)];
_exitSwipeRecognizer.edges = _settings.swipeExitScreenEdge.intValue;
_exitSwipeRecognizer.normalizedThresholdDistance = _settings.swipeToExitDistance.floatValue;
_exitSwipeRecognizer.delaysTouchesBegan = NO;
_exitSwipeRecognizer.delaysTouchesEnded = NO;
[self.view addGestureRecognizer:_exitSwipeRecognizer];
}
- (void)reConfigStreamViewRealtime{
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
[self configOscLayoutTool];
[self configExitGesture];
[self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang
[self.mainframeViewcontroller reloadStreamConfig]; // reload streamconfig
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig]; //reinitiate setupStreamView process.
[self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport
andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here.
}
- (void)viewDidAppear:(BOOL)animated
@@ -70,7 +116,7 @@
#if !TARGET_OS_TV
[[self revealViewController] setPrimaryViewController:self];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reConfigStreamView) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
selector:@selector(reConfigStreamViewRealtime) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
name:@"SettingsViewClosed"
object:nil];
#endif
@@ -143,37 +189,8 @@
[self.view addGestureRecognizer:_playPauseTapGestureRecognizer];
#else
_exitSwipeRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(expandSettingsView)];
_exitSwipeRecognizer.edges = _settings.swipeExitScreenEdge.intValue;
_exitSwipeRecognizer.normalizedThresholdDistance = _settings.swipeToExitDistance.floatValue;
_exitSwipeRecognizer.delaysTouchesBegan = NO;
_exitSwipeRecognizer.delaysTouchesEnded = NO;
[self.view addGestureRecognizer:_exitSwipeRecognizer];
if((_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom){
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
_oscLayoutTapRecoginizer.numberOfTouchesRequired = 4; //tap 4 fingers to invoke OSC rebase
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 1;
_oscLayoutTapRecoginizer.delaysTouchesBegan = NO;
_oscLayoutTapRecoginizer.delaysTouchesEnded = NO;
[self.view addGestureRecognizer:_oscLayoutTapRecoginizer];
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
_layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init];
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
if (isIPhone) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
_layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
}
else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
_layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
_layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
}
_layoutOnScreenControlsVC.view.backgroundColor = UIColor.clearColor;
_layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
[self configExitGesture]; // swipe & exit gesture configured here
[self configOscLayoutTool]; //_oscLayoutTapRecoginizer will be added or removed to the view here
#endif
_tipLabel = [[UILabel alloc] init];
@@ -263,6 +280,7 @@
- (void)oscLayoutClosed{
// Handle the callback
[self->_streamView disableOnScreenControls]; // add this to get realtime back menu working.
[self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport
andConfig:(StreamConfiguration*)_streamConfig];
[self->_streamView showOnScreenControls];