aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/hls.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-26 16:44:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitb5b687550d8ef8beafdf706e45d6556fb5f4c876 (patch)
tree232412d463c78af1f7ab5797db5aecf1096d08da /server/lib/hls.ts
parentef680f68351ec10ab73a1131570a6d14ce14c195 (diff)
downloadPeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.gz
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.zst
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.zip
Add ability to save live replay
Diffstat (limited to 'server/lib/hls.ts')
-rw-r--r--server/lib/hls.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index e38a8788c..7aa152638 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -106,22 +106,6 @@ async function buildSha256Segment (segmentPath: string) {
106 return sha256(buf) 106 return sha256(buf)
107} 107}
108 108
109function getRangesFromPlaylist (playlistContent: string) {
110 const ranges: { offset: number, length: number }[] = []
111 const lines = playlistContent.split('\n')
112 const regex = /^#EXT-X-BYTERANGE:(\d+)@(\d+)$/
113
114 for (const line of lines) {
115 const captured = regex.exec(line)
116
117 if (captured) {
118 ranges.push({ length: parseInt(captured[1], 10), offset: parseInt(captured[2], 10) })
119 }
120 }
121
122 return ranges
123}
124
125function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, timeout: number) { 109function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, timeout: number) {
126 let timer 110 let timer
127 111
@@ -199,3 +183,19 @@ export {
199} 183}
200 184
201// --------------------------------------------------------------------------- 185// ---------------------------------------------------------------------------
186
187function getRangesFromPlaylist (playlistContent: string) {
188 const ranges: { offset: number, length: number }[] = []
189 const lines = playlistContent.split('\n')
190 const regex = /^#EXT-X-BYTERANGE:(\d+)@(\d+)$/
191
192 for (const line of lines) {
193 const captured = regex.exec(line)
194
195 if (captured) {
196 ranges.push({ length: parseInt(captured[1], 10), offset: parseInt(captured[2], 10) })
197 }
198 }
199
200 return ranges
201}