Skip to content

Commit 355ac7e

Browse files
committed
Prepare for CalSync integration
1 parent f6b5c22 commit 355ac7e

9 files changed

+129
-2
lines changed

Daemons/vmpserverd/config.plist.in

+34
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,40 @@
2121
<key>scratchDirectory</key>
2222
<string></string>
2323

24+
<!--
25+
iCalendar URL for scheduling recordings
26+
and locations for filtering calendar events
27+
-->
28+
<key>icalURL</key>
29+
<string></string>
30+
<key>locations</key>
31+
<!--
32+
Maps LOCATION property of a VEVENT to
33+
channels.
34+
35+
E.g. If we have an event in FMI_HS1, two
36+
recordings are scheduled:
37+
1. present0, audio0
38+
2. camera0, audio0
39+
-->
40+
<array>
41+
<dict>
42+
<key>name</key>
43+
<string>FMI_HS1</string>
44+
<key>source</key>
45+
<array>
46+
<array>
47+
<string>present0</string>
48+
<string>audio0</string>
49+
</array>
50+
<array>
51+
<string>camera0</string>
52+
<string>audio0</string>
53+
</array>
54+
</array>
55+
</dict>
56+
</array>
57+
2458
<!--
2559
Specify the address and port of the RTSP server here.
2660
The rtspAddress is the IP address of the interface to bind to.

Daemons/vmpserverd/meson.build

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ systemd_dep = dependency('libsystemd')
2828
# HTTP server library for the REST API
2929
libmicrohttpkit_dep = dependency('microhttpkit')
3030

31+
# CalendarKit for iCalendar parsing
32+
libcalendarkit_dep = dependency('calendarkit')
33+
3134
# libdispatch for recording scheduling
3235
libdispatch_dep = dependency('libdispatch')
3336

@@ -70,6 +73,8 @@ source = [
7073
'src/VMPRecordingManager.m',
7174
'src/VMPErrors.m',
7275
'src/VMPJournal.m',
76+
'src/VMPCalEvent.m',
77+
'src/VMPCalSync.m',
7378
'src/NSString+substituteVariables.m',
7479
'src/NSRunLoop+blockExecution.m',
7580
# Models
@@ -99,6 +104,7 @@ dependencies = [
99104
udev_dep,
100105
systemd_dep,
101106
libmicrohttpkit_dep,
107+
libcalendarkit_dep,
102108
libdispatch_dep,
103109
libcgraph_dep,
104110
libgvc_dep,

Daemons/vmpserverd/src/VMPCalEvent.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* vmpserverd - A virtual multimedia processor
2+
* Copyright (C) 2023 Hugo Melder
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
#import <Foundation/Foundation.h>
8+
9+
@interface VMPCalEvent : NSObject
10+
11+
@property (nonatomic) NSString *uid;
12+
@property (nonatomic) NSString *summary;
13+
@property (nonatomic) NSString *location;
14+
@property (nonatomic) NSDate *startDate;
15+
@property (nonatomic) NSDate *endDate;
16+
@property BOOL recordingScheduled;
17+
18+
@end

Daemons/vmpserverd/src/VMPCalEvent.m

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* vmpserverd - A virtual multimedia processor
2+
* Copyright (C) 2023 Hugo Melder
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
#import "VMPCalEvent.h"
8+
9+
@implementation VMPCalEvent
10+
@end

Daemons/vmpserverd/src/VMPCalSync.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* vmpserverd - A virtual multimedia processor
2+
* Copyright (C) 2023 Hugo Melder
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
#import <Foundation/Foundation.h>
8+
#import <dispatch/dispatch.h>
9+
10+
#import "VMPCalEvent.h"
11+
12+
@interface VMPCalSync : NSObject {
13+
NSMutableArray<VMPCalEvent *> *_events;
14+
}
15+
16+
@property (readonly) NSURL *icalURL;
17+
@property (readonly) NSTimeInterval updateInterval;
18+
@property (readonly) NSArray<NSString *> *locations;
19+
20+
- (instancetype)initWithURL:(NSURL *)url
21+
locations:(NSArray<NSString *> *)locations
22+
updateInterval:(NSTimeInterval)interval;
23+
24+
@end

Daemons/vmpserverd/src/VMPCalSync.m

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* vmpserverd - A virtual multimedia processor
2+
* Copyright (C) 2023 Hugo Melder
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
#import "VMPCalSync.h"
8+
9+
@implementation VMPCalSync
10+
11+
- (instancetype)initWithURL:(NSURL *)url
12+
locations:(NSArray<NSString *> *)locations
13+
updateInterval:(NSTimeInterval)interval {
14+
self = [super init];
15+
if (self) {
16+
_icalURL = url;
17+
_updateInterval = interval;
18+
_locations = [locations copy];
19+
_events = [NSMutableArray arrayWithCapacity:100];
20+
}
21+
22+
return self;
23+
}
24+
25+
@end

Daemons/vmpserverd/src/VMPServerMain.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
#import <MicroHTTPKit/MicroHTTPKit.h>
88
#import <glib.h>
99

10+
#import "VMPCalSync.h"
1011
#import "VMPConfigModel.h"
1112
#import "VMPJournal.h"
1213
#import "VMPProfileManager.h"
1314
#import "VMPRTSPServer.h"
1415
#import "VMPServerMain.h"
1516

16-
#include <graphviz/cgraph.h>
17-
#include <graphviz/gvc.h>
17+
#import <graphviz/cgraph.h>
18+
#import <graphviz/gvc.h>
1819

1920
#include "config.h"
2021

@@ -70,6 +71,7 @@
7071
@implementation VMPServerMain {
7172
VMPRTSPServer *_rtspServer;
7273
VMPProfileManager *_profileMgr;
74+
VMPCalSync *_calSync;
7375
HKHTTPServer *_httpServer;
7476
NSString *_version;
7577
NSDate *_startedAtDate;

Daemons/vmpserverd/src/models/VMPConfigModel.h

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
@property (nonatomic, strong) NSString *scratchDirectory;
2020

21+
@property (nonatomic, strong) NSString *icalURL;
22+
2123
@property (nonatomic, strong) NSString *rtspAddress;
2224

2325
@property (nonatomic, strong) NSString *rtspPort;
@@ -32,6 +34,8 @@
3234

3335
@property (nonatomic, strong) NSString *gstDebug;
3436

37+
@property (nonatomic, strong) NSArray<id> *locations;
38+
3539
@property (nonatomic, strong) NSArray<VMPConfigMountpointModel *> *mountpoints;
3640

3741
@property (nonatomic, strong) NSArray<VMPConfigChannelModel *> *channels;

Daemons/vmpserverd/src/models/VMPConfigModel.m

+4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ - (id)initWithPropertyList:(id)propertyList error:(NSError **)error {
2222
SET_PROPERTY(_name, @"name");
2323
SET_PROPERTY(_profileDirectory, @"profileDirectory");
2424
SET_PROPERTY(_scratchDirectory, @"scratchDirectory");
25+
SET_PROPERTY(_icalURL, @"icalURL");
2526
SET_PROPERTY(_rtspAddress, @"rtspAddress");
2627
SET_PROPERTY(_rtspPort, @"rtspPort");
2728
SET_PROPERTY(_httpPort, @"httpPort");
2829
SET_PROPERTY(_httpAuth, @"httpAuth");
2930
SET_PROPERTY(_httpUsername, @"httpUsername");
3031
SET_PROPERTY(_httpPassword, @"httpPassword");
3132
SET_PROPERTY(_gstDebug, @"gstDebug");
33+
SET_PROPERTY(_locations, @"locations");
3234

3335
SET_PROPERTY(plistMountpoints, @"mountpoints");
3436
SET_PROPERTY(plistChannels, @"channels");
@@ -86,6 +88,7 @@ - (NSArray *)propertyListChannels {
8688

8789
- (id)propertyList {
8890
VMP_ASSERT(_name, @"name is nil");
91+
VMP_ASSERT(_icalURL, @"icalURL is nil");
8992
VMP_ASSERT(_rtspAddress, @"rtspAddress is nil");
9093
VMP_ASSERT(_rtspPort, @"rtspPort is nil");
9194
VMP_ASSERT(_httpPort, @"httpPort is nil");
@@ -98,6 +101,7 @@ - (id)propertyList {
98101

99102
return @{
100103
@"name" : _name,
104+
@"icalURL" : _icalURL,
101105
@"rtspAddress" : _rtspAddress,
102106
@"rtspPort" : _rtspPort,
103107
@"httpPort" : _httpPort,

0 commit comments

Comments
 (0)