Add object detection, tracking, mobile notifications, and search to any security camera.
variable segment size
roryclear9ba5a9b7d739
diff --git a/clearcam/FileServer.h b/clearcam/FileServer.hindex e5b3765..142c8f3 100644--- a/clearcam/FileServer.h+++ b/clearcam/FileServer.h@@ -4,5 +4,7 @@- (void)start;@property (nonatomic, strong) NSMutableDictionary *segmentsDict;+@property (nonatomic, assign) NSInteger segment_length;+@property (nonatomic, strong) NSDate *last_req_time;@enddiff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 9806af6..34e66f4 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -18,6 +18,8 @@- (void)start {dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{+ self.segment_length = 60;+ self.last_req_time = [NSDate now];self.segmentsDict = [[NSMutableDictionary alloc] init];self.basePath = [self getDocumentsDirectory];self.durationCache = [[NSMutableDictionary alloc] init];@@ -65,6 +67,11 @@}- (void)handleClientRequest:(int)clientSocket withBasePath:(NSString *)basePath {+ if(self.segment_length == 60){+ self.segment_length = 1;+ sleep(2); //todo, this is bad+ }+ self.last_req_time = [NSDate now];char requestBuffer[1024];ssize_t bytesRead = recv(clientSocket, requestBuffer, sizeof(requestBuffer) - 1, 0);if (bytesRead < 0) {diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex f932641..35537f7 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -476,7 +476,10 @@ NSMutableDictionary *classColorMap;if (!success) [self finishRecording];}NSTimeInterval elapsedTime = CMTimeGetSeconds(self.currentTime);- if (elapsedTime >= 1.0) {+ if (self.fileServer.segment_length == 1 && [[NSDate now] timeIntervalSinceDate:self.fileServer.last_req_time] > 60){+ self.fileServer.segment_length = 60;+ }+ if (elapsedTime >= self.fileServer.segment_length) {[self finishRecording];}}