diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-03 11:38:07 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-03 14:49:15 +0200 |
commit | 26e3e98ff0e222a9fb9226938ac6902af77921bd (patch) | |
tree | 73d1c6f2524e380862d3365f12043fc319d40841 /shared | |
parent | 86c5229b4d726202378ef46854383bcafca22310 (diff) | |
download | PeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.tar.gz PeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.tar.zst PeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.zip |
Support live session in server
Diffstat (limited to 'shared')
-rw-r--r-- | shared/models/server/job.model.ts | 1 | ||||
-rw-r--r-- | shared/models/videos/live/index.ts | 2 | ||||
-rw-r--r-- | shared/models/videos/live/live-video-error.enum.ts | 7 | ||||
-rw-r--r-- | shared/models/videos/live/live-video-session.model.ts | 16 | ||||
-rw-r--r-- | shared/server-commands/videos/live-command.ts | 48 |
5 files changed, 73 insertions, 1 deletions
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index 9370cf011..bc5ffa570 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -160,6 +160,7 @@ export type VideoTranscodingPayload = | |||
160 | export interface VideoLiveEndingPayload { | 160 | export interface VideoLiveEndingPayload { |
161 | videoId: number | 161 | videoId: number |
162 | publishedAt: string | 162 | publishedAt: string |
163 | liveSessionId: number | ||
163 | 164 | ||
164 | replayDirectory?: string | 165 | replayDirectory?: string |
165 | } | 166 | } |
diff --git a/shared/models/videos/live/index.ts b/shared/models/videos/live/index.ts index 68f32092a..07b59fe2c 100644 --- a/shared/models/videos/live/index.ts +++ b/shared/models/videos/live/index.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | export * from './live-video-create.model' | 1 | export * from './live-video-create.model' |
2 | export * from './live-video-error.enum' | ||
2 | export * from './live-video-event-payload.model' | 3 | export * from './live-video-event-payload.model' |
3 | export * from './live-video-event.type' | 4 | export * from './live-video-event.type' |
4 | export * from './live-video-latency-mode.enum' | 5 | export * from './live-video-latency-mode.enum' |
6 | export * from './live-video-session.model' | ||
5 | export * from './live-video-update.model' | 7 | export * from './live-video-update.model' |
6 | export * from './live-video.model' | 8 | export * from './live-video.model' |
diff --git a/shared/models/videos/live/live-video-error.enum.ts b/shared/models/videos/live/live-video-error.enum.ts new file mode 100644 index 000000000..3a8e4afa0 --- /dev/null +++ b/shared/models/videos/live/live-video-error.enum.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export const enum LiveVideoError { | ||
2 | BAD_SOCKET_HEALTH = 1, | ||
3 | DURATION_EXCEEDED = 2, | ||
4 | QUOTA_EXCEEDED = 3, | ||
5 | FFMPEG_ERROR = 4, | ||
6 | BLACKLISTED = 5 | ||
7 | } | ||
diff --git a/shared/models/videos/live/live-video-session.model.ts b/shared/models/videos/live/live-video-session.model.ts new file mode 100644 index 000000000..7ff6afbe5 --- /dev/null +++ b/shared/models/videos/live/live-video-session.model.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | import { LiveVideoError } from './live-video-error.enum' | ||
2 | |||
3 | export interface LiveVideoSession { | ||
4 | id: number | ||
5 | |||
6 | startDate: string | ||
7 | endDate: string | ||
8 | |||
9 | error: LiveVideoError | ||
10 | |||
11 | replayVideo: { | ||
12 | id: number | ||
13 | uuid: string | ||
14 | shortUUID: string | ||
15 | } | ||
16 | } | ||
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts index c24c7a5fc..2ff65881b 100644 --- a/shared/server-commands/videos/live-command.ts +++ b/shared/server-commands/videos/live-command.ts | |||
@@ -4,7 +4,17 @@ import { readdir } from 'fs-extra' | |||
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { wait } from '@shared/core-utils' | 6 | import { wait } from '@shared/core-utils' |
7 | import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' | 7 | import { |
8 | HttpStatusCode, | ||
9 | LiveVideo, | ||
10 | LiveVideoCreate, | ||
11 | LiveVideoSession, | ||
12 | LiveVideoUpdate, | ||
13 | ResultList, | ||
14 | VideoCreateResult, | ||
15 | VideoDetails, | ||
16 | VideoState | ||
17 | } from '@shared/models' | ||
8 | import { unwrapBody } from '../requests' | 18 | import { unwrapBody } from '../requests' |
9 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 19 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
10 | import { sendRTMPStream, testFfmpegStreamError } from './live' | 20 | import { sendRTMPStream, testFfmpegStreamError } from './live' |
@@ -25,6 +35,42 @@ export class LiveCommand extends AbstractCommand { | |||
25 | }) | 35 | }) |
26 | } | 36 | } |
27 | 37 | ||
38 | listSessions (options: OverrideCommandOptions & { | ||
39 | videoId: number | string | ||
40 | }) { | ||
41 | const path = `/api/v1/videos/live/${options.videoId}/sessions` | ||
42 | |||
43 | return this.getRequestBody<ResultList<LiveVideoSession>>({ | ||
44 | ...options, | ||
45 | |||
46 | path, | ||
47 | implicitToken: true, | ||
48 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
49 | }) | ||
50 | } | ||
51 | |||
52 | async findLatestSession (options: OverrideCommandOptions & { | ||
53 | videoId: number | string | ||
54 | }) { | ||
55 | const { data: sessions } = await this.listSessions(options) | ||
56 | |||
57 | return sessions[sessions.length - 1] | ||
58 | } | ||
59 | |||
60 | getReplaySession (options: OverrideCommandOptions & { | ||
61 | videoId: number | string | ||
62 | }) { | ||
63 | const path = `/api/v1/videos/${options.videoId}/live-session` | ||
64 | |||
65 | return this.getRequestBody<LiveVideoSession>({ | ||
66 | ...options, | ||
67 | |||
68 | path, | ||
69 | implicitToken: true, | ||
70 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
71 | }) | ||
72 | } | ||
73 | |||
28 | update (options: OverrideCommandOptions & { | 74 | update (options: OverrideCommandOptions & { |
29 | videoId: number | string | 75 | videoId: number | string |
30 | fields: LiveVideoUpdate | 76 | fields: LiveVideoUpdate |