Add object detection, tracking, mobile notifications, and search to any security camera.
merges 10 files
roryclear201d3f10224a
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 905555e..427a379 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -395,8 +395,9 @@context:self.context];[self sendJson200:segmentsForDate toClient:clientSocket];}-+if ([filePath hasPrefix:@"download"]) {+ NSUInteger numSegments = 10; // π₯ Change this to merge more or fewer segmentsNSString *timeStampParam = nil;NSRange queryRange = [filePath rangeOfString:@"?"];@@ -427,15 +428,16 @@NSArray *segments = [self fetchAndProcessSegmentsFromCoreDataForDateParam:formattedDate start:0 context:self.context];- if (segments.count < 2) {- NSString *errorResponse = @"HTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\n\r\n[{\"error\": \"Not enough segments found to merge\"}]";+ if (segments.count < numSegments) {+ NSString *errorResponse = [NSString stringWithFormat:@"HTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\n\r\n[{\"error\": \"Not enough segments found (found %lu, need %lu)\"}]", (unsigned long)segments.count, (unsigned long)numSegments];send(clientSocket, [errorResponse UTF8String], errorResponse.length, 0);return;}- NSMutableArray<NSString *> *segmentFilePaths = [NSMutableArray arrayWithCapacity:2];+ // β Collect `n` segment file paths+ NSMutableArray<NSString *> *segmentFilePaths = [NSMutableArray arrayWithCapacity:numSegments];- for (NSUInteger i = 0; i < 2; i++) {+ for (NSUInteger i = 0; i < numSegments; i++) {NSString *segmentURL = segments[i][@"url"];NSString *fullFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:segmentURL];@@ -448,7 +450,7 @@[segmentFilePaths addObject:fullFilePath];}- // β Ensure this runs synchronously+ // β Merge `n` files synchronouslydispatch_semaphore_t sema = dispatch_semaphore_create(0);__block NSString *outputPath = nil;@@ -510,6 +512,7 @@NSLog(@"β Merged video sent successfully.");}+if ([filePath hasPrefix:@"get-frames"]) {NSString *urlParam = nil;