From 1b129ebd41198fab2bf0c2dd02df95ce55f6e893 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 21 Apr 2019 12:42:48 +0200 Subject: [PATCH] Add suffix parameter to getFileForRecording This allows different download types to support different file types --- common/src/main/java/ctbrec/Config.java | 4 ++-- .../main/java/ctbrec/recorder/download/MergedHlsDownload.java | 4 ++-- .../ctbrec/sites/jasmin/LiveJasminChunkedHttpDownload.java | 3 +-- .../java/ctbrec/sites/jasmin/LiveJasminWebSocketDownload.java | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/ctbrec/Config.java b/common/src/main/java/ctbrec/Config.java index cffa030c..3b40c44d 100644 --- a/common/src/main/java/ctbrec/Config.java +++ b/common/src/main/java/ctbrec/Config.java @@ -133,11 +133,11 @@ public class Config { return configDir; } - public File getFileForRecording(Model model) { + public File getFileForRecording(Model model, String suffix) { File dirForRecording = getDirForRecording(model); SimpleDateFormat sdf = new SimpleDateFormat(RECORDING_DATE_FORMAT); String startTime = sdf.format(new Date()); - File targetFile = new File(dirForRecording, model.getSanitizedNamed() + '_' + startTime + ".ts"); + File targetFile = new File(dirForRecording, model.getSanitizedNamed() + '_' + startTime + '.' + suffix); return targetFile; } diff --git a/common/src/main/java/ctbrec/recorder/download/MergedHlsDownload.java b/common/src/main/java/ctbrec/recorder/download/MergedHlsDownload.java index 5782cd80..0e468cb0 100644 --- a/common/src/main/java/ctbrec/recorder/download/MergedHlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/MergedHlsDownload.java @@ -130,7 +130,7 @@ public class MergedHlsDownload extends AbstractHlsDownload { super.startTime = Instant.now(); splitRecStartTime = ZonedDateTime.now(); super.model = model; - targetFile = Config.getInstance().getFileForRecording(model); + targetFile = Config.getInstance().getFileForRecording(model, "ts"); // let the world know, that we are recording now RecordingStateChangedEvent evt = new RecordingStateChangedEvent(getTarget(), RECORDING, model, getStartTime()); @@ -328,7 +328,7 @@ public class MergedHlsDownload extends AbstractHlsDownload { File lastTargetFile = targetFile; // switch to the next file - targetFile = Config.getInstance().getFileForRecording(model); + targetFile = Config.getInstance().getFileForRecording(model, "ts"); LOG.debug("Switching to file {}", targetFile.getAbsolutePath()); fileChannel = FileChannel.open(targetFile.toPath(), CREATE, WRITE); MTSSink sink = ByteChannelSink.builder().setByteChannel(fileChannel).build(); diff --git a/common/src/main/java/ctbrec/sites/jasmin/LiveJasminChunkedHttpDownload.java b/common/src/main/java/ctbrec/sites/jasmin/LiveJasminChunkedHttpDownload.java index cad15b60..c8d47fcc 100644 --- a/common/src/main/java/ctbrec/sites/jasmin/LiveJasminChunkedHttpDownload.java +++ b/common/src/main/java/ctbrec/sites/jasmin/LiveJasminChunkedHttpDownload.java @@ -57,8 +57,7 @@ public class LiveJasminChunkedHttpDownload implements Download { public void start(Model model, Config config) throws IOException { this.model = model; startTime = Instant.now(); - File _targetFile = config.getFileForRecording(model); - targetFile = new File(_targetFile.getAbsolutePath().replace(".ts", ".mp4")); + targetFile = config.getFileForRecording(model, "mp4"); getPerformerDetails(model.getName()); try { diff --git a/common/src/main/java/ctbrec/sites/jasmin/LiveJasminWebSocketDownload.java b/common/src/main/java/ctbrec/sites/jasmin/LiveJasminWebSocketDownload.java index 9728c6ff..d11267f5 100644 --- a/common/src/main/java/ctbrec/sites/jasmin/LiveJasminWebSocketDownload.java +++ b/common/src/main/java/ctbrec/sites/jasmin/LiveJasminWebSocketDownload.java @@ -59,8 +59,7 @@ public class LiveJasminWebSocketDownload implements Download { public void start(Model model, Config config) throws IOException { this.model = model; startTime = Instant.now(); - File _targetFile = config.getFileForRecording(model); - targetFile = new File(_targetFile.getAbsolutePath().replace(".ts", ".mp4")); + targetFile = config.getFileForRecording(model, "mp4"); getPerformerDetails(model.getName()); LOG.debug("appid: {}", applicationId);