Skip to content

Commit

Permalink
fix: updated multiview-arr-interface to be called multiviews instead …
Browse files Browse the repository at this point in the history
…of multiview, and minor fixes
  • Loading branch information
malmen237 committed Sep 4, 2024
1 parent 169c23f commit a1eb23a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
13 changes: 7 additions & 6 deletions src/api/agileLive/pipelines/multiviews/multiviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ export async function createMultiviewForPipeline(
productionSettings: ProductionSettings,
sourceRefs: SourceReference[]
): Promise<ResourcesPipelineMultiviewResponse[]> {
// TODO Check if this can be cleaned out. This is an old code and dont know the purpose of it, therefor I dont want to remove it yet.
// const multiviewPresets = await getMultiviewPresets();

const pipeline = productionSettings.pipelines.find((p) =>
p.multiview ? p.multiview?.length > 0 : undefined
p.multiviews ? p.multiviews?.length > 0 : undefined
);
const multiviewIndexArray = pipeline?.multiview
? pipeline.multiview.map((p) => p.for_pipeline_idx)
const multiviewIndexArray = pipeline?.multiviews
? pipeline.multiviews.map((p) => p.for_pipeline_idx)
: undefined;

const multiviewIndex = multiviewIndexArray?.find((p) => p !== undefined);
Expand All @@ -54,8 +55,8 @@ export async function createMultiviewForPipeline(
throw `Did not find a specified pipeline in multiview settings`;
}
if (
!productionSettings.pipelines[multiviewIndex].multiview ||
productionSettings.pipelines[multiviewIndex].multiview?.length === 0
!productionSettings.pipelines[multiviewIndex].multiviews ||
productionSettings.pipelines[multiviewIndex].multiviews?.length === 0
) {
Log().error(
`Did not find any multiview settings in pipeline settings for: ${productionSettings.pipelines[multiviewIndex]}`
Expand All @@ -80,7 +81,7 @@ export async function createMultiviewForPipeline(
Log().info(`Creating a multiview for pipeline '${pipelineUUID}' from preset`);

const multiviewsSettings: MultiviewSettings[] =
productionSettings.pipelines[multiviewIndex].multiview ?? [];
productionSettings.pipelines[multiviewIndex].multiviews ?? [];

const createEachMultiviewer = multiviewsSettings.map(
async (singleMultiviewSettings) => {
Expand Down
3 changes: 1 addition & 2 deletions src/api/agileLive/pipelines/streams/streams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useCallback } from 'react';
import { ResourcesUUIDResponse } from '../../../../../types/agile-live';
import { AGILE_BASE_API_PATH } from '../../../../constants';
import {
Expand Down Expand Up @@ -206,7 +205,7 @@ export async function createStream(

const multiviews = multiviewsResponse.filter((multiview) => {
const pipeline = production.production_settings.pipelines[0];
const multiviewArray = pipeline.multiview;
const multiviewArray = pipeline.multiviews;

if (Array.isArray(multiviewArray)) {
return multiviewArray.some(
Expand Down
4 changes: 2 additions & 2 deletions src/api/manager/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export async function startProduction(

// Try to setup multiviews start
try {
if (!production.production_settings.pipelines[0].multiview) {
if (!production.production_settings.pipelines[0].multiviews) {
Log().error(
`No multiview settings specified for production: ${production.name}`
);
Expand All @@ -676,7 +676,7 @@ export async function startProduction(
});

runtimeMultiviews.flatMap((runtimeMultiview, index) => {
const multiview = production.production_settings.pipelines[0].multiview;
const multiview = production.production_settings.pipelines[0].multiviews;
if (multiview && multiview[index]) {
return (multiview[index].multiview_id = runtimeMultiview.id);
}
Expand Down
13 changes: 7 additions & 6 deletions src/app/production/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ export default function ProductionConfiguration({ params }: PageProps) {
putProduction(updatedSetup._id.toString(), updatedSetup);
const pipeline = updatedSetup.production_settings.pipelines[0];

pipeline.multiview?.map((singleMultiview) => {
pipeline.multiviews?.map((singleMultiview) => {
if (
pipeline.pipeline_id &&
pipeline.multiview &&
pipeline.multiviews &&
singleMultiview.multiview_id
) {
updateMultiviewViews(
Expand Down Expand Up @@ -337,7 +337,7 @@ export default function ProductionConfiguration({ params }: PageProps) {
pipelines: preset.pipelines
}
} as Production;
updatedSetup.production_settings.pipelines[0].multiview = [multiview];
updatedSetup.production_settings.pipelines[0].multiviews = [multiview];
setProductionSetup(updatedSetup);
}

Expand Down Expand Up @@ -428,9 +428,9 @@ export default function ProductionConfiguration({ params }: PageProps) {
productionSetup.isActive &&
selectedSource &&
(Array.isArray(
productionSetup?.production_settings.pipelines[0].multiview
productionSetup?.production_settings.pipelines[0].multiviews
)
? productionSetup.production_settings.pipelines[0].multiview.some(
? productionSetup.production_settings.pipelines[0].multiviews.some(
(singleMultiview) => singleMultiview?.layout?.views
)
: false)
Expand Down Expand Up @@ -486,7 +486,7 @@ export default function ProductionConfiguration({ params }: PageProps) {
selectedSourceRef.stream_uuids
) {
const multiviews =
productionSetup.production_settings.pipelines[0].multiview;
productionSetup.production_settings.pipelines[0].multiviews;

if (!multiviews || multiviews.length === 0) return;

Expand Down Expand Up @@ -555,6 +555,7 @@ export default function ProductionConfiguration({ params }: PageProps) {
productionSetup,
selectedSourceRef.input_slot
);

if (!result.ok) {
if (!result.value) {
setDeleteSourceStatus({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export function ConfigureOutputModal({
const t = useTranslate();

useEffect(() => {
if (preset.pipelines[0].multiview) {
if (!Array.isArray(preset.pipelines[0].multiview)) {
setMultiviews([preset.pipelines[0].multiview]);
if (preset.pipelines[0].multiviews) {
if (!Array.isArray(preset.pipelines[0].multiviews)) {
setMultiviews([preset.pipelines[0].multiviews]);
} else {
setMultiviews(preset.pipelines[0].multiview);
setMultiviews(preset.pipelines[0].multiviews);
}
}
}, [preset.pipelines]);
Expand All @@ -88,7 +88,7 @@ export function ConfigureOutputModal({

const clearInputs = () => {
setMultiviews(
preset.pipelines[0].multiview ? preset.pipelines[0].multiview : []
preset.pipelines[0].multiviews ? preset.pipelines[0].multiviews : []
);
setOutputStreams(defaultState(preset.pipelines));
onClose();
Expand Down Expand Up @@ -122,7 +122,7 @@ export function ConfigureOutputModal({
return;
}

presetToUpdate.pipelines[0].multiview = multiviews.map(
presetToUpdate.pipelines[0].multiviews = multiviews.map(
(singleMultiview) => {
return { ...singleMultiview };
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/startProduction/StartProductionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function StartProductionButton({
return;
}
let productionToStart: Production;
if (!production.production_settings.pipelines[0].multiview) {
if (!production.production_settings.pipelines[0].multiviews) {
if (!multiviewPresets || multiviewPresets.length === 0) {
toast.error(t('start_production_status.unexpected'));
return;
Expand All @@ -106,7 +106,7 @@ export function StartProductionButton({
),
{
...pipelineToUpdateMultiview,
multiview: [{ ...multiviewPresets[0], for_pipeline_idx: 0 }]
multiviews: [{ ...multiviewPresets[0], for_pipeline_idx: 0 }]
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/items/addSetupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export function addSetupItem(
source: SourceReference,
productionSetup: Production
) {
const multiview = productionSetup.production_settings.pipelines[0].multiview;
if (!multiview) return;
const multiviews =
productionSetup.production_settings.pipelines[0].multiviews;
if (!multiviews || multiviews.length === 0) return;
const updatedSetup = {
...productionSetup,
sources: [
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useDeleteStream(): CallbackHook<
const pipelineUUID =
production.production_settings.pipelines[0].pipeline_id;

const multiviews = production.production_settings.pipelines[0].multiview;
const multiviews = production.production_settings.pipelines[0].multiviews;
const multiviewViews = multiviews?.flatMap((singleMultiview) => {
return singleMultiview.layout.views;
});
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface PipelineSettings {
audio_mapping: string;
program_output_port: number; // deprecated but kept for backward compatibility
program_output: ProgramOutput[];
multiview?: MultiviewSettings[];
multiviews?: MultiviewSettings[];
interfaces: [
{
commit_rate: number;
Expand Down

0 comments on commit a1eb23a

Please sign in to comment.