diff options
author | Chocobozzz <me@florianbigard.com> | 2020-09-17 09:20:52 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (patch) | |
tree | 79304b0152b0a38d33b26e65d4acdad0da4032a7 /server/lib/hls.ts | |
parent | 110d463fece85e87a26aca48a6048ae0017a27b3 (diff) | |
download | PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.gz PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.zst PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.zip |
Live streaming implementation first step
Diffstat (limited to 'server/lib/hls.ts')
-rw-r--r-- | server/lib/hls.ts | 10 |
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 | ||
68 | async function updateSha256Segments (video: MVideoWithFile) { | 68 | async 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 | ||
104 | async function buildSha256Segment (segmentPath: string) { | ||
105 | const buf = await readFile(segmentPath) | ||
106 | return sha256(buf) | ||
107 | } | ||
108 | |||
104 | function getRangesFromPlaylist (playlistContent: string) { | 109 | function 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 | ||
188 | export { | 193 | export { |
189 | updateMasterHLSPlaylist, | 194 | updateMasterHLSPlaylist, |
190 | updateSha256Segments, | 195 | updateSha256VODSegments, |
196 | buildSha256Segment, | ||
191 | downloadPlaylistSegments, | 197 | downloadPlaylistSegments, |
192 | updateStreamingPlaylistsInfohashesIfNeeded | 198 | updateStreamingPlaylistsInfohashesIfNeeded |
193 | } | 199 | } |