File size: 2,147 Bytes
6f9647d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bb097e
6f9647d
 
 
 
 
 
 
 
 
 
 
 
 
8bb097e
6f9647d
 
 
 
 
 
 
 
 
 
 
 
 
 
8bb097e
6f9647d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bb097e
6f9647d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Static, Type as t } from "@sinclair/typebox";

const playback = t.Object(
  {
    url: t.String({
      minLength: 1,
      errorMessage: "Invalid playback url"
    }),
    headers: t.Optional(
      t.Object(
        {},
        {
          additionalProperties: true,
          errorMessage: "Invalid playback headers"
        }
      )
    ),
    type: t.Union([t.Literal("hls"), t.Literal("video")], {
      errorMessage: "Invalid playback type: expected HLS or VIDEO"
    }),
    protocol: t.Union([t.Literal("http"), t.Literal("local")], {
      errorMessage: "Invalid playback type: expected HTTP or LOCAL"
    }),
    picture_quality: t.Optional(
      t.String({
        minLength: 0,
        errorMessage: "Invalid picture quality"
      })
    )
  },
  { errorMessage: "Invalid playback data" }
);

export type T_playback = Static<typeof playback>;

const live = t.Object(
  {
    sbe_id: t.Optional(
      t.String({
        minLength: 0,
        errorMessage: "Invalid sbe id"
      })
    ),
    delivery_mode: t.Union([t.Literal("download"), t.Literal("stream")], {
      errorMessage: "Invalid delivery mode, must be one of: download, stream"
    }),
    delivery_format: t.Union(
      [t.Literal("mp4"), t.Literal("mkv"), t.Literal("ts")],
      {
        errorMessage: "Invalid output format, must be one of: mp4, mkv, ts"
      }
    ),
    delivery_name: t.Optional(
      t.String({
        minLength: 0,
        errorMessage: "Invalid delivery name"
      })
    ),
    subtitles: t.Optional(
      t.Array(
        t.Object(
          {
            lang: t.String(),
            url: t.String(),
            title: t.Optional(t.String()),
            default: t.Optional(t.Boolean())
          },
          { additionalProperties: true }
        ),
        { errorMessage: "Invalid subtitle data" }
      )
    ),
    progress_update_endpoint: t.Optional(
      t.String({
        minLength: 0,
        errorMessage: "Invalid progress update endpoint"
      })
    )
  },
  { errorMessage: "Invalid live data" }
);

export type T_live = Static<typeof live>;

export const NS_validator_v2 = {
  playback,
  live
};