aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/hls.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/hls.ts')
-rw-r--r--server/lib/hls.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index 05136c21c..943721dd7 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -12,6 +12,7 @@ import { VideoFileModel } from '../models/video/video-file'
12import { CONFIG } from '../initializers/config' 12import { CONFIG } from '../initializers/config'
13import { sequelizeTypescript } from '../initializers/database' 13import { sequelizeTypescript } from '../initializers/database'
14import { MVideoWithFile } from '@server/typings/models' 14import { MVideoWithFile } from '@server/typings/models'
15import { getVideoFilename, getVideoFilePath } from './video-paths'
15 16
16async function updateStreamingPlaylistsInfohashesIfNeeded () { 17async function updateStreamingPlaylistsInfohashesIfNeeded () {
17 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() 18 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion()
@@ -32,13 +33,14 @@ async function updateMasterHLSPlaylist (video: MVideoWithFile) {
32 const directory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) 33 const directory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
33 const masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ] 34 const masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ]
34 const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) 35 const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename())
36 const streamingPlaylist = video.getHLSPlaylist()
35 37
36 for (const file of video.VideoFiles) { 38 for (const file of streamingPlaylist.VideoFiles) {
37 // If we did not generated a playlist for this resolution, skip 39 // If we did not generated a playlist for this resolution, skip
38 const filePlaylistPath = join(directory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution)) 40 const filePlaylistPath = join(directory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution))
39 if (await pathExists(filePlaylistPath) === false) continue 41 if (await pathExists(filePlaylistPath) === false) continue
40 42
41 const videoFilePath = video.getVideoFilePath(file) 43 const videoFilePath = getVideoFilePath(streamingPlaylist, file)
42 44
43 const size = await getVideoFileSize(videoFilePath) 45 const size = await getVideoFileSize(videoFilePath)
44 46
@@ -59,12 +61,13 @@ async function updateSha256Segments (video: MVideoWithFile) {
59 const json: { [filename: string]: { [range: string]: string } } = {} 61 const json: { [filename: string]: { [range: string]: string } } = {}
60 62
61 const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) 63 const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
64 const hlsPlaylist = video.getHLSPlaylist()
62 65
63 // For all the resolutions available for this video 66 // For all the resolutions available for this video
64 for (const file of video.VideoFiles) { 67 for (const file of hlsPlaylist.VideoFiles) {
65 const rangeHashes: { [range: string]: string } = {} 68 const rangeHashes: { [range: string]: string } = {}
66 69
67 const videoPath = join(playlistDirectory, VideoStreamingPlaylistModel.getHlsVideoName(video.uuid, file.resolution)) 70 const videoPath = getVideoFilePath(hlsPlaylist, file)
68 const playlistPath = join(playlistDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution)) 71 const playlistPath = join(playlistDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution))
69 72
70 // Maybe the playlist is not generated for this resolution yet 73 // Maybe the playlist is not generated for this resolution yet
@@ -82,7 +85,7 @@ async function updateSha256Segments (video: MVideoWithFile) {
82 } 85 }
83 await close(fd) 86 await close(fd)
84 87
85 const videoFilename = VideoStreamingPlaylistModel.getHlsVideoName(video.uuid, file.resolution) 88 const videoFilename = getVideoFilename(hlsPlaylist, file)
86 json[videoFilename] = rangeHashes 89 json[videoFilename] = rangeHashes
87 } 90 }
88 91