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.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index 76380b1f2..e38a8788c 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -65,7 +65,7 @@ async function updateMasterHLSPlaylist (video: MVideoWithFile) {
65 await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n') 65 await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n')
66} 66}
67 67
68async function updateSha256Segments (video: MVideoWithFile) { 68async function updateSha256VODSegments (video: MVideoWithFile) {
69 const json: { [filename: string]: { [range: string]: string } } = {} 69 const json: { [filename: string]: { [range: string]: string } } = {}
70 70
71 const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) 71 const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
@@ -101,6 +101,11 @@ async function updateSha256Segments (video: MVideoWithFile) {
101 await outputJSON(outputPath, json) 101 await outputJSON(outputPath, json)
102} 102}
103 103
104async function buildSha256Segment (segmentPath: string) {
105 const buf = await readFile(segmentPath)
106 return sha256(buf)
107}
108
104function getRangesFromPlaylist (playlistContent: string) { 109function getRangesFromPlaylist (playlistContent: string) {
105 const ranges: { offset: number, length: number }[] = [] 110 const ranges: { offset: number, length: number }[] = []
106 const lines = playlistContent.split('\n') 111 const lines = playlistContent.split('\n')
@@ -187,7 +192,8 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string,
187 192
188export { 193export {
189 updateMasterHLSPlaylist, 194 updateMasterHLSPlaylist,
190 updateSha256Segments, 195 updateSha256VODSegments,
196 buildSha256Segment,
191 downloadPlaylistSegments, 197 downloadPlaylistSegments,
192 updateStreamingPlaylistsInfohashesIfNeeded 198 updateStreamingPlaylistsInfohashesIfNeeded
193} 199}