use accessor methods for Encoding Options
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 25 Jun 2015 16:58:50 +0000 (19:58 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 25 Jun 2015 16:58:50 +0000 (19:58 +0300)
src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java
src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java
src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java
src/main/java/eu/svjatoslav/meviz/encoder/converters/AvconvVideo.java

index 1f38b17..d6282c2 100755 (executable)
@@ -65,22 +65,22 @@ public class CommandlineHandler {
 
                parser.parse(args);
 
-               options.recursive = recursiveParameter.isParameterSpecified();
+               options.setRecursive(recursiveParameter.isParameterSpecified());
 
-               options.deinterlace = deinterlaceParameter.isParameterSpecified();
+               options.setDeinterlace(deinterlaceParameter.isParameterSpecified());
 
-               options.testOnly = testParameter.isParameterSpecified();
+               options.setTestOnly(testParameter.isParameterSpecified());
 
                if (outputFormatParameter.isParameterSpecified())
-                       options.outputFormats.addAll(outputFormatParameter.getValue());
+                       options.getOutputFormats().addAll(outputFormatParameter.getValue());
 
                if (workingDirectoryParameter.isParameterSpecified())
-                       options.workingDirectory = workingDirectoryParameter.getValue();
+                       options.setWorkingDirectory(workingDirectoryParameter.getValue());
 
                if (inputPatternParameter.isParameterSpecified())
-                       options.inputPatterns.addAll(inputPatternParameter.getValue());
+                       options.getInputPatterns().addAll(inputPatternParameter.getValue());
 
-               options.forPortablePlayer = forPortableParameter.isParameterSpecified();
+               options.setForPortablePlayer(forPortableParameter.isParameterSpecified());
 
                if (videoBitrateParameter.isParameterSpecified())
                        options.setVideoBitrate(videoBitrateParameter.getValue());
index 4b56b13..1ec9d03 100755 (executable)
@@ -44,7 +44,7 @@ public class Encoder implements Module {
                        // handle directory
                        for (final File subFile : sourceFile.listFiles())
                                if (subFile.isDirectory()) {
-                                       if (encodingOptions.recursive)
+                                       if (encodingOptions.isRecursive())
                                                compileEncodingPlan(subFile);
                                } else
                                        compileEncodingPlan(subFile);
@@ -58,7 +58,7 @@ public class Encoder implements Module {
                                                .getFileExtension(sourceFile);
 
                                // encode source file into every desired target format
-                               for (final String targetFormat : encodingOptions.outputFormats) {
+                               for (final String targetFormat : encodingOptions.getOutputFormats()) {
 
                                        // construct target file
                                        final File targetFile = getTargetFile(sourceFile,
@@ -112,7 +112,7 @@ public class Encoder implements Module {
        public boolean fileMatchesInputPattern(final File file) {
                final String fileName = file.getName().toLowerCase();
 
-               for (final String inputPattern : encodingOptions.inputPatterns)
+               for (final String inputPattern : encodingOptions.getInputPatterns())
                        if (WildCardMatcher.match(fileName, inputPattern.toLowerCase()))
                                return true;
 
@@ -154,9 +154,9 @@ public class Encoder implements Module {
 
                encodingPlan = new EncodingPlan();
 
-               compileEncodingPlan(encodingOptions.workingDirectory);
+               compileEncodingPlan(encodingOptions.getWorkingDirectory());
 
-               if (!encodingOptions.testOnly)
+               if (!encodingOptions.isTestOnly())
                        try {
                                encodingPlan.execute(encodingOptions);
                        } catch (final Exception exception) {
index 6c666a1..9721cdc 100755 (executable)
@@ -21,19 +21,19 @@ public class EncodingOptions {
 
        // public Bitrate audioBitrate;
 
-       public boolean deinterlace = false;
+       private boolean deinterlace = false;
 
-       public boolean recursive;
+       private boolean recursive;
 
-       public boolean testOnly;
+       private boolean testOnly;
 
-       public boolean forPortablePlayer = false;
+       private boolean forPortablePlayer = false;
 
-       public File workingDirectory = new File(System.getProperty("user.dir"));
+       private File workingDirectory = new File(System.getProperty("user.dir"));
 
-       List<String> outputFormats = new ArrayList<String>();
+       private List<String> outputFormats = new ArrayList<String>();
 
-       List<String> inputPatterns = new ArrayList<String>();
+       private List<String> inputPatterns = new ArrayList<String>();
 
        public BitrateParameter.bitrate getAudioBitrate() {
                return audioBitrate;
@@ -51,4 +51,60 @@ public class EncodingOptions {
                this.videoBitrate = videoBitrate;
        }
 
+       public List<String> getInputPatterns() {
+               return inputPatterns;
+       }
+
+       public void setInputPatterns(List<String> inputPatterns) {
+               this.inputPatterns = inputPatterns;
+       }
+
+       public List<String> getOutputFormats() {
+               return outputFormats;
+       }
+
+       public void setOutputFormats(List<String> outputFormats) {
+               this.outputFormats = outputFormats;
+       }
+
+       public File getWorkingDirectory() {
+               return workingDirectory;
+       }
+
+       public void setWorkingDirectory(File workingDirectory) {
+               this.workingDirectory = workingDirectory;
+       }
+
+       public boolean isForPortablePlayer() {
+               return forPortablePlayer;
+       }
+
+       public void setForPortablePlayer(boolean forPortablePlayer) {
+               this.forPortablePlayer = forPortablePlayer;
+       }
+
+       public boolean isTestOnly() {
+               return testOnly;
+       }
+
+       public void setTestOnly(boolean testOnly) {
+               this.testOnly = testOnly;
+       }
+
+       public boolean isRecursive() {
+               return recursive;
+       }
+
+       public void setRecursive(boolean recursive) {
+               this.recursive = recursive;
+       }
+
+       public boolean isDeinterlace() {
+               return deinterlace;
+       }
+
+       public void setDeinterlace(boolean deinterlace) {
+               this.deinterlace = deinterlace;
+       }
+
 }
index ea4d1d3..3d3393b 100644 (file)
@@ -37,7 +37,7 @@ public class AvconvVideo extends AbstractConverter {
                if (audioBitrate != -1)
                        codecParams.append("-b:a " + audioBitrate + "k ");
 
-               if (options.deinterlace)
+               if (options.isDeinterlace())
                        codecParams.append("-filter:v yadif ");
 
                return codecParams.toString();
@@ -94,7 +94,7 @@ public class AvconvVideo extends AbstractConverter {
                if (options.getAudioBitrate() == bitrate.NONE)
                        audioCodec = null;
 
-               if (options.forPortablePlayer) {
+               if (options.isForPortablePlayer()) {
                        videoBitrate = 1000;
                        audioBitrate = 128;
                        videoCodec = "libxvid";