Skip to content

Commit 0040d16

Browse files
authored
feat: Add playout-limit support to interstitials (#147)
* Initial POC to add playoutLimit in interstitials * Fixed getStaticDateRagnges when duration is undefined * Added blank line
1 parent 99ec221 commit 0040d16

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

packages/stitcher/src/interstitials.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export function getStaticDateRanges(session: Session, isLive: boolean) {
2222
clientAttributes["RESUME-OFFSET"] = 0;
2323
}
2424

25+
if (interstitial.duration) {
26+
clientAttributes["PLAYOUT-LIMIT"] = interstitial.duration;
27+
}
28+
2529
const cue: string[] = ["ONCE"];
2630
if (startDate.equals(session.startTime)) {
2731
cue.push("PRE");

packages/stitcher/src/routes/session.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const sessionRoutes = new Elysia()
3939
t.Array(
4040
t.Object({
4141
time: t.Union([t.Number(), t.String()]),
42+
duration: t.Optional(t.Number()),
4243
assets: t.Optional(
4344
t.Array(
4445
t.Object({

packages/stitcher/src/session.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface Session {
2020

2121
interface SessionInterstitial {
2222
time: number | string;
23+
duration?: number;
2324
assets?: {
2425
uri: string;
2526
kind?: "ad" | "bumper";
@@ -85,14 +86,15 @@ function mapSessionInterstitials(
8586
interstitials: SessionInterstitial[],
8687
) {
8788
return interstitials.map<Interstitial>((item) => {
88-
const { time, assets, ...rest } = item;
89+
const { time, duration, assets, ...rest } = item;
8990
const dateTime =
9091
typeof time === "string"
9192
? DateTime.fromISO(time)
9293
: startTime.plus({ seconds: time });
9394

9495
return {
9596
dateTime,
97+
duration,
9698
assets: assets?.map((asset) => {
9799
const { uri, ...rest } = asset;
98100
return { url: resolveUri(uri), ...rest };

packages/stitcher/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface InterstitialAssetList {
1717

1818
export interface Interstitial {
1919
dateTime: DateTime;
20+
duration?: number;
2021
assets?: InterstitialAsset[];
2122
vast?: InterstitialVast;
2223
assetList?: InterstitialAssetList;

0 commit comments

Comments
 (0)