use of org.opencastproject.silencedetection.api.MediaSegments in project opencast by opencast.
the class SilenceDetectionServiceImpl method process.
@Override
protected String process(Job job) throws SilenceDetectionFailedException, SmilException, MediaPackageException {
if (Operation.SILENCE_DETECTION.toString().equals(job.getOperation())) {
// get source track
String sourceTrackXml = StringUtils.trimToNull(job.getArguments().get(0));
if (sourceTrackXml == null) {
throw new SilenceDetectionFailedException("Track not set!");
}
Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);
// run detection on source track
MediaSegments segments = runDetection(sourceTrack);
// get reference tracks if any
List<Track> referenceTracks = null;
if (job.getArguments().size() > 1) {
String referenceTracksXml = StringUtils.trimToNull(job.getArguments().get(1));
if (referenceTracksXml != null) {
referenceTracks = (List<Track>) MediaPackageElementParser.getArrayFromXml(referenceTracksXml);
}
}
if (referenceTracks == null) {
referenceTracks = Arrays.asList(sourceTrack);
}
// create smil XML as result
try {
return generateSmil(segments, referenceTracks).toXML();
} catch (Exception ex) {
throw new SmilException("Failed to create smil document.", ex);
}
}
throw new SilenceDetectionFailedException("Can't handle this operation: " + job.getOperation());
}
Aggregations