Add object detection, tracking, mobile notifications, and search to any security camera.
start list of live devices
roryclear1a8ae382947e
diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.mindex 8b141fc..036356b 100644--- a/clearcam/GalleryViewController.m+++ b/clearcam/GalleryViewController.m@@ -3,6 +3,7 @@#import "SecretManager.h"#import <AVKit/AVKit.h>#import <AVFoundation/AVFoundation.h>+#import "LiveViewController.h"@interface VideoTableViewCell : UITableViewCell@property (nonatomic, strong) UIImageView *thumbnailView;@@ -64,45 +65,6 @@@end-// New Live tab view controller-@interface LiveViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>-@property (nonatomic, strong) UITableView *tableView;-@end--@implementation LiveViewController--- (void)viewDidLoad {- [super viewDidLoad];- self.title = @"Live";- [self setupTableView];-}--- (void)setupTableView {- self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];- self.tableView.delegate = self;- self.tableView.dataSource = self;- self.tableView.backgroundColor = [UIColor systemBackgroundColor];- [self.view addSubview:self.tableView];-- self.tableView.translatesAutoresizingMaskIntoConstraints = NO;- [NSLayoutConstraint activateConstraints:@[- [self.tableView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],- [self.tableView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor],- [self.tableView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor],- [self.tableView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor]- ]];-}--- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {- return 0; // Empty for now-}--- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {- return [UITableViewCell new]; // Empty for now-}--@end-// Modified GalleryViewController with tabs@interface GalleryViewController () <UITableViewDelegate, UITableViewDataSource>@property (nonatomic, strong) UITabBarController *tabController;diff --git a/clearcam/LiveViewController.h b/clearcam/LiveViewController.hnew file mode 100644index 0000000..253e478--- /dev/null+++ b/clearcam/LiveViewController.h@@ -0,0 +1,9 @@+#import <UIKit/UIKit.h>++NS_ASSUME_NONNULL_BEGIN++@interface LiveViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>+@property (nonatomic, strong) UITableView *tableView;+@end++NS_ASSUME_NONNULL_ENDdiff --git a/clearcam/LiveViewController.m b/clearcam/LiveViewController.mnew file mode 100644index 0000000..4df8a75--- /dev/null+++ b/clearcam/LiveViewController.m@@ -0,0 +1,111 @@+// LiveViewController.m+#import "LiveViewController.h"+#import "StoreManager.h"++@interface LiveViewController () <UITableViewDelegate, UITableViewDataSource>+@property (nonatomic, strong) NSMutableArray<NSString *> *deviceNames;+@property (nonatomic, strong) NSURLSession *session;+@end++@implementation LiveViewController++- (void)viewDidLoad {+ [super viewDidLoad];+ self.title = @"Live";+ self.deviceNames = [NSMutableArray array];+ self.session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];+ [self setupTableView];+ [self fetchLiveDevices];+}++- (void)setupTableView {+ self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];+ self.tableView.delegate = self;+ self.tableView.dataSource = self;+ self.tableView.backgroundColor = [UIColor systemBackgroundColor];+ [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"DeviceCell"];++ [self.view addSubview:self.tableView];++ self.tableView.translatesAutoresizingMaskIntoConstraints = NO;+ [NSLayoutConstraint activateConstraints:@[+ [self.tableView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],+ [self.tableView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor],+ [self.tableView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor],+ [self.tableView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor]+ ]];+}++- (void)fetchLiveDevices {+ NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];+ if (!sessionToken) {+ NSLog(@"No session token available");+ return;+ }++ NSString *encodedSessionToken = [sessionToken stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];+ NSURLComponents *components = [NSURLComponents componentsWithString:@"https://rors.ai/get_live_devices"];+ components.queryItems = @[+ [NSURLQueryItem queryItemWithName:@"session_token" value:encodedSessionToken]+ ];++ NSURL *url = components.URL;+ NSLog(@"Final URL: %@", url);++ NSURLSessionDataTask *task = [self.session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {+ if (error) {+ NSLog(@"❌ Error: %@", error.localizedDescription);+ return;+ }++ NSError *jsonError;+ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];+ if (jsonError) {+ NSLog(@"❌ JSON Error: %@", jsonError.localizedDescription);+ return;+ }++ NSArray<NSString *> *deviceNames = json[@"device_names"];+ if (deviceNames) {+ dispatch_async(dispatch_get_main_queue(), ^{+ [self.deviceNames removeAllObjects];+ for (NSString *deviceName in deviceNames) {+ NSString *decodedName = [deviceName stringByRemovingPercentEncoding];+ if (decodedName) {+ [self.deviceNames addObject:decodedName];+ }+ }+ [self.tableView reloadData];+ });+ }+ }];+ [task resume];+}++#pragma mark - UITableViewDataSource++- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {+ return self.deviceNames.count;+}++- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DeviceCell" forIndexPath:indexPath];+ cell.textLabel.text = self.deviceNames[indexPath.row];+ cell.textLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];+ cell.backgroundColor = [UIColor systemBackgroundColor];+ return cell;+}++#pragma mark - UITableViewDelegate++- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {+ NSString *selectedDevice = self.deviceNames[indexPath.row];+ NSLog(@"Selected device: %@", selectedDevice);+ [tableView deselectRowAtIndexPath:indexPath animated:YES];+}++- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {+ return 44;+}++@end