diff --git a/core/src/main/java/com/automation/remarks/video/RecorderFactory.java b/core/src/main/java/com/automation/remarks/video/RecorderFactory.java index bc2bb52..2b9e18e 100644 --- a/core/src/main/java/com/automation/remarks/video/RecorderFactory.java +++ b/core/src/main/java/com/automation/remarks/video/RecorderFactory.java @@ -2,6 +2,7 @@ import com.automation.remarks.video.enums.RecorderType; import com.automation.remarks.video.recorder.IVideoRecorder; +import com.automation.remarks.video.recorder.custom.CustomRecorder; import com.automation.remarks.video.recorder.ffmpeg.LinuxFFmpegRecorder; import com.automation.remarks.video.recorder.ffmpeg.MacFFmpegRecorder; import com.automation.remarks.video.recorder.ffmpeg.WindowsFFmpegRecorder; @@ -14,14 +15,19 @@ public class RecorderFactory { public static IVideoRecorder getRecorder(RecorderType recorderType) { - if (recorderType.equals(RecorderType.FFMPEG)) { - if (SystemUtils.IS_OS_WINDOWS) { - return new WindowsFFmpegRecorder(); - } else if (SystemUtils.IS_OS_MAC) { - return new MacFFmpegRecorder(); - } - return new LinuxFFmpegRecorder(); + switch (recorderType) { + case CUSTOM: + return new CustomRecorder(); + case FFMPEG: + if (SystemUtils.IS_OS_WINDOWS) { + return new WindowsFFmpegRecorder(); + } else if (SystemUtils.IS_OS_MAC) { + return new MacFFmpegRecorder(); + } + return new LinuxFFmpegRecorder(); + case MONTE: + default: + return new MonteRecorder(); } - return new MonteRecorder(); } } diff --git a/core/src/main/java/com/automation/remarks/video/enums/RecorderType.java b/core/src/main/java/com/automation/remarks/video/enums/RecorderType.java index d256faa..b97b322 100644 --- a/core/src/main/java/com/automation/remarks/video/enums/RecorderType.java +++ b/core/src/main/java/com/automation/remarks/video/enums/RecorderType.java @@ -5,5 +5,6 @@ */ public enum RecorderType { MONTE, - FFMPEG + FFMPEG, + CUSTOM } diff --git a/core/src/main/java/com/automation/remarks/video/recorder/VideoConfiguration.java b/core/src/main/java/com/automation/remarks/video/recorder/VideoConfiguration.java index 7a25654..db6f06e 100644 --- a/core/src/main/java/com/automation/remarks/video/recorder/VideoConfiguration.java +++ b/core/src/main/java/com/automation/remarks/video/recorder/VideoConfiguration.java @@ -49,6 +49,9 @@ default String folder() { @DefaultValue("MONTE") RecorderType recorderType(); + @Key("recorder.class") + String recorderClass(); + @Key("video.save.mode") @DefaultValue("FAILED_ONLY") VideoSaveMode saveMode(); diff --git a/core/src/main/java/com/automation/remarks/video/recorder/custom/CustomRecorder.java b/core/src/main/java/com/automation/remarks/video/recorder/custom/CustomRecorder.java new file mode 100644 index 0000000..9587d5a --- /dev/null +++ b/core/src/main/java/com/automation/remarks/video/recorder/custom/CustomRecorder.java @@ -0,0 +1,28 @@ +package com.automation.remarks.video.recorder.custom; + +import com.automation.remarks.video.recorder.VideoRecorder; + +import java.io.File; + +public class CustomRecorder extends VideoRecorder { + private VideoRecorder recorder; + + public CustomRecorder() { + try { + Class clazz = Class.forName(conf().recorderClass()); + recorder = (VideoRecorder) clazz.newInstance(); + } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { + e.printStackTrace(); + } + } + + @Override + public void start() { + recorder.start(); + } + + @Override + public File stopAndSave(String filename) { + return recorder.stopAndSave(filename); + } +} diff --git a/core/src/test/groovy/test/VideoConfigurationTest.groovy b/core/src/test/groovy/test/VideoConfigurationTest.groovy index bd49a56..51b6bf7 100644 --- a/core/src/test/groovy/test/VideoConfigurationTest.groovy +++ b/core/src/test/groovy/test/VideoConfigurationTest.groovy @@ -20,7 +20,7 @@ class VideoConfigurationTest extends SpockBaseTest { def conf = VideoRecorder.conf() then: - conf.folder() == System.getProperty("user.dir") + "/video" + conf.folder() == System.getProperty("user.dir") + File.separator + "video" conf.frameRate() == 24 conf.mode() == RecordingMode.ANNOTATED conf.recorderType() == RecorderType.MONTE