Skip to content

Commit

Permalink
api,www: Create failed state for recordings (#2162)
Browse files Browse the repository at this point in the history
* api: Add failed state to recordings

Showing none is just misleading, let's show that only for stale streams

* www: Handle new failed state on frontend
  • Loading branch information
victorges authored May 6, 2024
1 parent f38cdd7 commit b19bf50
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
5 changes: 2 additions & 3 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type MultistreamTargetRef = MultistreamOptions["targets"][number];
export const USER_SESSION_TIMEOUT = 60 * 1000; // 1 min
export const ACTIVE_TIMEOUT = 90 * 1000; // 90 sec
const STALE_SESSION_TIMEOUT = 3 * 60 * 60 * 1000; // 3 hours
const MAX_WAIT_STREAM_ACTIVE = 2 * 60 * 1000; // 2 min

// Helper constant to be used in the PUT /pull API to make sure we delete fields
// from the stream that are not specified in the PUT payload.
Expand Down Expand Up @@ -524,7 +523,7 @@ export async function getRecordingFields(
if (session.version === "v2") {
const asset = await db.asset.getBySessionId(session.id);
if (!asset) {
return { recordingStatus: "waiting" };
return { recordingStatus: isStreamStale(session) ? "none" : "waiting" };
}
const assetWithPlayback = await withPlaybackUrls(config, ingest, asset);
const assetPhase = assetWithPlayback.status?.phase;
Expand All @@ -533,7 +532,7 @@ export async function getRecordingFields(
assetPhase == "ready"
? "ready"
: assetPhase == "failed"
? "none"
? "failed"
: "waiting",
recordingUrl: assetWithPlayback.playbackUrl,
mp4Url: assetWithPlayback.downloadUrl,
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ components:
enum:
- waiting
- ready
- failed
- none
recordingUrl:
type: string
Expand Down
11 changes: 8 additions & 3 deletions packages/www/components/Admin/Table-v2/cells/duration.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/** @jsxImportSource @emotion/react */
import { jsx } from "theme-ui";
import { Session } from "@livepeer.studio/api";
import { formatDuration, intervalToDuration } from "date-fns";
import { CellComponentProps, TableData } from "../types";

export type DurationCellProps = { duration: number; status?: string };
export type DurationCellProps = {
duration: number;
status?: Session["recordingStatus"];
};

const DurationCell = <D extends TableData>({
cell,
}: CellComponentProps<D, DurationCellProps>) => {
if (cell.value.status === "waiting") {
return "In progress";
} else if (cell.value.status === "failed") {
return "Failed";
}
if (cell.value.duration === 0) {
if (cell.value.duration === 0 || cell.value.status !== "ready") {
return "n/a";
}
try {
Expand Down
12 changes: 9 additions & 3 deletions packages/www/components/Table/cells/duration.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { Session } from "@livepeer.studio/api";
import { formatDuration, intervalToDuration } from "date-fns";
import { CellComponentProps, TableData } from "../types";

export type DurationCellProps = {
sourceSegmentsDuration: number;
status?: string;
status?: Session["recordingStatus"];
};

const DurationCell = <D extends TableData>({
cell,
}: CellComponentProps<D, DurationCellProps>) => {
if (cell.value.status === "waiting") {
return "In progress";
} else if (cell.value.status === "failed") {
return "Failed";
}
if (cell.value.sourceSegmentsDuration === 0) {
return "—";
if (
cell.value.sourceSegmentsDuration === 0 ||
cell.value.status !== "ready"
) {
return "n/a";
}
try {
const durationMins = Math.round(cell.value.sourceSegmentsDuration / 60);
Expand Down

0 comments on commit b19bf50

Please sign in to comment.