diff --git a/README.md b/README.md index 049c3c3..1fd30aa 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# hclaps \ No newline at end of file +# hclaps + +## Release + +### Maven Central + +Pre-reqs: + +1. A Sonatype account with access to the LTS group +2. GPG +3. Maven setup with your Sonatype and GPG credentials: https://central.sonatype.org/publish/publish-maven/ + +Execute the following to publish to central: + +```shell +mvn -Prelease-central clean deploy +``` + +Note: + +1. The above command will **not** modify the version. You should use either `mvn release` or `mvn versions:set` to + set the version prior to publishing. +2. The plugin is currently configured to stage the artifact in Central, but **not** release it. To release it, you + must sign in at https://s01.oss.sonatype.org/ and follow [these instructions](https://central.sonatype.org/publish/release/#performing-a-release-deployment-with-the-maven-release-plugin). diff --git a/build.xml b/build.xml index f77e64c..d5ca543 100755 --- a/build.xml +++ b/build.xml @@ -39,7 +39,6 @@ - diff --git a/lib-local/_readme.txt b/lib-local/_readme.txt deleted file mode 100644 index 90cbc2a..0000000 --- a/lib-local/_readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -This directory contains Maven dependencies that are not available publicly. They are arranged by the standard Maven deployment method. These are accessed by the pom.xml file. -For an example, an artifact should be deployed to this directory as follows: - -mvn install:install-file -Dfile=[FILE_PATH] -DgroupId=[GROUP] -DartifactId=[ARTIFACT] -Dversion=[VERS] -Dpackaging=jar -DlocalRepositoryPath=[REPO_DIR] - -mvn install:install-file -Dfile=local/location/PDFBox-0.7.3.jar -DgroupId=org.pdfbox -DartifactId=PDFBox -Dversion=0.7.3 -Dpackaging=jar -DlocalRepositoryPath=./lib-local diff --git a/lib-local/aes-model.jar b/lib-local/aes-model.jar deleted file mode 100644 index 874dcee..0000000 Binary files a/lib-local/aes-model.jar and /dev/null differ diff --git a/lib-local/audiomarker.jar b/lib-local/audiomarker.jar deleted file mode 100644 index 7db9c80..0000000 Binary files a/lib-local/audiomarker.jar and /dev/null differ diff --git a/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.jar b/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.jar deleted file mode 100644 index 7db9c80..0000000 Binary files a/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.jar and /dev/null differ diff --git a/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.pom b/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.pom deleted file mode 100644 index 36b1880..0000000 --- a/lib-local/edu/harvard/hcl/audiomarker/1.6.0_65-b14-462-11M4609/audiomarker-1.6.0_65-b14-462-11M4609.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - edu.harvard.hcl - audiomarker - 1.6.0_65-b14-462-11M4609 - POM was created from install:install-file - diff --git a/lib-local/edu/harvard/hcl/audiomarker/maven-metadata-local.xml b/lib-local/edu/harvard/hcl/audiomarker/maven-metadata-local.xml deleted file mode 100644 index 2195503..0000000 --- a/lib-local/edu/harvard/hcl/audiomarker/maven-metadata-local.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - edu.harvard.hcl - audiomarker - - 1.6.0_65-b14-462-11M4609 - - 1.6.0_65-b14-462-11M4609 - - 20220124231704 - - diff --git a/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.jar b/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.jar deleted file mode 100644 index 874dcee..0000000 Binary files a/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.jar and /dev/null differ diff --git a/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.pom b/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.pom deleted file mode 100644 index a226b39..0000000 --- a/lib-local/org/aes/aes-model/1.5.0_06-64/aes-model-1.5.0_06-64.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - org.aes - aes-model - 1.5.0_06-64 - POM was created from install:install-file - diff --git a/lib-local/org/aes/aes-model/maven-metadata-local.xml b/lib-local/org/aes/aes-model/maven-metadata-local.xml deleted file mode 100644 index d167687..0000000 --- a/lib-local/org/aes/aes-model/maven-metadata-local.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - org.aes - aes-model - - 1.5.0_06-64 - - 1.5.0_06-64 - - 20220124231544 - - diff --git a/pom.xml b/pom.xml index 2d65945..6d46a2c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,15 @@ jar hclaps + hclaps + https://github.com/harvard-lts/hclaps + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + scm:git:https://github.com/harvard-lts/hclaps.git @@ -65,6 +74,32 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.5.0 + + + attach-javadocs + + jar + + + + @@ -89,26 +124,11 @@ Saxon-HE ${saxonhe.version} - - castor - castor - ${castor.version} - org.apache.commons commons-csv ${commons-csv.version} - - org.aes - aes-model - ${aes-model.version} - - - edu.harvard.hcl - audiomarker - ${audiomarker.version} - org.slf4j slf4j-api @@ -146,39 +166,94 @@ - - - lts-libs-all - Harvard LTS Dependency Repository - ${lts-artifactory-url}/lts-libs-all - - - local-maven-repo - Local file system for temporarily holding non-repo JAR files - file://${project.basedir}/lib-local/ - - - - - - lts-libs-all-plugins - Harvard LTS Plugin Repository - ${lts-artifactory-url}/lts-libs-all - - + + + harvard + + true + + + + lts-libs-all + Harvard LTS Dependency Repository + ${lts-artifactory-url}/lts-libs-all + + + + + lts-libs-all-plugins + Harvard LTS Plugin Repository + ${lts-artifactory-url}/lts-libs-all + + + + + + harvard-lts-internal-release-repository + Harvard LTS internal Release Repository + ${lts-artifactory-url}/lts-libs-release-local + + + harvard-lts-internal-snapshot-repository + Harvard LTS internal Snapshot Repository + ${lts-artifactory-url}/lts-libs-snapshot-local + + + + + + release-central + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://s01.oss.sonatype.org/ + false + + + + + + - - - - harvard-lts-internal-release-repository - Harvard LTS internal Release Repository - ${lts-artifactory-url}/lts-libs-release-local - - - harvard-lts-internal-snapshot-repository - Harvard LTS internal Snapshot Repository - ${lts-artifactory-url}/lts-libs-snapshot-local - - + + + David Neiman + dneiman@g.harvard.edu + Harvard University Information Technology + https://huit.harvard.edu + + + Andrew Woods + andrew_woods@harvard.edu + Harvard University Information Technology + https://huit.harvard.edu + + \ No newline at end of file diff --git a/src/main/java/edu/harvard/hcl/hclaps/bwav/chunks/Chunk.java b/src/main/java/edu/harvard/hcl/hclaps/bwav/chunks/Chunk.java index 7bfcefa..51cb07b 100755 --- a/src/main/java/edu/harvard/hcl/hclaps/bwav/chunks/Chunk.java +++ b/src/main/java/edu/harvard/hcl/hclaps/bwav/chunks/Chunk.java @@ -177,8 +177,6 @@ public void writeToFile(IFFRandomAccessFile file) throws IOException { /** * Returns a clone of the Chunk. - * - * @throws CloneNotSupportedException */ public Object clone() { try { diff --git a/src/main/java/edu/harvard/hcl/hclaps/util/AES31Time.java-SAV b/src/main/java/edu/harvard/hcl/hclaps/util/AES31Time.java-SAV deleted file mode 100755 index 5eca19e..0000000 --- a/src/main/java/edu/harvard/hcl/hclaps/util/AES31Time.java-SAV +++ /dev/null @@ -1,310 +0,0 @@ -// -// AES31Time.java -// APXE -// -// Created by Robert La Ferla (robertlaferla@comcast.net) on Thu Jan 22 2004. -// Transferred from APXE to hclaps on 3/1/2007 -// -// Copyright 2004 by the President and Fellows of Harvard College. -// - -package edu.harvard.hcl.hclaps.util; - -import org.aes.tcf.*; -import org.aes.tcf.types.*; -import java.util.*; -import java.text.NumberFormat; -import java.math.BigDecimal; - -/** - * AES31Time is a collection of utility methods for dealing with AES-31 time code character format. - * - * @author Robert La Ferla - */ -public class AES31Time { - private final static int FRAME_ERROR_PER_HOUR = 108; - private final static int MINUTES_PER_HOUR = 60; - private final static int SECONDS_PER_MINUTE = 60; - private final static int DECIMAL_SCALE = 64; - - public static TimeCodeCharacterFormatType parseString(String timeCodeString) { - TimeCodeCharacterFormatType tccft; - - //System.out.println("parseString(" + timeCodeString + ")"); - tccft = new TimeCodeCharacterFormatType(); - tccft.setHours(Integer.parseInt(timeCodeString.substring(0,2))); - tccft.setMinutes(Integer.parseInt(timeCodeString.substring(3,5))); - tccft.setSeconds(Integer.parseInt(timeCodeString.substring(6,8))); - tccft.setFrames(Integer.parseInt(timeCodeString.substring(9,11))); - - if (timeCodeString.length() > 11) { - SamplesType st; - char indicatorVal; - String rateName; - int numSamples; - - st = new SamplesType(); - indicatorVal = timeCodeString.charAt(11); - rateName = TCFData.getSampleRateNameForIndicator(indicatorVal); - // System.out.println("rateName = " + rateName); - st.setSampleRate(SampleRateType.valueOf(rateName)); - numSamples = Integer.parseInt(timeCodeString.substring(12,16)); - st.setNumberOfSamples(numSamples); - //System.out.println("NumberOfSamples = " + numSamples); - tccft.setSamples(st); - } - - //System.out.println("timeCodeString.charAt(2)=" + timeCodeString.charAt(2)); - tccft.setFrameCount(TCFData.getFrameCountForIndicator(timeCodeString.charAt(2))); - tccft.setTimeBase(TCFData.getTimeBaseForIndicator(timeCodeString.charAt(2))); - - //System.out.println("timeCodeString.charAt(8)=" + timeCodeString.charAt(8)); - tccft.setVideoField(TCFData.getVideoFieldForIndicator(timeCodeString.charAt(8))); - tccft.setCountingMode(TCFData.getCountingModeForIndicator(timeCodeString.charAt(8))); - - //System.out.println("timeCodeString.charAt(5)=" + timeCodeString.charAt(5)); - if (tccft.getCountingMode() == CountingModeType.PAL) { - PalFilmFramingType pfft; - - pfft = new PalFilmFramingType(); - tccft.setFilmFraming(pfft); - // Is the frame count/timebase indicator repeated? - if (timeCodeString.charAt(5) == timeCodeString.charAt(2)) { - pfft.setFraming(PalListType.NOT_APPLICABLE); - } - } - else { - NtscFilmFramingType nfft; - - nfft = new NtscFilmFramingType(); - tccft.setFilmFraming(nfft); - // Is the frame count/timebase indicator repeated? - if (timeCodeString.charAt(5) == timeCodeString.charAt(2)) { - nfft.setFraming(NtscListType.NOT_APPLICABLE); - } - } - - // System.out.println("tccft = " + toString(tccft)); - //System.out.println("tccft.getHours() = " + tccft.getHours()); - - return tccft; - } - - public static String toString(TimeCodeCharacterFormatType tccft) { - FilmFramingType fft; - String str; - String sampleStr = ""; - char ind1; - char ind2; - char ind3; - char ind4; - - // System.out.println("tccft = " + tccft); - - // System.out.println("tccft.getFrameCount() = " + tccft.getFrameCount()); - // System.out.println("tccft.getTimeBase() = " + tccft.getTimeBase()); - - // First Indicator (1) - ind1 = TCFData.getIndicatorForFrameCountAndTimeBase(tccft.getFrameCount(), tccft.getTimeBase()); - - // Second Indicator (2) - fft = tccft.getFilmFraming(); - if (fft.getClass() == NtscFilmFramingType.class) { - NtscFilmFramingType nfft; - NtscListType nlt; - int idx; - - nfft = (NtscFilmFramingType)fft; - nlt = nfft.getFraming(); - idx = nlt.getType(); - if (idx != NtscListType.NOT_APPLICABLE_TYPE) { - ind2 = TCFData.getIndicatorForNTSCListType(nlt); - } - else { - ind2 = ind1; - } - } - else { - PalFilmFramingType pfft; - PalListType plt; - int idx; - - pfft = (PalFilmFramingType)fft; - plt = pfft.getFraming(); - idx = plt.getType(); - if (idx != PalListType.NOT_APPLICABLE_TYPE) { - ind2 = TCFData.getIndicatorForPALListType(plt); - } - else { - ind2 = ind1; - } - } - - // Third Indicator (3) - ind3 = TCFData.getIndicatorForCountingModeAndVideoField(tccft.getCountingMode(), tccft.getVideoField()); - - // Construct time code group - str = pad(tccft.getHours()) + ind1 + pad(tccft.getMinutes()) + ind2 + pad(tccft.getSeconds()) + ind3 + pad(tccft.getFrames()); - if (tccft.getSamples() != null) { - SampleRateType sampleRate; - NumberFormat nf; - - nf = NumberFormat.getIntegerInstance(); - nf.setMinimumIntegerDigits(4); - nf.setGroupingUsed(false); - - sampleRate = tccft.getSamples().getSampleRate(); - //System.out.println("sampleRate = " + sampleRate); - // Fourth Indicator (4) - ind4 = TCFData.getIndicatorForSampleRate(sampleRate.toString()); - // System.out.println("ind4 = " + ind4); - sampleStr = ind4 + sampleStr + nf.format(tccft.getSamples().getNumberOfSamples()); - } - return str+sampleStr; - } - - - public static BigDecimal getNumberOfSecondsForTimeCode(TimeCodeCharacterFormatType tccft) { - BigDecimal time; - SamplesType st; - int frameCount = 0; - double sampleRate = (double)0; - double timeBase = (double)0; - - frameCount = getFrameCountForType(tccft.getFrameCount()); - - //discover the samplerate for this tcf object - st = tccft.getSamples(); - sampleRate = getSampleRateForType(st.getSampleRate()); - - // Timebase - timeBase = getTimeBaseForType(tccft.getTimeBase()); - - //recalc the timecode as seconds - time = new BigDecimal(0.0); - time.setScale(DECIMAL_SCALE, BigDecimal.ROUND_UNNECESSARY); - - time = time.add(new BigDecimal(tccft.getHours() * MINUTES_PER_HOUR * SECONDS_PER_MINUTE)); - time = time.add(new BigDecimal(tccft.getMinutes() * SECONDS_PER_MINUTE)); - time = time.add(new BigDecimal(tccft.getSeconds())); - time = time.add(new BigDecimal(tccft.getFrames() * (1.0 / frameCount))); - if (st.hasNumberOfSamples()) { - time = time.add(new BigDecimal(st.getNumberOfSamples() * 1.0 / sampleRate)); - } - - if (tccft.getCountingMode().getType() == CountingModeType.NTSC_DROP_FRAME_TYPE) { - int minutesToDrop = ((tccft.getHours() * MINUTES_PER_HOUR) + tccft.getMinutes()); - int framesToDrop = ((minutesToDrop - (minutesToDrop / 10)) * 2); - time = time.subtract(new BigDecimal(framesToDrop * 1.0 / frameCount)); - } - - time = time.multiply(new BigDecimal(timeBase)); - - return time; - } - - public static TimeCodeCharacterFormatType convertFromBigDecimal(BigDecimal time, SampleRateType sampleRateType, double timeBaseValue, int frameCountValue, CountingModeType countingModeType) { - TimeCodeCharacterFormatType tccft; - SamplesType st; - int sampleRate; - - tccft = new TimeCodeCharacterFormatType(); - st = new SamplesType(); - tccft.setSamples(st); - - time.setScale(DECIMAL_SCALE, BigDecimal.ROUND_HALF_EVEN); - time = time.multiply(new BigDecimal(1.0 / timeBaseValue)); - - int frames = time.divide(new BigDecimal(1.0 / frameCountValue), DECIMAL_SCALE, BigDecimal.ROUND_HALF_EVEN).intValue(); - BigDecimal remainder = time.divide(new BigDecimal(1.0/frameCountValue), DECIMAL_SCALE, BigDecimal.ROUND_HALF_EVEN); - remainder = remainder.subtract(BigDecimal.valueOf(frames)); - - if (countingModeType == CountingModeType.NTSC_DROP_FRAME) { - int minutesToDrop = ((frames/frameCountValue) / SECONDS_PER_MINUTE); - int framesToDrop = ((minutesToDrop - (minutesToDrop / 10)) * 2); - frames += framesToDrop; - } - - int seconds = frames/frameCountValue; - frames -= seconds * frameCountValue; - - int minutes = seconds / SECONDS_PER_MINUTE; - seconds -= minutes * SECONDS_PER_MINUTE; - - int hours = minutes / MINUTES_PER_HOUR; - minutes -= hours * MINUTES_PER_HOUR; - - sampleRate = getSampleRateForType(sampleRateType); - float samples = remainder.multiply(new BigDecimal(sampleRate/frameCountValue * timeBaseValue)).floatValue(); - - float samplesRemainder = samples - (int)samples; - samples = (int)samples; - if (samplesRemainder >= 0.5) { - samples++; - } - - - //System.out.println("H-> " + hours + " M-> " + minutes + " S-> " + seconds + " F-> " + frames + " s-> " + (int)samples); - - st.setSampleRate(sampleRateType); - st.setNumberOfSamples((int)samples); - tccft.setHours(hours); - tccft.setMinutes(minutes); - tccft.setSeconds(seconds); - tccft.setFrames(frames); - return tccft; - } - - public static int getFrameCountForType(FrameCountType frameCountType) { - int frameCount = 0; - - switch (frameCountType.getType()) { - case FrameCountType.VALUE_30_TYPE: - frameCount = 30; - break; - case FrameCountType.VALUE_25_TYPE: - frameCount = 25; - break; - case FrameCountType.VALUE_24_TYPE: - frameCount = 24; - break; - } - return frameCount; - } - - public static double getTimeBaseForType(TimeBaseType timeBaseType) { - double timeBase = (double)0; - - switch (timeBaseType.getType()) { - case TimeBaseType.UNKNOWN_TYPE: // Unknown - timeBase = 1.000; - System.out.println("Unknown timebase encountered, will use 1.000"); - break; - case TimeBaseType.VALUE_1000_TYPE: // 1.0 - timeBase = 1.000; - break; - case TimeBaseType.VALUE_1001_TYPE: - timeBase = 1.001001001001001001; - break; - } - return timeBase; - } - - public static int getSampleRateForType(SampleRateType sampleRateType) { - int sampleRate = 0; - - sampleRate = Integer.parseInt(sampleRateType.toString().substring(1)); - return sampleRate; - } - - private static String pad(int num) { - String str = ""; - - if (num < 10) { - str = "0"; - } - str = str + num; - return str; - } - -} diff --git a/src/main/java/edu/harvard/hcl/hclaps/util/AESUtil.java-SAV b/src/main/java/edu/harvard/hcl/hclaps/util/AESUtil.java-SAV deleted file mode 100755 index 232cf93..0000000 --- a/src/main/java/edu/harvard/hcl/hclaps/util/AESUtil.java-SAV +++ /dev/null @@ -1,509 +0,0 @@ -// -// AESUtil.java -// hclaps -// -// Created by Robert La Ferla on 3/5/07. -// Copyright 2007 Harvard University. All rights reserved. -// - -package edu.harvard.hcl.hclaps.util; - -import java.io.*; -import java.util.*; -import java.nio.charset.Charset; -import java.math.BigDecimal; -import edu.harvard.hcl.hclaps.bwav.*; -import org.exolab.castor.xml.*; -import org.exolab.castor.util.LocalConfiguration; -import org.aes.tcf.*; -import org.aes.processhistory.*; -import org.aes.processhistory.types.*; -import com.therockquarry.aes31.adl.*; -import java.net.URI; -import org.aes.audioObject.AudioObjectType; -import org.aes.audioObject.FaceRegionType; -import org.aes.audioObject.FaceType; -import org.aes.audioObject.ChannelAssignmentType; - -/** - * @author Robert La Ferla - */ - -public class AESUtil implements AttributeListener { - - HashMap oldIDtoNewIDMap = new HashMap(); - boolean finishedParsingIDMap = false; - - public static OperatorType getOperatorType() { - OperatorType ot = null; - String hpPath; - - hpPath = System.getProperty("user.home") + "/hclaps.prop"; - try { - FileInputStream fis; - Properties prop; - - fis = new FileInputStream(hpPath); - prop = new Properties(); - prop.load(fis); - ot = new OperatorType(); - ot.setFirstName(prop.getProperty("operator.firstname")); - ot.setLastName(prop.getProperty("operator.lastname")); - ot.setOrganization(prop.getProperty("operator.organization")); - ot.setStreet1(prop.getProperty("operator.street1")); - ot.setStreet2(prop.getProperty("operator.street2")); - ot.setCity(prop.getProperty("operator.city")); - ot.setRegion(prop.getProperty("operator.region")); - ot.setCountryCode(prop.getProperty("operator.countrycode")); - ot.setPostalCode(prop.getProperty("operator.postalcode")); - } - catch (FileNotFoundException ex) { - System.err.println("Could not open " + hpPath); - System.exit(-1); - } - catch (IOException ex) { - System.err.println("Could not load " + hpPath); - System.exit(-1); - } - return ot; - } - - public static void saveObject(ObjectType obj, String rootElementName, String fileName, boolean validate) { - try { - Properties prop; - FileOutputStream fos; - OutputStreamWriter osw; - Marshaller marsh; - - prop = LocalConfiguration.getInstance().getProperties(); - prop.setProperty("org.exolab.castor.indent", "true"); - prop.setProperty("org.exolab.castor.marshalling.validation", "true"); - - fos = new FileOutputStream(fileName); - osw = new OutputStreamWriter(fos, Charset.forName("UTF-8")); - - marsh = new Marshaller(osw); - marsh.setSchemaLocation("http://www.aes.org/processhistory http://hul.harvard.edu/ois/xml/xsd/drs/processhistory.xsd"); - marsh.setNamespaceMapping("tcf", "http://www.aes.org/tcf"); - marsh.setNamespaceMapping("xlink", "http://www.w3.org/1999/xlink"); - marsh.setNamespaceMapping("xsd", "http://www.w3.org/2001/XMLSchema"); - marsh.setRootElement(rootElementName); - marsh.setValidation(validate); - marsh.marshal(obj); - } - catch (Exception ex) { - ex.printStackTrace(); - } - } - - public static ArrayList getStreams(MediaType mt, ADLSection adls) { - ArrayList streams; - EventListSection els; - TracklistSection tls; - ArrayList eventEntries; - Iterator it; - TcfToken beginTimeline = null; - TcfToken endTimeline = null; - TimeCodeCharacterFormatType firstTimeCode, lastTimeCode, durationTimeCode; - BigDecimal duration; - TimeRangeType trt; - TreeSet dcSet; - - dcSet = new TreeSet(); - - els = adls.getEventListSection(); - eventEntries = els.getEventEntries(BaseEditEntry.EntryType.CUT); - it = eventEntries.iterator(); - while (it.hasNext()) { - CutEditEntry cee; - TcfToken din, dout; - Range dcRange; - - cee = (CutEditEntry)it.next(); - - // Determine destination channels - dcRange = cee.getDestChannels(); - for (int i = dcRange.getBegin(); i <= dcRange.getEnd(); i++) { - dcSet.add(new Integer(i)); - } - - din = cee.getDestIn(); - dout = cee.getDestOut(); - - // Determine beginning of timeline - if (beginTimeline == null) { - beginTimeline = din; - } - else { - if (din.valueOf() < beginTimeline.valueOf()) { - beginTimeline = din; - } - } - - // Determine end of timeline - if (endTimeline == null) { - endTimeline = dout; - } - else { - if (dout.valueOf() > endTimeline.valueOf()) { - endTimeline = dout; - } - } - } - //System.out.println("# dest channels = " + dcSet.size()); - - tls = adls.getTracklistSection(); - - streams = new ArrayList(); - it = dcSet.iterator(); - while (it.hasNext()) { - StreamType st; - Integer num; - - num = (Integer)it.next(); - st = new StreamType(); - st.setStreamNum(num.intValue()); - if (tls != null) { - TrackType tt; - - tt = tls.getTrackAtIndex(num.intValue()); - st.setLabel(tt.getTrackName()); - } - else { - st.setLabel("Track #" + num); - } - streams.add(st); - } - - // Convert TcfToken to TimeCodeCharacterFormatType - firstTimeCode = AES31Time.parseString(beginTimeline.toString()); - lastTimeCode = AES31Time.parseString(endTimeline.toString()); - - trt = new TimeRangeType(); - trt.setStartTime(firstTimeCode); - // Need to calculate the duration - - duration = AES31Time.getNumberOfSecondsForTimeCode(lastTimeCode).subtract(AES31Time.getNumberOfSecondsForTimeCode(firstTimeCode)); - durationTimeCode = AES31Time.convertFromBigDecimal(duration, lastTimeCode.getSamples().getSampleRate(), AES31Time.getTimeBaseForType(lastTimeCode.getTimeBase()), AES31Time.getFrameCountForType(lastTimeCode.getFrameCount()), lastTimeCode.getCountingMode()); - durationTimeCode.setFrameCount(lastTimeCode.getFrameCount()); - durationTimeCode.setTimeBase(lastTimeCode.getTimeBase()); - durationTimeCode.setVideoField(lastTimeCode.getVideoField()); - durationTimeCode.setFilmFraming(lastTimeCode.getFilmFraming()); - durationTimeCode.setCountingMode(lastTimeCode.getCountingMode()); - trt.setDuration(durationTimeCode); - mt.setTimeRange(trt); - mt.setStream(streams); - return streams; - } - - public static MediaType mediaFromADLFile(String filename) { - // System.out.println("mediaFromADLFile(" + filename + ")"); - MediaType mt = null; - - try { - ADL adl; - ADLSection adls = null; - LocStringType lst; - Iterator it; - - adl = new ADL(filename); - adl.open("r"); - adls = adl.getADLSection(); - if (adls != null) { - File f; - URI uri; - ProjectSection ps; - - lst = new LocStringType(); - lst.setShow(LocStringTypeShowType.NONE); - lst.setActuate(LocStringTypeActuateType.NONE); - - f = new File(filename); - uri = f.toURI(); - lst.setHref(uri.toString()); - - ps = adls.getProjectSection(); - lst.setTitle(ps.getProjTitle()); - - mt = new MediaType(); - mt.setMediaLocation(lst); - mt.setKind(MediaKindType.AES_31_3_ADL_METADATA); - mt.setTemporary(false); - getStreams(mt, adls); - it = mt.getStreamAsReference().iterator(); - while (it.hasNext()) { - StreamType st; - - st = (StreamType)it.next(); - st.setMediaRef(mt); - } - } - } - catch (Exception ex) { - ex.printStackTrace(); - } - - return mt; - } - - public static MediaType mediaForFile(String path) { - MediaType mt = null; - LocStringType lst; - File file; - - // System.out.println("mediaForFile(" + path + ")"); - file = new File(path); - path = file.getAbsolutePath(); - - mt = new MediaType(); - lst = new LocStringType(); - try { - URI uri; - - uri = file.toURI(); - lst.setHref(uri.toString()); - if (path.endsWith(".wav")) { - WAVEFile bwav; - TimeRangeType trt; - int numChannels; - - bwav = new WAVEFile(path); - bwav.load(); - numChannels = bwav.formatChunk().getNumberOfChannels(); - for (int i = 0; i < numChannels; i++) { - StreamType st; - - st = new StreamType(); - st.setStreamNum(i); - st.setMediaRef(mt); - mt.addStream(st); - } - //System.out.println("start time = " + bwav.getStartTime()); - //System.out.println("duration = " + bwav.getDuration()); - - trt = new TimeRangeType(); - trt.setStartTime(AES31Time.parseString(bwav.getStartTime().toString())); - trt.setDuration(AES31Time.parseString(bwav.getDuration().toString())); - //System.out.println("AES31Time.toString(trt.getStartTime()) = " + AES31Time.toString(trt.getStartTime())); - //System.out.println("AES31Time.toString(trt.getDuration()) = " + AES31Time.toString(trt.getDuration())); - mt.setTimeRange(trt); - } - } - catch (Exception ex) { - ex.printStackTrace(); - } - mt.setMediaLocation(lst); - return mt; - } - - public static ArrayList mediaForPathsInPool(ArrayList paths, MediaPoolType mpt) { - ArrayList mediaLocations; - ArrayList al; - Iterator it; - - al = new ArrayList(); - - mediaLocations = new ArrayList(); - it = paths.iterator(); - while (it.hasNext()) { - File file; - String path; - - path = (String)it.next(); - file = new File(path); - path = file.getAbsolutePath(); - try { - URI uri; - - uri = file.toURI(); - mediaLocations.add(uri.toString()); - // System.out.println("Trying path " + uri.toString()); - } - catch (Exception ex) { - ex.printStackTrace(); - } - } - - it = mpt.getMediaAsReference().iterator(); - while (it.hasNext()) { - MediaType mt; - String href; - - mt = (MediaType)it.next(); - href = mt.getMediaLocation().getHref(); - if (AESUtil.isStringInArrayList(href, mediaLocations)) { - al.add(mt); - // System.out.println("Added " + href); - } - } - - return al; - } - - public static boolean isStringInArrayList(String str, ArrayList array) { - Iterator it; - boolean retval = false; - - it = array.iterator(); - while (it.hasNext()) { - String s; - - s = it.next(); - if (s.equals(str)) { - retval = true; - break; - } - } - return retval; - } - - public MediaType importCoreAudioFile(String fileName) { - MediaType mt = null; - AudioObjectType aot = null; - - //System.out.println("importCoreAudioFile(" + fileName + ")"); - - aot = (AudioObjectType)importObjectFromFile(fileName, AudioObjectType.class, true); - //System.out.println("aot = " + aot); - if (aot != null) { - Iterator streamIt; - LocStringType lst; - FaceRegionType frt = null; // CHANGE THIS - FaceType ft; - - mt = new MediaType(); - mt.setKind(MediaKindType.CORE_AUDIO_METADATA); - mt.setTemporary(false); - lst = new LocStringType(); - - try { - File f; - URI uri; - - f = new File(fileName); - uri = f.toURI(); - lst.setHref(uri.toString()); - } - catch (Exception ex) { - ex.printStackTrace(); - } - - lst.setShow(LocStringTypeShowType.NONE); - lst.setActuate(LocStringTypeActuateType.NONE); - ft = aot.getFace(0); - frt = ft.getRegion(0); - lst.setTitle(ft.getLabel() + " - " + frt.getLabel()); - //System.out.println("lst.getTitle() = " + lst.getTitle()); - mt.setMediaLocation(lst); - mt.setTimeRange(frt.getTimeRange()); - //System.out.println("frt.getTimeRange() = " + frt.getTimeRange()); - - streamIt = frt.getStreamAsReference().iterator(); - while (streamIt.hasNext()) { - org.aes.audioObject.StreamType aca_st; - org.aes.processhistory.StreamType ph_st; - ChannelAssignmentType cat; - - aca_st = (org.aes.audioObject.StreamType)streamIt.next(); - cat = aca_st.getChannelAssignment(); - ph_st = new org.aes.processhistory.StreamType(); - ph_st.setStreamNum(cat.getChannelNum()); - ph_st.setLabel(cat.getMapLocation()); - mt.addStream(ph_st); - ph_st.setMediaRef(mt); - } - } - - return mt; - } - - public Object importObjectFromFile(String fileName, Class aClass, boolean validate) { - Object obj = null; - FileInputStream fis; - InputStreamReader isr; - Unmarshaller unm; - - //System.out.println("importObjectFromFile(" + fileName + ", " + aClass + ")"); - try { - BufferedReader br; - String str; - String line; - StringBuffer sb; - StringReader sr; - Iterator it; - - fis = new FileInputStream(fileName); - isr = new InputStreamReader(fis, Charset.forName("UTF-8")); - - unm = new Unmarshaller(aClass); - //unm.setAttributeListener(this); - // Validate the first time before we replace anything. - unm.setValidation(validate); - // Unmarshal the model object to get the map of IDs - unm.unmarshal(isr); - finishedParsingIDMap = true; - fis.close(); - isr.close(); - - fis = new FileInputStream(fileName); - isr = new InputStreamReader(fis, Charset.forName("UTF-8")); - br = new BufferedReader(isr); - - sb = new StringBuffer(); - - while ((line = br.readLine()) != null) { - sb.append(line); - sb.append("\n"); - } - - str = sb.toString(); - - it = oldIDtoNewIDMap.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry; - String key; - String value; - String newStr; - - entry = (Map.Entry)it.next(); - key = (String)entry.getKey(); - value = (String)entry.getValue(); - - newStr = str.replaceAll(key, value); - str = newStr; - } - - // System.out.println(str); - sr = new StringReader(str); - - // Unmarshal a second time to substitute the IDs - // Do not validate the second time because we are changing references during unmarshalling. - unm.setValidation(false); - obj = unm.unmarshal(sr); - finishedParsingIDMap = false; - fis.close(); - isr.close(); - } - catch (FileNotFoundException ex) { - System.err.println("Can't open file: " + fileName); - } - catch (Exception ex) { - ex.printStackTrace(); - } - - return obj; - } - - public void processAttribute(String attName, String attValue) { - if (attName.equals("ID") == true) { - String newValue; - - newValue = org.aes.processhistory.ObjectType.newObjectID(); - // key = old ID, value = new ID - oldIDtoNewIDMap.put(attValue, newValue); - // System.out.println("added (" + attValue + "," + newValue + ") to hash map\n\n"); - } - } - - -} diff --git a/src/main/java/edu/harvard/hcl/hclaps/util/TCFData.java b/src/main/java/edu/harvard/hcl/hclaps/util/TCFData.java deleted file mode 100755 index f3e016c..0000000 --- a/src/main/java/edu/harvard/hcl/hclaps/util/TCFData.java +++ /dev/null @@ -1,301 +0,0 @@ -// -// TCFData.java -// APXE -// -// Created by Robert La Ferla (robertlaferla@comcast.net) on Wed Mar 24 2004. -// Transferred from APXE to hclaps on 3/1/2007 -// -// Copyright 2004 by the President and Fellows of Harvard College. -// - -package edu.harvard.hcl.hclaps.util; - -import org.aes.tcf.types.*; -import org.aes.tcf.data.*; -import java.io.*; -import org.exolab.castor.xml.*; -import java.util.*; -import java.net.URI; -import java.net.URL; -import java.nio.charset.Charset; - -/** - * @author Robert La Ferla - */ - -/** - * Class TCFData. - * - * @version $Revision: 1.8 $ $Date: 2004/11/22 21:48:40 $ - */ -public class TCFData { - static TcfDataEnumerationType tdet = null; - - static { - InputStream is; - - is = new TCFData().getClass().getResourceAsStream("tcfdata.xml"); - try { - InputStreamReader isr; - - isr = new InputStreamReader(is, Charset.forName("UTF-8")); - tdet = (TcfDataEnumerationType)Unmarshaller.unmarshal(TcfDataEnumerationType.class, isr); - } - catch (MarshalException e) { - System.out.println("Exception = " + e); - } - catch (ValidationException e) { - System.out.println("Exception = " + e); - } - - //System.out.println("tdet=" + tdet); - } - - public static char getIndicatorForSampleRate(String rateName) { - char indicator = (char)0; - SampleRateTableType srtt; - - //System.out.println("rateName=" + rateName); - srtt = tdet.getSampleRateTable(); - for (Iterator it = srtt.getRowAsReference().iterator(); it.hasNext() ;) { - SampleRateRowType srrt; - - srrt = (SampleRateRowType)it.next(); - //System.out.println("srrt.getRateName()=" + srrt.getRateName() + " srrt.getIndicator()=" + srrt.getIndicator()); - if (srrt.getRateName().equals(rateName)) { - indicator = (char)srrt.getIndicator(); - break; - } - } - return indicator; - } - - public static String getSampleRateNameForIndicator(char indicator) { - String sampleRateName = null; - SampleRateTableType srtt; - - srtt = tdet.getSampleRateTable(); - for (Iterator it = srtt.getRowAsReference().iterator(); it.hasNext() ;) { - SampleRateRowType srrt; - - srrt = (SampleRateRowType)it.next(); - if ((char)srrt.getIndicator() == indicator) { - sampleRateName = srrt.getRateName(); - break; - } - } - return sampleRateName; - } - - public static char getIndicatorForPALListType(PalListType plt) { - char indicator = (char)0; - Pal_11_3_TableType ptt; - String palTypeName; - - palTypeName = plt.toString(); - ptt = tdet.getPal_11_3_Table(); - for (Iterator it = ptt.getRowAsReference().iterator(); it.hasNext() ;) { - Pal_11_3_RowType prt; - - prt = (Pal_11_3_RowType)it.next(); - if (prt.getEnumValue().equals(palTypeName)) { - indicator = (char)prt.getIndicator(); - break; - } - } - return indicator; - } - - public static char getIndicatorForNTSCListType(NtscListType nlt) { - char indicator = (char)0; - Ntsc_2_3_TableType ntt; - String ntscTypeName; - - ntscTypeName = nlt.toString(); - ntt = tdet.getNtsc_2_3_Table(); - for (Iterator it = ntt.getRowAsReference().iterator(); it.hasNext() ;) { - Ntsc_2_3_RowType nrt; - - nrt = (Ntsc_2_3_RowType)it.next(); - if (nrt.getEnumValue().equals(ntscTypeName)) { - indicator = (char)nrt.getIndicator(); - break; - } - } - return indicator; - } - - public static char getIndicatorForFrameCountAndTimeBase(FrameCountType fct, TimeBaseType tbt) { - char indicator = (char)0; - FrameCountTableType fctt; - int framecount; - String timebase = null; - - //System.out.println("getIndicatorForFrameCountAndTimeBase(" + fct + "," + tbt + ")"); - framecount = Integer.parseInt(fct.toString()); - switch(tbt.getType()) { - case TimeBaseType.UNKNOWN_TYPE: - timebase = "Unknown"; - break; - case TimeBaseType.VALUE_1000_TYPE: - timebase = "1.000"; - break; - case TimeBaseType.VALUE_1001_TYPE: - timebase = "1.001"; - break; - } - - fctt = tdet.getFrameCountTable(); - for (Iterator it = fctt.getRowAsReference().iterator(); it.hasNext() ;) { - FrameCountRowType fcrt; - - fcrt = (FrameCountRowType)it.next(); - if (fcrt.getFrameCount() == framecount && fcrt.getTimeBase().equals(timebase)) { - indicator = (char)fcrt.getIndicator(); - break; - } - } - return indicator; - } - - public static FrameCountType getFrameCountForIndicator(char c) { - int frameCount = 0; - FrameCountType fct = null; - FrameCountTableType fctt; - - fctt = tdet.getFrameCountTable(); - for (Iterator it = fctt.getRowAsReference().iterator(); it.hasNext() ;) { - FrameCountRowType fcrt; - - fcrt = (FrameCountRowType)it.next(); - if (fcrt.getIndicator() == c) { - frameCount = fcrt.getFrameCount(); - break; - } - } - switch(frameCount) { - case 24: - fct = FrameCountType.VALUE_24; - break; - case 25: - fct = FrameCountType.VALUE_25; - break; - case 30: - fct = FrameCountType.VALUE_30; - break; - } - return fct; - } - - public static TimeBaseType getTimeBaseForIndicator(char c) { - TimeBaseType tbt = null; - FrameCountTableType fctt; - String timeBase = null; - - fctt = tdet.getFrameCountTable(); - for (Iterator it = fctt.getRowAsReference().iterator(); it.hasNext() ;) { - FrameCountRowType fcrt; - - fcrt = (FrameCountRowType)it.next(); - if (fcrt.getIndicator() == c) { - timeBase = fcrt.getTimeBase(); - break; - } - } - if (timeBase.equals("Unknown")) { - tbt = TimeBaseType.UNKNOWN; - } - else if (timeBase.equals("1.000")) { - tbt = TimeBaseType.VALUE_1000; - } - else if (timeBase.equals("1.001")) { - tbt = TimeBaseType.VALUE_1001; - } - return tbt; - } - - - public static char getIndicatorForCountingModeAndVideoField(CountingModeType cmt, VideoFieldType vft) { - char indicator = (char)0; - CountingModeTableType cmtt; - int field = 0; - String countingmode = null; - - countingmode = cmt.toString(); - switch(vft.getType()) { - case VideoFieldType.FIELD_1_TYPE: - field = 1; - break; - case VideoFieldType.FIELD_2_TYPE: - field = 2; - break; - } - - cmtt = tdet.getCountingModeTable(); - for (Iterator it = cmtt.getRowAsReference().iterator(); it.hasNext() ;) { - CountingModeRowType cmrt; - - cmrt = (CountingModeRowType)it.next(); - if (cmrt.getCountingMode().equals(countingmode) && cmrt.getVideoField() == field) { - indicator = (char)cmrt.getIndicator(); - break; - } - } - return indicator; - } - - public static VideoFieldType getVideoFieldForIndicator(char c) { - int videoField = 0; - VideoFieldType vft = null; - CountingModeTableType cmtt; - - cmtt = tdet.getCountingModeTable(); - for (Iterator it = cmtt.getRowAsReference().iterator(); it.hasNext() ;) { - CountingModeRowType cmrt; - - cmrt = (CountingModeRowType)it.next(); - if (cmrt.getIndicator() == c) { - videoField = cmrt.getVideoField(); - break; - } - } - switch(videoField) { - case 1: - vft = VideoFieldType.FIELD_1; - break; - case 2: - vft = VideoFieldType.FIELD_2; - break; - } - return vft; - } - - public static CountingModeType getCountingModeForIndicator(char c) { - String countingmode = null; - CountingModeType cmt = null; - CountingModeTableType cmtt; - - cmtt = tdet.getCountingModeTable(); - for (Iterator it = cmtt.getRowAsReference().iterator(); it.hasNext() ;) { - CountingModeRowType cmrt; - - cmrt = (CountingModeRowType)it.next(); - if (cmrt.getIndicator() == c) { - countingmode = cmrt.getCountingMode(); - break; - } - } - if (countingmode.equals("PAL")) { - cmt = CountingModeType.PAL; - } - else if (countingmode.equals("NTSC_NON_DROP_FRAME")) { - cmt = CountingModeType.NTSC_NON_DROP_FRAME; - } - else if (countingmode.equals("NTSC_DROP_FRAME_TYPE")) { - cmt = CountingModeType.NTSC_DROP_FRAME; - } - return cmt; - } - - -} diff --git a/src/main/java/edu/harvard/hcl/hclaps/util/TimeLine.java b/src/main/java/edu/harvard/hcl/hclaps/util/TimeLine.java index a929b34..1b7ce6e 100755 --- a/src/main/java/edu/harvard/hcl/hclaps/util/TimeLine.java +++ b/src/main/java/edu/harvard/hcl/hclaps/util/TimeLine.java @@ -8,8 +8,6 @@ package edu.harvard.hcl.hclaps.util; import com.therockquarry.aes31.adl.*; -import edu.harvard.hcl.hclaps.audiomarker.*; -import edu.harvard.hcl.hclaps.audiomarker.types.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -171,60 +169,6 @@ public TimeLine(ADL adl, boolean includeGaps) { } } - /** - * Creates a new TimeLine from an audio marker document ignoring all PQ_INDEX markers - * and optionally including gaps between PQ_END and next PQ_START markers. - */ - public TimeLine(HclAudioMarkerDocumentElementType markerDocument, boolean includeGaps) { - ArrayList allMarkerList, markerList; - Iterator it; - ListIterator lit; - - markerList = new ArrayList(); - - sampleRate = markerDocument.getProjectSampleRate(); - // Ignore all index and comment markers by creating a new list with only start and end markers. - allMarkerList = (ArrayList)markerDocument.getMarkerAsReference(); - it = allMarkerList.iterator(); - while (it.hasNext()) { - MarkerElementType marker; - - marker = it.next(); - if (marker.getMarkerType() == MarkerTypeAttributeType.PQ_START || marker.getMarkerType() == MarkerTypeAttributeType.PQ_END) { - markerList.add(marker); - } - } - lit = markerList.listIterator(); - while (lit.hasNext()) { - MarkerElementType marker; - - marker = lit.next(); - if (marker.getMarkerType() == MarkerTypeAttributeType.PQ_START) { - TimeRange tr; - MarkerElementType nextMarker; - - nextMarker = markerList.get(lit.nextIndex()); - - if (includeGaps == true) { - if (nextMarker.getMarkerType() == MarkerTypeAttributeType.PQ_END) { - // Jump to the PQ_END marker - nextMarker = lit.next(); - if (lit.hasNext()) { - // This should always be a PQ_START. - nextMarker = markerList.get(lit.nextIndex()); - } - } - } - tr = new TimeRange(); - tr.setObject(marker); - tr.setStartSamples(marker.getSamplePosition()); - tr.setEndSamples(nextMarker.getSamplePosition()); - - addTimeRange(tr); - } - } - } - /** * Converts all time ranges in the time line to the specified sample rate. * diff --git a/src/main/java/edu/harvard/hcl/hclaps/util/tcfdata.xml b/src/main/java/edu/harvard/hcl/hclaps/util/tcfdata.xml deleted file mode 100755 index 545ff38..0000000 --- a/src/main/java/edu/harvard/hcl/hclaps/util/tcfdata.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -