public static SMILDocument getSmilDocumentFromMediaPackage(MediaPackage mp, MediaPackageElementFlavor smilFlavor, Workspace workspace) throws IOException, SAXException, NotFoundException { final AbstractMediaPackageElementSelector<Catalog> smilSelector = new CatalogSelector(); smilSelector.addFlavor(smilFlavor); final Collection<Catalog> smilCatalog = smilSelector.select(mp, false); if (smilCatalog.size() == 1) { return getSmilDocument(smilCatalog.iterator().next(), workspace); } else { logger.error("More or less than one smil catalog found: {}", smilCatalog); throw new IllegalStateException("More or less than one smil catalog found!"); } }
String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) {
/** * This base implementation will return those media package elements that match the type specified as the type * parameter to the class and that flavor (if specified) AND at least one of the tags (if specified) match. * * @see org.opencastproject.mediapackage.MediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, * boolean) */ @Override public Collection<T> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { return select(Arrays.asList(mediaPackage.getElements()), withTagsAndFlavors); }
return result; Class type = getParametrizedType(result); elementLoop: for (MediaPackageElement e : elements) {
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, * boolean) */ public Collection<T> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { Set<T> candidates = new HashSet<T>(); Set<T> result = new HashSet<T>(); // Have the super implementation match type, flavor and tags candidates.addAll(super.select(mediaPackage, withTagsAndFlavors)); if (flavors.isEmpty()) return candidates; // Return the first element based on the flavor buildResult: for (MediaPackageElementFlavor flavor : flavors) { for (T element : candidates) { if (flavor.equals(element.getFlavor())) { result.add(element); break buildResult; } } } return result; }
/** * Returns all tracks from a <code>MediaPackage</code> that contain at least a <code>Stream</code> of the parametrized * type while optionally matching other requirements such as flavors and tags. If no such combination can be found, i. * g. there is no audio or video at all, an empty array is returned. * * @see org.opencastproject.mediapackage.selector.AbstractMediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, boolean) */ @SuppressWarnings("unchecked") @Override public Collection<Track> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { Collection<Track> candidates = super.select(mediaPackage, withTagsAndFlavors); List<Track> result = new ArrayList<Track>(); for (Track t : candidates) { if (TrackSupport.byType(t.getStreams(), getParametrizedStreamType()).length > 0) { result.add(t); } } return result; }
Collection<Track> candidates = super.select(mediaPackage, withTagsAndFlavors); Set<Track> result = new HashSet<Track>();