Skip to content

Commit

Permalink
chore: rebase-main
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMaupin committed Nov 1, 2024
1 parent df7c9aa commit 80116ac
Show file tree
Hide file tree
Showing 74 changed files with 2,822 additions and 2,456 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
images: {
minimumCacheTTL: 0
},
reactStrictMode: false,
async headers() {
return [
{
Expand Down
35 changes: 14 additions & 21 deletions src/api/ateliereLive/pipelines/multiviews/multiviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { getAuthorizationHeader } from '../../utils/authheader';
import { createMultiview } from '../../utils/multiview';
import { getSourcesByIds } from '../../../manager/sources';
import { Log } from '../../../logger';
import { ProductionSettings } from '../../../../interfaces/production';
import {
Production,
ProductionSettings
} from '../../../../interfaces/production';
import { MultiviewSettings } from '../../../../interfaces/multiview';
import { LIVE_BASE_API_PATH } from '../../../../constants';

Expand Down Expand Up @@ -35,14 +38,10 @@ export async function getMultiviewsForPipeline(
}

export async function createMultiviewForPipeline(
productionSettings: ProductionSettings,
sourceRefs: SourceReference[]
production: Production
): Promise<ResourcesPipelineMultiviewResponse[]> {
const pipeline = productionSettings.pipelines.find((p) =>
p.multiviews ? p.multiviews?.length > 0 : undefined
);
const multiviewIndexArray = pipeline?.multiviews
? pipeline.multiviews.map((p) => p.for_pipeline_idx)
const multiviewIndexArray = production?.multiviews
? production.multiviews.map((p) => p.for_pipeline_idx)
: undefined;

const multiviewIndex = multiviewIndexArray?.find((p) => p !== undefined);
Expand All @@ -51,22 +50,17 @@ export async function createMultiviewForPipeline(
Log().error(`Did not find a specified pipeline in multiview settings`);
throw `Did not find a specified pipeline in multiview settings`;
}
if (
!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]}`
);
throw `Did not find any multiview settings in pipeline settings for: ${productionSettings.pipelines[multiviewIndex]}`;
if (!production.multiviews || production.multiviews?.length === 0) {
Log().error(`Did not find any multiviews for: ${production.name}`);
throw `Did not find any multiviews for: ${production.name}`;
}
const pipelineUUID =
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
productionSettings.pipelines[multiviewIndex].pipeline_id!;
production.pipelines[0].pipeline_id!;
const sources = await getSourcesByIds(
sourceRefs.map((ref) => (ref._id ? ref._id.toString() : ''))
production.sources.map((ref) => (ref._id ? ref._id.toString() : ''))
);
const sourceRefsWithLabels = sourceRefs.map((ref) => {
const sourceRefsWithLabels = production.sources.map((ref) => {
const refId = ref._id ? ref._id.toString() : '';
if (!ref.label) {
const source = sources.find((source) => source._id.toString() === refId);
Expand All @@ -76,8 +70,7 @@ export async function createMultiviewForPipeline(
});
Log().info(`Creating a multiview for pipeline '${pipelineUUID}' from preset`);

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

const createEachMultiviewer = multiviewsSettings.map(
async (singleMultiviewSettings) => {
Expand Down
33 changes: 25 additions & 8 deletions src/api/ateliereLive/pipelines/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,25 @@ export async function removePipelineStreams(pipeId: string) {
return { status: 200, results };
}

export async function createPipelineOutputs(pipeline: PipelineSettings) {
const outputs = pipeline.outputs;
export async function createPipelineOutputs(
pipeline: PipelineSettings,
outputsParam: PipelineOutput[]
) {
if (!pipeline.pipeline_id) return;
const pipelinesOutputs = await getPipelineOutputs(pipeline.pipeline_id).catch(
(error) => {
throw error.message;
}
);
const outputsWithStreams = outputsParam.filter(
(output) => output.streams?.length
);
const outputs = outputsWithStreams?.map((output, index) => {
return {
...output,
uuid: pipelinesOutputs[index]?.uuid
};
});
if (!outputs) return;
const startOutputStreamsPromises = outputs.map((o) => {
return startPipelineStream(
Expand All @@ -176,14 +193,14 @@ export async function createPipelineOutputs(pipeline: PipelineSettings) {
const startedOutputs = await Promise.all(startOutputStreamsPromises).catch(
(error) => {
Log().error(
`Failed to create outputs for pipeline '${pipeline.pipeline_name}/${pipeline.pipeline_id}'`,
`Failed to create outputs for pipeline '${pipeline.pipeline_readable_name}/${pipeline.pipeline_id}'`,
error
);
throw `Failed to create outputs for pipeline '${pipeline.pipeline_name}/${pipeline.pipeline_id}': ${error.message}`;
throw `Failed to create outputs for pipeline '${pipeline.pipeline_readable_name}/${pipeline.pipeline_id}': ${error.message}`;
}
);
Log().info(
`Outputs for pipeline '${pipeline.pipeline_name}/${pipeline.pipeline_id}' created`
`Outputs for pipeline '${pipeline.pipeline_readable_name}/${pipeline.pipeline_id}' created`
);
return startedOutputs;
}
Expand All @@ -198,14 +215,14 @@ export async function connectControlPanelToPipeline(
});

const productionControlPanels = controlPanels.filter((c) =>
control_connection.control_panel_name?.includes(c.name)
control_connection.control_panel_ids?.includes(c.uuid)
);

if (!productionControlPanels || productionControlPanels.length === 0) {
Log().error(
`Did not find control panel: ${control_connection.control_panel_name}`
`Did not find control panel: ${control_connection.control_panel_ids}`
);
throw `Did not find control panel: ${control_connection.control_panel_name}`;
throw `Did not find control panel: ${control_connection.control_panel_ids}`;
}

const pipelinesIds = pipelines.map((pipeline) => {
Expand Down
52 changes: 23 additions & 29 deletions src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '../../../../../types/ateliere-live';
import { LIVE_BASE_API_PATH } from '../../../../constants';
import { MultiviewSettings } from '../../../../interfaces/multiview';
import { Production } from '../../../../interfaces/production';
import {
HTMLSource,
MediaSource
Expand All @@ -17,6 +16,7 @@ import {
getMultiviewsForPipeline,
updateMultiviewForPipeline
} from '../multiviews/multiviews';
import { PipelineSettings } from '../../../../interfaces/pipeline';

export async function getPipelineHtmlSources(
pipelineUuid: string
Expand Down Expand Up @@ -44,20 +44,19 @@ export async function getPipelineHtmlSources(
}

export async function createPipelineHtmlSource(
production: Production,
pipelines: PipelineSettings[],
inputSlot: number,
data: HTMLSource,
source: SourceReference
) {
try {
const { production_settings } = production;
const htmlResults = [];

for (let i = 0; i < production_settings.pipelines.length; i++) {
for (let i = 0; i < pipelines.length; i++) {
const response = await fetch(
new URL(
LIVE_BASE_API_PATH +
`/pipelines/${production_settings.pipelines[i].pipeline_id}/renderingengine/html`,
`/pipelines/${pipelines[i].pipeline_id}/renderingengine/html`,
process.env.LIVE_URL
),
{
Expand Down Expand Up @@ -117,18 +116,16 @@ export async function createPipelineHtmlSource(
}

try {
if (!production.production_settings.pipelines[0].pipeline_id) {
Log().error(
`Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`
);
throw `Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`;
if (!pipelines[0].pipeline_id) {
Log().error(`Missing pipeline_id for: ${pipelines[0].pipeline_name}`);
throw `Missing pipeline_id for: ${pipelines[0].pipeline_name}`;
}
const multiviewsResponse = await getMultiviewsForPipeline(
production.production_settings.pipelines[0].pipeline_id
pipelines[0].pipeline_id
);

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

if (Array.isArray(multiviewArray)) {
Expand All @@ -146,9 +143,9 @@ export async function createPipelineHtmlSource(

if (multiviews.length === 0 || !multiviews) {
Log().error(
`No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`
`No multiview found for pipeline: ${pipelines[0].pipeline_id}`
);
throw `No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`;
throw `No multiview found for pipeline: ${pipelines[0].pipeline_id}`;
}

await Promise.all(
Expand Down Expand Up @@ -188,7 +185,7 @@ export async function createPipelineHtmlSource(
];

await updateMultiviewForPipeline(
production.production_settings.pipelines[0].pipeline_id!,
pipelines[0].pipeline_id!,
multiview.id,
updatedViews
);
Expand Down Expand Up @@ -303,20 +300,19 @@ export async function getPipelineMediaSources(
}

export async function createPipelineMediaSource(
production: Production,
pipelines: PipelineSettings[],
inputSlot: number,
data: MediaSource,
source: SourceReference
) {
try {
const { production_settings } = production;
const mediaResults = [];

for (let i = 0; i < production_settings.pipelines.length; i++) {
for (let i = 0; i < pipelines.length; i++) {
const response = await fetch(
new URL(
LIVE_BASE_API_PATH +
`/pipelines/${production_settings.pipelines[i].pipeline_id}/renderingengine/media`,
`/pipelines/${pipelines[i].pipeline_id}/renderingengine/media`,
process.env.LIVE_URL
),
{
Expand Down Expand Up @@ -373,18 +369,16 @@ export async function createPipelineMediaSource(
}

try {
if (!production.production_settings.pipelines[0].pipeline_id) {
Log().error(
`Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`
);
throw `Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`;
if (pipelines[0].pipeline_id) {
Log().error(`Missing pipeline_id for: ${pipelines[0].pipeline_name}`);
throw `Missing pipeline_id for: ${pipelines[0].pipeline_name}`;
}
const multiviewsResponse = await getMultiviewsForPipeline(
production.production_settings.pipelines[0].pipeline_id
pipelines[0].pipeline_id || ''
);

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

if (Array.isArray(multiviewArray)) {
Expand All @@ -402,9 +396,9 @@ export async function createPipelineMediaSource(

if (multiviews.length === 0 || !multiviews) {
Log().error(
`No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`
`No multiview found for pipeline: ${pipelines[0].pipeline_id}`
);
throw `No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`;
throw `No multiview found for pipeline: ${pipelines[0].pipeline_id}`;
}

await Promise.all(
Expand Down Expand Up @@ -444,7 +438,7 @@ export async function createPipelineMediaSource(
];

await updateMultiviewForPipeline(
production.production_settings.pipelines[0].pipeline_id!,
pipelines[0].pipeline_id!,
multiview.id,
updatedViews
);
Expand Down
30 changes: 15 additions & 15 deletions src/api/ateliereLive/pipelines/streams/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
SourceWithId
} from '../../../../interfaces/Source';
import { MultiviewSettings } from '../../../../interfaces/multiview';
import { PipelineStreamSettings } from '../../../../interfaces/pipeline';
import {
PipelineSettings,
PipelineStreamSettings
} from '../../../../interfaces/pipeline';
import { Production } from '../../../../interfaces/production';
import { Result } from '../../../../interfaces/result';
import { Log } from '../../../logger';
Expand Down Expand Up @@ -50,15 +53,14 @@ export async function getPipelineStreams(

export async function createStream(
source: SourceWithId,
production: Production,
pipelines: PipelineSettings[],
input_slot: number
): Promise<Result<AddSourceResult>> {
const sourceToPipelineStreams: SourceToPipelineStream[] = [];
try {
const allPipelines = await getPipelines();
const { production_settings } = production;
const pipelinesToUseCompact = allPipelines.filter((pipeline) =>
production_settings.pipelines.some((p) => p.pipeline_id === pipeline.uuid)
pipelines.some((p) => p.pipeline_id === pipeline.uuid)
);

const usedPorts = await getCurrentlyUsedPorts(
Expand Down Expand Up @@ -89,7 +91,7 @@ export async function createStream(

await initDedicatedPorts();

for (const pipeline of production_settings.pipelines) {
for (const pipeline of pipelines) {
const availablePorts = getAvailablePortsForIngest(
source.ingest_name,
usedPorts
Expand Down Expand Up @@ -208,18 +210,16 @@ export async function createStream(
}

try {
if (!production.production_settings.pipelines[0].pipeline_id) {
Log().error(
`Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`
);
throw `Missing pipeline_id for: ${production.production_settings.pipelines[0].pipeline_name}`;
if (!pipelines[0].pipeline_id) {
Log().error(`Missing pipeline_id for: ${pipelines[0].pipeline_name}`);
throw `Missing pipeline_id for: ${pipelines[0].pipeline_name}`;
}
const multiviewsResponse = await getMultiviewsForPipeline(
production.production_settings.pipelines[0].pipeline_id
pipelines[0].pipeline_id
);

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

if (Array.isArray(multiviewArray)) {
Expand All @@ -237,9 +237,9 @@ export async function createStream(

if (multiviews.length === 0) {
Log().error(
`No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`
`No multiview found for pipeline: ${pipelines[0].pipeline_id}`
);
throw `No multiview found for pipeline: ${production.production_settings.pipelines[0].pipeline_id}`;
throw `No multiview found for pipeline: ${pipelines[0].pipeline_id}`;
}
multiviews.map(async (multiview) => {
const views = multiview.layout.views;
Expand Down Expand Up @@ -278,7 +278,7 @@ export async function createStream(
];

await updateMultiviewForPipeline(
production.production_settings.pipelines[0].pipeline_id!,
pipelines[0].pipeline_id!,
multiview.id,
updatedViews
);
Expand Down
Loading

0 comments on commit 80116ac

Please sign in to comment.