From ec71dc3c6d54cc2f31b88a7a6fe7d243d866fe38 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Tue, 22 Dec 2020 15:15:21 +0100 Subject: [PATCH] Remove dead download code --- .../download/hls/MergedFfmpegHlsDownload.java | 37 +++++-------------- .../sites/showup/ShowupMergedDownload.java | 6 +-- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/common/src/main/java/ctbrec/recorder/download/hls/MergedFfmpegHlsDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/MergedFfmpegHlsDownload.java index 00713d63..ddc04067 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/MergedFfmpegHlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/MergedFfmpegHlsDownload.java @@ -101,7 +101,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload { throw new ProcessExitedUncleanException("Couldn't spawn FFmpeg"); } else { LOG.debug("Starting to download segments"); - startDownloadLoop(segments, true); + startDownloadLoop(segments); ffmpegThread.join(); LOG.debug("FFmpeg thread terminated"); } @@ -168,10 +168,10 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload { return OS.getFFmpegCommand(argsPlusFile); } - protected void startDownloadLoop(String segmentPlaylistUri, boolean livestreamDownload) throws IOException, ParseException, PlaylistException { + protected void startDownloadLoop(String segmentPlaylistUri) throws IOException, ParseException, PlaylistException { while (running) { try { - downloadSegments(segmentPlaylistUri, livestreamDownload); + downloadSegments(segmentPlaylistUri); } catch (HttpException e) { logHttpException(e); running = false; @@ -186,17 +186,13 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload { ffmpegThread.interrupt(); } - private void downloadSegments(String segmentPlaylistUri, boolean livestreamDownload) throws IOException, ParseException, PlaylistException, ExecutionException { + private void downloadSegments(String segmentPlaylistUri) throws IOException, ParseException, PlaylistException, ExecutionException { SegmentPlaylist lsp = getNextSegments(segmentPlaylistUri); emptyPlaylistCheck(lsp); // download new segments long downloadStart = System.currentTimeMillis(); - if (livestreamDownload) { - downloadNewSegments(lsp, nextSegment); - } else { - downloadRecording(lsp); - } + downloadNewSegments(lsp, nextSegment); long downloadTookMillis = System.currentTimeMillis() - downloadStart; // download segments, which might have been skipped @@ -205,17 +201,13 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload { downloadTookMillis, lsp.totalDuration); } - if (livestreamDownload) { - splitRecordingIfNecessary(); + splitRecordingIfNecessary(); - // wait some time until requesting the segment playlist again to not hammer the server - waitForNewSegments(lsp, lastSegment, downloadTookMillis); + // wait some time until requesting the segment playlist again to not hammer the server + waitForNewSegments(lsp, lastSegment, downloadTookMillis); - lastSegment = lsp.seq; - nextSegment = lastSegment + lsp.segments.size(); - } else { - running = false; - } + lastSegment = lsp.seq; + nextSegment = lastSegment + lsp.segments.size(); } private void logHttpException(HttpException e) { @@ -234,15 +226,6 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload { } } - private void downloadRecording(SegmentPlaylist lsp) throws IOException { - for (String segment : lsp.segments) { - URL segmentUrl = new URL(segment); - SegmentDownload segmentDownload = new SegmentDownload(lsp, segmentUrl, client); - byte[] segmentData = segmentDownload.call(); - writeSegment(segmentData); - } - } - private void downloadNewSegments(SegmentPlaylist lsp, int nextSegment) throws ExecutionException, IOException { int skip = nextSegment - lsp.seq; diff --git a/common/src/main/java/ctbrec/sites/showup/ShowupMergedDownload.java b/common/src/main/java/ctbrec/sites/showup/ShowupMergedDownload.java index 28537c45..920f51e1 100644 --- a/common/src/main/java/ctbrec/sites/showup/ShowupMergedDownload.java +++ b/common/src/main/java/ctbrec/sites/showup/ShowupMergedDownload.java @@ -28,7 +28,7 @@ public class ShowupMergedDownload extends MergedFfmpegHlsDownload { } @Override - protected void startDownloadLoop(String segmentPlaylistUri, boolean livestreamDownload) throws IOException, ParseException, PlaylistException { + protected void startDownloadLoop(String segmentPlaylistUri) throws IOException, ParseException, PlaylistException { try { SegmentPlaylist lsp = getNextSegments(segmentPlaylistUri); emptyPlaylistCheck(lsp); @@ -48,9 +48,7 @@ public class ShowupMergedDownload extends MergedFfmpegHlsDownload { BandwidthMeter.add(length); writeSegment(buffer, 0, length); keepGoing = running && !Thread.interrupted() && model.isOnline(true); - if (livestreamDownload) { - splitRecordingIfNecessary(); - } + splitRecordingIfNecessary(); } } else { throw new HttpException(response.code(), response.message());