Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

change res when streaming

roryclear66da57f8ca6a
diff --git a/clearcam/SettingsManager.h b/clearcam/SettingsManager.h
index 6c70d98..fa74665 100644
--- a/clearcam/SettingsManager.h
+++ b/clearcam/SettingsManager.h
@@ -8,6 +8,7 @@
@property (nonatomic, strong) NSString *width;
@property (nonatomic, strong) NSString *height;
@property (nonatomic, strong) NSString *text_size;
+@property (nonatomic, strong) NSString *old_width;
@property (nonatomic, strong) NSString *preset; //todo, resolution
@@ -16,5 +17,6 @@
- (void)loadResolutionSettings;
- (void)saveResolutionSettings;
- (void)updateResolutionWithWidth:(NSString *)width height:(NSString *)height textSize:(NSString *)textSize preset:(NSString *)preset;
+- (void)revertResolution;
@end
diff --git a/clearcam/SettingsManager.m b/clearcam/SettingsManager.m
index 61ce78b..94b4a5c 100644
--- a/clearcam/SettingsManager.m
+++ b/clearcam/SettingsManager.m
@@ -70,6 +70,7 @@
// Update resolution settings
- (void)updateResolutionWithWidth:(NSString *)width height:(NSString *)height textSize:(NSString *)textSize preset:(NSString *)preset {
+ self.old_width = self.width;
self.width = width;
self.height = height;
self.text_size = textSize;
@@ -77,4 +78,18 @@
[self saveResolutionSettings];
}
+- (void)revertResolution{
+ self.width = self.old_width;
+ if([self.width isEqualToString:@"1280"]){
+ self.height = @"720";
+ self.text_size = @"2";
+ self.preset = @"AVCaptureSessionPreset1280x720";
+ } else {
+ self.height = @"1080";
+ self.text_size = @"1";
+ self.preset = @"AVCaptureSessionPreset1920x1080";
+ }
+ [self saveResolutionSettings];
+}
+
@end
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index d6cbd2b..65bce8f 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -1001,7 +1001,7 @@
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
- NSArray *resolutions = @[@"480p",@"720p", @"1080p"];
+ NSArray *resolutions = @[@"720p", @"1080p"];
for (NSString *resolution in resolutions) {
UIAlertAction *action = [UIAlertAction actionWithTitle:resolution
@@ -1013,8 +1013,6 @@
[settingsManager updateResolutionWithWidth:@"1280" height:@"720" textSize:@"2" preset:@"AVCaptureSessionPreset1280x720"];
} else if ([resolution isEqualToString:@"1080p"]) {
[settingsManager updateResolutionWithWidth:@"1920" height:@"1080" textSize:@"3" preset:@"AVCaptureSessionPreset1920x1080"];
- } else if ([resolution isEqualToString:@"480p"]) {
- [settingsManager updateResolutionWithWidth:@"640" height:@"480" textSize:@"2" preset:@"AVCaptureSessionPreset640x480"];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index d37bdbf..1a14a99 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -26,6 +26,7 @@
@property (nonatomic, assign) BOOL isProcessingCoreData;
@property (nonatomic, assign) BOOL recordPressed;
@property (nonatomic, assign) BOOL isRecording;
+@property (nonatomic, assign) BOOL isStreaming; //over the internet
@property (nonatomic, assign) NSTimeInterval last_check_time;
@property (nonatomic, assign) CMTime startTime;
@property (nonatomic, assign) CMTime currentTime;
@@ -162,6 +163,7 @@ NSMutableDictionary *classColorMap;
self.isProcessingCoreData = NO;
self.recordPressed = wasRecording; // Restore recording state
self.isRecording = NO;
+ self.isStreaming = NO;
self.last_check_time = [[NSDate date] timeIntervalSince1970];
self.startTime = kCMTimeInvalid;
self.currentTime = kCMTimeZero;
@@ -1127,17 +1129,29 @@ NSMutableDictionary *classColorMap;
NSLog(@"⚠️ JSON Parsing Error: %@", jsonError.localizedDescription);
} else {
NSString *uploadLink = json[@"upload_link"];
- if (uploadLink && ![uploadLink isKindOfClass:[NSNull class]]) {
- NSLog(@"📤 Upload link received: %@", uploadLink);
-
- //[FileServer sharedInstance].segment_length = 2;
- //[[SettingsManager sharedManager] updateResolutionWithWidth:@"640" height:@"480" textSize:@"2" preset:@"AVCaptureSessionPreset640x480"];
-
- //dispatch_async(dispatch_get_main_queue(), ^{
- // [self refreshView];
- //});
+ if ((uploadLink && ![uploadLink isKindOfClass:[NSNull class]])) {
+ if(self.isStreaming == NO){
+ NSLog(@"📤 Upload link received: %@", uploadLink);
+ self.isStreaming = YES;
+ [FileServer sharedInstance].segment_length = 2;
+ if(![[SettingsManager sharedManager].width isEqualToString:@"640"]) {
+ [[SettingsManager sharedManager] updateResolutionWithWidth:@"640" height:@"480" textSize:@"2" preset:@"AVCaptureSessionPreset640x480"];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self refreshView];
+ });
+ }
+ }
} else {
- NSLog(@"no link");
+ if(self.isStreaming){ //todo, messy
+ self.isStreaming = NO;
+ if([SettingsManager sharedManager].old_width && ![[SettingsManager sharedManager].width isEqualToString:[SettingsManager sharedManager].old_width]){
+ [[SettingsManager sharedManager] revertResolution];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self refreshView];
+ });
+ }
+ NSLog(@"no link");
+ }
}
}
}