Skip to content

Commit 1e5f627

Browse files
committed
Extended CA API - Add field cameraPosition
1 parent b244e4e commit 1e5f627

7 files changed

Lines changed: 110 additions & 2 deletions

File tree

src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type InitialValues = {
6969
stream: string;
7070
record: string;
7171
layout: string;
72+
cameraPosition: string;
7273
}
7374

7475
/**
@@ -179,6 +180,19 @@ const EventDetailsSchedulingTab = ({
179180
}
180181
};
181182

183+
const getCameraPosition = (deviceId: Recording["id"]) => {
184+
if (deviceId === source.device.id) {
185+
return source.device.parsedCapabilities.cameraPosition ? source.device.parsedCapabilities.cameraPosition : [];
186+
} else {
187+
for (const agent of filterDevicesForAccess(user, captureAgents)) {
188+
if (agent.id === deviceId) {
189+
return agent.parsedCapabilities.cameraPosition ? agent.parsedCapabilities.cameraPosition : [];
190+
}
191+
}
192+
return [];
193+
}
194+
};
195+
182196
const getInputForAgent = (deviceId: Recording["id"], input: string) => {
183197
const inputs = getInputs(deviceId);
184198
const value = inputs.find(agent => agent.id === input)?.value;
@@ -203,6 +217,12 @@ const EventDetailsSchedulingTab = ({
203217
return value ? t(value as ParseKeys) : "";
204218
};
205219

220+
const getCameraPositionForAgent = (deviceId: Recording["id"], s: string) => {
221+
const cameraPosition = getCameraPosition(deviceId);
222+
const value = cameraPosition.find(agent => agent.id === s)?.value;
223+
return value ? t(value as ParseKeys) : "";
224+
};
225+
206226
// changes the inputs in the formik
207227
const changeInputs = (deviceId: Recording["id"], setFieldValue: (field: string, value: any) => Promise<void | FormikErrors<any>>) => {
208228
setFieldValue("captureAgent", deviceId);
@@ -315,6 +335,9 @@ const EventDetailsSchedulingTab = ({
315335
const layout = source.device.capabilitiesMethods.layout && source.device.capabilitiesMethods.layout.length > 0
316336
? source.device.capabilitiesMethods.layout[0]
317337
: "";
338+
const cameraPosition = source.device.capabilitiesMethods.cameraPosition && source.device.capabilitiesMethods.cameraPosition.length > 0
339+
? source.device.capabilitiesMethods.cameraPosition[0]
340+
: "";
318341

319342
startDate.setHours(0, 0, 0);
320343
endDate.setHours(0, 0, 0);
@@ -333,6 +356,7 @@ const EventDetailsSchedulingTab = ({
333356
stream: stream,
334357
record: record,
335358
layout: layout,
359+
cameraPosition: cameraPosition,
336360
};
337361
};
338362

@@ -701,6 +725,33 @@ const EventDetailsSchedulingTab = ({
701725
)}
702726
</td>
703727
</tr>
728+
729+
{/* cameraPosition */}
730+
<tr>
731+
<td>
732+
{t(
733+
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.CAMERA_POSITION",
734+
)}
735+
</td>
736+
<td>
737+
{!!formik.values.captureAgent &&
738+
!!getCameraPosition(formik.values.captureAgent) &&
739+
getCameraPosition(formik.values.captureAgent).length >
740+
0 &&
741+
(hasAccessRole &&
742+
accessAllowed(formik.values.captureAgent)
743+
? <SchedulingRadio
744+
name="cameraPosition"
745+
inputs={getCameraPosition(formik.values.captureAgent)}
746+
/>
747+
:
748+
<span>
749+
{getCameraPositionForAgent(formik.values.captureAgent, formik.values.cameraPosition)}
750+
<br />
751+
</span>
752+
)}
753+
</td>
754+
</tr>
704755
</tbody>
705756
</table>
706757
</div>

src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,26 @@ const Schedule = <T extends {
543543
}
544544
};
545545

546+
const renderCameraPositionDeviceOptions = () => {
547+
if (formik.values.location) {
548+
const inputDevice = inputDevices.find(
549+
({ name }) => name === formik.values.location,
550+
);
551+
if (!inputDevice) {
552+
return <></>;
553+
}
554+
return (
555+
<>
556+
<SchedulingRadio
557+
name="cameraPosition"
558+
inputs={inputDevice.parsedCapabilities.cameraPosition}
559+
// formik={formik}
560+
/>
561+
</>
562+
);
563+
}
564+
};
565+
546566
return (
547567
<div className="obj">
548568
<header>{t("EVENTS.EVENTS.NEW.SOURCE.DATE_TIME.CAPTION")}</header>
@@ -854,6 +874,12 @@ const Schedule = <T extends {
854874
{renderLayoutDeviceOptions()}
855875
</td>
856876
</tr>
877+
<tr>
878+
<td>{t("EVENTS.EVENTS.NEW.SOURCE.PLACEHOLDER.CAMERA_POSITION")}</td>
879+
<td>
880+
{renderCameraPositionDeviceOptions()}
881+
</td>
882+
</tr>
857883
</tbody>
858884
</table>
859885
</div>

src/i18n/org/opencastproject/adminui/languages/lang-en_US.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@
539539
"END_DATE_FORMAT": "yyyy-mm-dd",
540540
"STREAM": "Stream",
541541
"RECORD": "Record",
542-
"LAYOUT": "Layout"
542+
"LAYOUT": "Layout",
543+
"CAMERA_POSITION": "Camera position"
543544
},
544545
"UPLOAD": {
545546
"CAPTION": "Upload",
@@ -773,7 +774,8 @@
773774
"END_DATE": "yyyy-mm-dd",
774775
"STREAM": "Stream",
775776
"RECORD": "Record",
776-
"LAYOUT": "Layout"
777+
"LAYOUT": "Layout",
778+
"CAMERA_POSITION": "Camera position"
777779
},
778780
"UPLOAD": {
779781
"CAPTION": "Upload",

src/slices/eventDetailsSlice.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ type Device = {
119119
stream: { id: string, value: string }[],
120120
record: { id: string, value: string }[],
121121
layout: { id: string, value: string }[],
122+
cameraPosition: { id: string, value: string }[],
122123
},
123124
capabilitiesMethods: {
124125
inputs: string[],
125126
stream: string[],
126127
record: string[],
127128
layout: string[],
129+
cameraPosition: string[],
128130
}
129131
name: string,
130132
// Fields we add to "device" from recordings but don't actually care about?
@@ -559,12 +561,14 @@ const initialState: EventDetailsState = {
559561
stream: [],
560562
record: [],
561563
layout: [],
564+
cameraPosition: [],
562565
},
563566
capabilitiesMethods: {
564567
inputs: [],
565568
stream: [],
566569
record: [],
567570
layout: [],
571+
cameraPosition: [],
568572
},
569573
},
570574
agentId: undefined,
@@ -1037,6 +1041,7 @@ export const fetchSchedulingInfo = createAppAsyncThunk("eventDetails/fetchSchedu
10371041
"capture.device.stream": string,
10381042
"capture.device.record": string,
10391043
"capture.device.layout": string,
1044+
"capture.device.cameraPosition": string,
10401045
},
10411046
presenters: string[],
10421047
start: string,
@@ -1069,12 +1074,14 @@ export const fetchSchedulingInfo = createAppAsyncThunk("eventDetails/fetchSchedu
10691074
stream: [],
10701075
record: [],
10711076
layout: [],
1077+
cameraPosition: [],
10721078
},
10731079
capabilitiesMethods: {
10741080
inputs: [],
10751081
stream: [],
10761082
record: [],
10771083
layout: [],
1084+
cameraPosition: [],
10781085
},
10791086
};
10801087

@@ -1118,13 +1125,23 @@ export const fetchSchedulingInfo = createAppAsyncThunk("eventDetails/fetchSchedu
11181125
}
11191126
}
11201127

1128+
const cameraPositionMethods = [];
1129+
1130+
if (schedulingResponse.agentConfiguration["capture.device.cameraPosition"] !== undefined) {
1131+
const cameraPosition = schedulingResponse.agentConfiguration["capture.device.cameraPosition"].split(",");
1132+
for (const s of cameraPosition) {
1133+
cameraPositionMethods.push(s);
1134+
}
1135+
}
1136+
11211137
device = {
11221138
...agent,
11231139
capabilitiesMethods: {
11241140
inputs: inputMethods,
11251141
stream: streamMethods,
11261142
record: recordMethods,
11271143
layout: layoutMethods,
1144+
cameraPosition: cameraPositionMethods,
11281145
},
11291146
};
11301147
}
@@ -1158,6 +1175,7 @@ export type SchedulingInfo = {
11581175
stream: string,
11591176
record: string,
11601177
layout: string,
1178+
cameraPosition: string,
11611179
scheduleDurationHours: string,
11621180
scheduleDurationMinutes: string,
11631181
scheduleEndDate: string,
@@ -1204,6 +1222,7 @@ export const saveSchedulingInfo = createAppAsyncThunk("eventDetails/saveScheduli
12041222
"capture.device.stream": values.stream,
12051223
"capture.device.record": values.record,
12061224
"capture.device.layout": values.layout,
1225+
"capture.device.cameraPosition": values.cameraPosition,
12071226
"event.location": agent ? agent.id : "",
12081227
},
12091228
};
@@ -2338,12 +2357,14 @@ const eventDetailsSlice = createSlice({
23382357
stream: [],
23392358
record: [],
23402359
layout: [],
2360+
cameraPosition: [],
23412361
},
23422362
capabilitiesMethods: {
23432363
inputs: [],
23442364
stream: [],
23452365
record: [],
23462366
layout: [],
2367+
cameraPosition: [],
23472368
},
23482369
},
23492370
agentId: undefined,

src/slices/eventSlice.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ export const postNewEvent = (params: {
443443
stream?: string,
444444
record?: string,
445445
layout?: string,
446+
cameraPosition?: string,
446447
processingWorkflow: string,
447448
repeatOn: string[],
448449
scheduleDurationHours: string,
@@ -477,6 +478,7 @@ export const postNewEvent = (params: {
477478
stream: string,
478479
record: string,
479480
layout: string,
481+
cameraPosition: string,
480482
end: Date,
481483
duration: string,
482484
rrule?: string,
@@ -556,6 +558,7 @@ export const postNewEvent = (params: {
556558
stream: values.stream ?? "",
557559
record: values.record ?? "",
558560
layout: values.layout ?? "",
561+
cameraPosition: values.cameraPosition ?? "",
559562
end: endDate,
560563
duration: duration.toString(),
561564
},

src/slices/recordingDetailsSlice.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface RecordingDetails {
2727
stream: { id: string, value: string }[],
2828
record: { id: string, value: string }[],
2929
layout: { id: string, value: string }[],
30+
cameraPosition: { id: string, value: string }[],
3031
},
3132
}
3233

@@ -50,6 +51,7 @@ const initialState: RecordingDetailsState = {
5051
stream: [],
5152
record: [],
5253
layout: [],
54+
cameraPosition: [],
5355
},
5456
};
5557

src/slices/recordingSlice.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Recording = {
1717
stream: { id: string, value: string }[],
1818
record: { id: string, value: string }[],
1919
layout: { id: string, value: string }[],
20+
cameraPosition: { id: string, value: string }[],
2021
},
2122
name: string,
2223
removable: boolean,
@@ -97,11 +98,13 @@ export const fetchRecordings = createAppAsyncThunk("recordings/fetchRecordings",
9798
stream: [],
9899
record: [],
99100
layout: [],
101+
cameraPosition: [],
100102
};
101103
parsedCapabilities.inputs = parsedCapabilities.inputs ? [...parsedCapabilities.inputs] : [];
102104
parsedCapabilities.stream = parsedCapabilities.stream ? [...parsedCapabilities.stream] : [];
103105
parsedCapabilities.record = parsedCapabilities.record ? [...parsedCapabilities.record] : [];
104106
parsedCapabilities.layout = parsedCapabilities.layout ? [...parsedCapabilities.layout] : [];
107+
parsedCapabilities.cameraPosition = parsedCapabilities.cameraPosition ? [...parsedCapabilities.cameraPosition] : [];
105108

106109
const transformedAgent = {
107110
id: agent.Name,

0 commit comments

Comments
 (0)