Add on-screen connection status warning

This commit is contained in:
Cameron Gutman
2019-07-23 18:43:41 -04:00
parent af16f03703
commit ba4e55aac4
3 changed files with 55 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <Limelight.h>
@implementation StreamFrameViewController {
ControllerSupport *_controllerSupport;
@@ -22,6 +23,7 @@
NSTimer *_inactivityTimer;
UITapGestureRecognizer *_menuGestureRecognizer;
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
UITextView *_overlayView;
}
- (void)viewDidAppear:(BOOL)animated
@@ -118,6 +120,31 @@
}
}
- (void)updateOverlayText:(NSString*)text {
if (_overlayView == nil) {
_overlayView = [[UITextView alloc] init];
[_overlayView setEditable:NO];
[_overlayView setSelectable:NO];
[_overlayView setScrollEnabled:NO];
[_overlayView setTextAlignment:NSTextAlignmentCenter];
[_overlayView setTextColor:[OSColor lightGrayColor]];
[_overlayView setBackgroundColor:[OSColor blackColor]];
[_overlayView setFont:[UIFont systemFontOfSize:12]];
[_overlayView setAlpha:0.5];
[self.view addSubview:_overlayView];
}
if (text != nil) {
[_overlayView setText:text];
[_overlayView sizeToFit];
[_overlayView setCenter:CGPointMake(self.view.frame.size.width / 2, _overlayView.frame.size.height / 2)];
[_overlayView setHidden:NO];
}
else {
[_overlayView setHidden:YES];
}
}
- (void) returnToMainFrame {
[self.navigationController popToRootViewControllerAnimated:YES];
}
@@ -264,6 +291,27 @@
[_controllerSupport rumble:controllerNumber lowFreqMotor:lowFreqMotor highFreqMotor:highFreqMotor];
}
- (void)connectionStatusUpdate:(int)status {
Log(LOG_W, @"Connection status update: %d", status);
dispatch_async(dispatch_get_main_queue(), ^{
switch (status) {
case CONN_STATUS_OKAY:
[self updateOverlayText:nil];
break;
case CONN_STATUS_POOR:
if (self->_streamConfig.bitRate > 5000) {
[self updateOverlayText:@"Slow connection to PC\nReduce your bitrate"];
}
else {
[self updateOverlayText:@"Poor connection to PC"];
}
break;
}
});
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];