/*
* Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
* This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- */
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+*/
package eu.svjatoslav.meviz.encoder;
-import java.io.IOException;
import java.util.ArrayList;
public class EncodingPlan {
- public ArrayList<EncodingTask> encodingTasks = new ArrayList<EncodingTask>();
+ private final ArrayList<EncodingTask> encodingTasks = new ArrayList<>();
- public void execute(final EncodingOptions encodingOptions) throws IOException {
- for (final EncodingTask task : encodingTasks) {
+ public void execute(final EncodingOptions encodingOptions) {
- try {
- String command = task.getCommand(encodingOptions);
-
- if (task.doUseTerminal()) {
- command = "xterm -e '" + command + "'";
- }
-
- System.out.println("Executing command: " + command);
-
- final Runtime run = Runtime.getRuntime();
- Process pr;
- pr = run.exec(new String[] { "/bin/bash", "-c", command });
-
- pr.waitFor();
-
- } catch (final Exception e) {
- System.out.println(e.toString());
- e.printStackTrace();
- }
-
- }
+ for (final EncodingTask task : encodingTasks)
+ task.execute(encodingOptions);
}
public void scheduleTask(final EncodingTask encodingTask) {
encodingTasks.add(encodingTask);
- };
+ }
}