Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
*/
public enum RecorderType {
MONTE,
FFMPEG
FFMPEG,
CUSTOM
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 1 addition & 1 deletion core/src/test/groovy/test/VideoConfigurationTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down