00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft.composers;
00024
00025 import gnu.getopt.Getopt;
00026
00027 import java.io.IOException;
00028 import java.util.Iterator;
00029 import java.util.Vector;
00030
00031 import com.meapsoft.EDLChunk;
00032 import com.meapsoft.EDLFile;
00033 import com.meapsoft.MEAPUtil;
00034 import com.meapsoft.ParserException;
00035
00042 public abstract class Composer extends MEAPUtil
00043 {
00044
00045 public static String description = "I am a generic Composer.";
00046
00047
00048 EDLFile outFile;
00049
00050
00051 Vector commands = null;
00052
00059 public void setup() throws IOException, ParserException
00060 {
00061
00062 outFile.clearChunks();
00063
00064
00065 progress.setMinimum(0);
00066 progress.setValue(0);
00067 }
00068
00072 public abstract EDLFile compose();
00073
00074
00075
00076
00077 public void run()
00078 {
00079 try
00080 {
00081 doComposer();
00082 }
00083 catch(Exception e)
00084 {
00085 exceptionHandler.handleException(e);
00086 }
00087 }
00088
00093 public void doComposer() throws IOException, ParserException
00094 {
00095
00096 setup();
00097
00098 compose();
00099
00100 addCommandsToAllEDLChunks();
00101
00102 if(writeMEAPFile)
00103 {
00104 outFile.writeFile();
00105
00106 }
00107
00108 }
00109
00113 public void addCommandToAllEDLChunks(String cmd)
00114 {
00115 if(outFile != null)
00116 {
00117 Iterator i = outFile.chunks.iterator();
00118 while(i.hasNext())
00119 {
00120 EDLChunk chunk = (EDLChunk)i.next();
00121
00122 if(chunk.commands != null)
00123 chunk.commands.add(cmd);
00124 }
00125 }
00126 }
00127
00131 public void addCommandsToAllEDLChunks(Vector cmds)
00132 {
00133 Iterator i = cmds.iterator();
00134 while(i.hasNext())
00135 addCommandToAllEDLChunks((String)i.next());
00136 }
00137
00138 public void addCommandsToAllEDLChunks()
00139 {
00140 if(commands != null)
00141 addCommandsToAllEDLChunks(commands);
00142 }
00143
00147 public void addCommand(String cmd)
00148 {
00149 if(commands == null)
00150 commands = new Vector();
00151
00152 commands.add(cmd);
00153 }
00154
00158 public static void printCommandLineOptions(char arg)
00159 {
00160 if(arg == 'c')
00161 {
00162 System.out.println(
00163 " -c command apply command to all chunks in the EDL output file\n" +
00164 " Supported commands include: reverse, crossfade(time), overlap(time) (time in seconds), gain(x)." +
00165 "");
00166 }
00167 else
00168 MEAPUtil.printCommandLineOptions(arg);
00169 }
00170
00174 public void parseCommands(String[] args, String argString)
00175 {
00176 Getopt opt = new Getopt("Composer", args, argString);
00177 opt.setOpterr(false);
00178
00179 int c = -1;
00180 while ((c = opt.getopt()) != -1)
00181 {
00182 if(c == 'c')
00183 {
00184 if(commands == null)
00185 commands = new Vector();
00186
00187 commands.add(opt.getOptarg());
00188 }
00189 }
00190 }
00191
00192 public String description()
00193 {
00194 return description;
00195 }
00196 }