diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-08 10:25:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 04aed76711909507e74905bde3a7fa024d3585c9 (patch) | |
tree | da93912bb9331feda40f597da3fea7dc24970d66 /shared/extra-utils | |
parent | d897210c2db1ca2acc1e7b28a13127647ab2222c (diff) | |
download | PeerTube-04aed76711909507e74905bde3a7fa024d3585c9.tar.gz PeerTube-04aed76711909507e74905bde3a7fa024d3585c9.tar.zst PeerTube-04aed76711909507e74905bde3a7fa024d3585c9.zip |
Shorter live methods
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/videos/live-command.ts | 30 | ||||
-rw-r--r-- | shared/extra-utils/videos/live.ts | 2 |
2 files changed, 16 insertions, 16 deletions
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index 55811b8ba..e36c632ee 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -14,7 +14,7 @@ import { getVideoWithToken } from './videos' | |||
14 | 14 | ||
15 | export class LiveCommand extends AbstractCommand { | 15 | export class LiveCommand extends AbstractCommand { |
16 | 16 | ||
17 | getLive (options: OverrideCommandOptions & { | 17 | get (options: OverrideCommandOptions & { |
18 | videoId: number | string | 18 | videoId: number | string |
19 | }) { | 19 | }) { |
20 | const path = '/api/v1/videos/live' | 20 | const path = '/api/v1/videos/live' |
@@ -27,7 +27,7 @@ export class LiveCommand extends AbstractCommand { | |||
27 | }) | 27 | }) |
28 | } | 28 | } |
29 | 29 | ||
30 | updateLive (options: OverrideCommandOptions & { | 30 | update (options: OverrideCommandOptions & { |
31 | videoId: number | string | 31 | videoId: number | string |
32 | fields: LiveVideoUpdate | 32 | fields: LiveVideoUpdate |
33 | }) { | 33 | }) { |
@@ -43,7 +43,7 @@ export class LiveCommand extends AbstractCommand { | |||
43 | }) | 43 | }) |
44 | } | 44 | } |
45 | 45 | ||
46 | async createLive (options: OverrideCommandOptions & { | 46 | async create (options: OverrideCommandOptions & { |
47 | fields: LiveVideoCreate | 47 | fields: LiveVideoCreate |
48 | }) { | 48 | }) { |
49 | const { fields } = options | 49 | const { fields } = options |
@@ -70,12 +70,12 @@ export class LiveCommand extends AbstractCommand { | |||
70 | fixtureName?: string | 70 | fixtureName?: string |
71 | }) { | 71 | }) { |
72 | const { videoId, fixtureName } = options | 72 | const { videoId, fixtureName } = options |
73 | const videoLive = await this.getLive({ videoId }) | 73 | const videoLive = await this.get({ videoId }) |
74 | 74 | ||
75 | return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey, fixtureName) | 75 | return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey, fixtureName) |
76 | } | 76 | } |
77 | 77 | ||
78 | async runAndTestFfmpegStreamError (options: OverrideCommandOptions & { | 78 | async runAndTestStreamError (options: OverrideCommandOptions & { |
79 | videoId: number | string | 79 | videoId: number | string |
80 | shouldHaveError: boolean | 80 | shouldHaveError: boolean |
81 | }) { | 81 | }) { |
@@ -84,28 +84,28 @@ export class LiveCommand extends AbstractCommand { | |||
84 | return testFfmpegStreamError(command, options.shouldHaveError) | 84 | return testFfmpegStreamError(command, options.shouldHaveError) |
85 | } | 85 | } |
86 | 86 | ||
87 | waitUntilLivePublished (options: OverrideCommandOptions & { | 87 | waitUntilPublished (options: OverrideCommandOptions & { |
88 | videoId: number | string | 88 | videoId: number | string |
89 | }) { | 89 | }) { |
90 | const { videoId } = options | 90 | const { videoId } = options |
91 | return this.waitUntilLiveState({ videoId, state: VideoState.PUBLISHED }) | 91 | return this.waitUntilState({ videoId, state: VideoState.PUBLISHED }) |
92 | } | 92 | } |
93 | 93 | ||
94 | waitUntilLiveWaiting (options: OverrideCommandOptions & { | 94 | waitUntilWaiting (options: OverrideCommandOptions & { |
95 | videoId: number | string | 95 | videoId: number | string |
96 | }) { | 96 | }) { |
97 | const { videoId } = options | 97 | const { videoId } = options |
98 | return this.waitUntilLiveState({ videoId, state: VideoState.WAITING_FOR_LIVE }) | 98 | return this.waitUntilState({ videoId, state: VideoState.WAITING_FOR_LIVE }) |
99 | } | 99 | } |
100 | 100 | ||
101 | waitUntilLiveEnded (options: OverrideCommandOptions & { | 101 | waitUntilEnded (options: OverrideCommandOptions & { |
102 | videoId: number | string | 102 | videoId: number | string |
103 | }) { | 103 | }) { |
104 | const { videoId } = options | 104 | const { videoId } = options |
105 | return this.waitUntilLiveState({ videoId, state: VideoState.LIVE_ENDED }) | 105 | return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED }) |
106 | } | 106 | } |
107 | 107 | ||
108 | waitUntilLiveSegmentGeneration (options: OverrideCommandOptions & { | 108 | waitUntilSegmentGeneration (options: OverrideCommandOptions & { |
109 | videoUUID: string | 109 | videoUUID: string |
110 | resolution: number | 110 | resolution: number |
111 | segment: number | 111 | segment: number |
@@ -116,7 +116,7 @@ export class LiveCommand extends AbstractCommand { | |||
116 | return waitUntilLog(this.server, `${videoUUID}/${segmentName}`, 2, false) | 116 | return waitUntilLog(this.server, `${videoUUID}/${segmentName}`, 2, false) |
117 | } | 117 | } |
118 | 118 | ||
119 | async waitUntilLiveSaved (options: OverrideCommandOptions & { | 119 | async waitUntilSaved (options: OverrideCommandOptions & { |
120 | videoId: number | string | 120 | videoId: number | string |
121 | }) { | 121 | }) { |
122 | let video: VideoDetails | 122 | let video: VideoDetails |
@@ -129,7 +129,7 @@ export class LiveCommand extends AbstractCommand { | |||
129 | } while (video.isLive === true && video.state.id !== VideoState.PUBLISHED) | 129 | } while (video.isLive === true && video.state.id !== VideoState.PUBLISHED) |
130 | } | 130 | } |
131 | 131 | ||
132 | async getPlaylistsCount (options: OverrideCommandOptions & { | 132 | async countPlaylists (options: OverrideCommandOptions & { |
133 | videoUUID: string | 133 | videoUUID: string |
134 | }) { | 134 | }) { |
135 | const basePath = buildServerDirectory(this.server, 'streaming-playlists') | 135 | const basePath = buildServerDirectory(this.server, 'streaming-playlists') |
@@ -140,7 +140,7 @@ export class LiveCommand extends AbstractCommand { | |||
140 | return files.filter(f => f.endsWith('.m3u8')).length | 140 | return files.filter(f => f.endsWith('.m3u8')).length |
141 | } | 141 | } |
142 | 142 | ||
143 | private async waitUntilLiveState (options: OverrideCommandOptions & { | 143 | private async waitUntilState (options: OverrideCommandOptions & { |
144 | videoId: number | string | 144 | videoId: number | string |
145 | state: VideoState | 145 | state: VideoState |
146 | }) { | 146 | }) { |
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts index 285a39c7e..92cb9104c 100644 --- a/shared/extra-utils/videos/live.ts +++ b/shared/extra-utils/videos/live.ts | |||
@@ -72,7 +72,7 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) { | |||
72 | 72 | ||
73 | async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoId: string) { | 73 | async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoId: string) { |
74 | for (const server of servers) { | 74 | for (const server of servers) { |
75 | await server.liveCommand.waitUntilLivePublished({ videoId }) | 75 | await server.liveCommand.waitUntilPublished({ videoId }) |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||