Remove dead download code

This commit is contained in:
0xb00bface 2020-12-22 15:15:21 +01:00
parent 492ef74459
commit ec71dc3c6d
2 changed files with 12 additions and 31 deletions

View File

@ -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;

View File

@ -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());