Skip to content

Commit fabf651

Browse files
committed
Extended CA API - Add field cameraPosition
1 parent c84dcb0 commit fabf651

File tree

7 files changed

+110
-2
lines changed

7 files changed

+110
-2
lines changed

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
@@ -505,6 +505,26 @@ const Schedule = <T extends {
505505
}
506506
};
507507

508+
const renderCameraPositionDeviceOptions = () => {
509+
if (formik.values.location) {
510+
const inputDevice = inputDevices.find(
511+
({ name }) => name === formik.values.location,
512+
);
513+
if (!inputDevice) {
514+
return <></>;
515+
}
516+
return (
517+
<>
518+
<SchedulingRadio
519+
name="cameraPosition"
520+
inputs={inputDevice.parsedCapabilities.cameraPosition}
521+
// formik={formik}
522+
/>
523+
</>
524+
);
525+
}
526+
};
527+
508528
return (
509529
<div className="obj">
510530
<header>{t("EVENTS.EVENTS.NEW.SOURCE.DATE_TIME.CAPTION")}</header>
@@ -792,6 +812,12 @@ const Schedule = <T extends {
792812
{renderLayoutDeviceOptions()}
793813
</td>
794814
</tr>
815+
<tr>
816+
<td>{t("EVENTS.EVENTS.NEW.SOURCE.PLACEHOLDER.CAMERA_POSITION")}</td>
817+
<td>
818+
{renderCameraPositionDeviceOptions()}
819+
</td>
820+
</tr>
795821
</tbody>
796822
</table>
797823
</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
@@ -538,7 +538,8 @@
538538
"END_DATE_FORMAT": "yyyy-mm-dd",
539539
"STREAM": "Stream",
540540
"RECORD": "Record",
541-
"LAYOUT": "Layout"
541+
"LAYOUT": "Layout",
542+
"CAMERA_POSITION": "Camera position"
542543
},
543544
"UPLOAD": {
544545
"CAPTION": "Upload",
@@ -767,7 +768,8 @@
767768
"END_DATE": "yyyy-mm-dd",
768769
"STREAM": "Stream",
769770
"RECORD": "Record",
770-
"LAYOUT": "Layout"
771+
"LAYOUT": "Layout",
772+
"CAMERA_POSITION": "Camera position"
771773
},
772774
"UPLOAD": {
773775
"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
@@ -441,6 +441,7 @@ export const postNewEvent = (params: {
441441
stream?: string,
442442
record?: string,
443443
layout?: string,
444+
cameraPosition?: string,
444445
processingWorkflow: string,
445446
repeatOn: string[],
446447
scheduleDurationHours: string,
@@ -474,6 +475,7 @@ export const postNewEvent = (params: {
474475
stream: string,
475476
record: string,
476477
layout: string,
478+
cameraPosition: string,
477479
end: Date,
478480
duration: string,
479481
rrule?: string,
@@ -553,6 +555,7 @@ export const postNewEvent = (params: {
553555
stream: values.stream ?? "",
554556
record: values.record ?? "",
555557
layout: values.layout ?? "",
558+
cameraPosition: values.cameraPosition ?? "",
556559
end: endDate,
557560
duration: duration.toString(),
558561
},

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)