Package org.opencastproject.mediapackage
Class MediaPackageImpl
java.lang.Object
org.opencastproject.mediapackage.MediaPackageImpl
- All Implemented Interfaces:
Cloneable,MediaPackage
Default implementation for a media media package.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA JAXB adapter that allows theMediaPackageinterface to be un/marshalled -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe prefix indicating that a tag should be excluded from a search for elements usinggetElementsByTags(Collection) -
Method Summary
Modifier and TypeMethodDescriptionAdds an arbitraryURIto this media package, utilizing aMediaPackageBuilderto create a suitable media package element out of the url.add(URI uri, MediaPackageElement.Type type, MediaPackageElementFlavor flavor) Adds an arbitraryURIto this media package, utilizing aMediaPackageBuilderto create a suitable media package element out of the url.voidadd(Attachment attachment) Adds an attachment to this media package.voidAdds catalog information to this media package.voidadd(MediaPackageElement element) Adds an arbitraryMediaPackageElementto this media package.voidAdds a track to this media package, actually moving the underlying file in the filesystem.voidaddContributor(String contributor) voidaddCreator(String creator) voidaddDerived(MediaPackageElement derivedElement, MediaPackageElement sourceElement) Adds an element to this media package that represents a derived version ofsourceElement.voidaddSubject(String subject) clone()Creates a deep copy of the media package.booleancontains(MediaPackageElement element) Returnstrueif the given element is part of the media package.elements()Returns an iteration of the media package elements.booleangetAttachment(String attachmentId) Returns the attachment identified byattachmentIdornullif that attachment does not exist.Returns the attachments that are part of this media package.Returns the attachments that are part of this media package and match the specified flavor.getCatalog(String catalogId) Returns the catalog identified bycatalogIdornullif that catalog doesn't exists.Catalog[]Returns the catalogs associated with this media package.Catalog[]getCatalogs(MediaPackageElementFlavor flavor) Returns the catalogs associated with this media package that matches the specified flavor.Catalog[]getCatalogs(MediaPackageElementFlavor flavor, MediaPackageReference reference) Returns the catalogs that are part of this media package and are refering to the element identified byreference.Catalog[]getCatalogs(MediaPackageReference reference) Returns the catalogs that are part of this media package and are refering to the element identified byreference.Catalog[]getCatalogsByTags(Collection<String> tags) Returns the catalogs that are tagged with any of the given tags or an empty array if no such elements are found.String[]Returns the names of the institutions or people who contributed to the content within this mediapackageString[]Returns the names of the institutions or people who created this mediapackagegetDate()Returns the media package start time.getDerived(MediaPackageElement sourceElement, MediaPackageElementFlavor derivateFlavor) Returns those media package elements that are derivates ofsourceElementand feature the flavorderivateFlavor.Returns the media package duration in milliseconds ornullif no duration is available.getElementById(String id) Returns the element that is identified by the given identifier ornullif no such element exists.getElementByReference(MediaPackageReference reference) Returns the element that is identified by the given reference ornullif no such element exists.Returns all the elements.Returns all elements of this media package with the given flavor.getElementsByTags(Collection<String> tags) Returns the elements that are tagged with any of the given tags or an empty array if no such elements are found.Returns the media package identifier.Returns the language written and/or spoken in the media content of this mediapackageThe license for the content in this mediapackageReturns the presentations that are part of this media package.Returns the series, if any, to which this mediapackage belongsReturns the title for the associated series, if any.Returns the recording time in utc format.String[]The keywords describing the subject(s) or categories describing the content of this mediapackagegetTitle()Returns the title of the episode that this mediapackage represents.Returns the track identified bytrackIdornullif that track doesn't exists.Track[]Returns the tracks that are part of this media package.Track[]getTracks(MediaPackageElementFlavor flavor) Returns the tracks that are part of this media package and match the given flavor as defined inTrack.Track[]getTracksByTag(String tag) Returns the tracks that are tagged with the given tag or an empty array if no such tracks are found.Track[]getTracksByTags(Collection<String> tags) Returns the tracks that are tagged with any of the given tags or an empty array if no such elements are found.Returns media package elements that are neither, attachments, catalogs nor tracks.inthashCode()booleanReturnstrueif the media package contains media tracks of any kind.booleanisLive()Whether the media package contains live tracks.voidremove(Attachment attachment) Removes the attachment from the media package.voidRemoves the catalog from the media package.voidremove(MediaPackageElement element) Removes an arbitrary media package element.voidRemoves the track from the media package.voidremoveContributor(String contributor) voidremoveCreator(String creator) Removes the element with the given identifier from the mediapackage and returns it.voidremoveSubject(String subject) voidvoidsetDuration(Long duration) Sets the duration of the media package in milliseconds.voidsetIdentifier(Id identifier) voidsetLanguage(String language) voidsetLicense(String license) voidvoidsetSeriesTitle(String seriesTitle) voidsetStartDateAsString(String startTime) Sets the date and time of recording in utc format.voidtoString()static MediaPackageImplvalueOf(InputStream xml) Reads the media package from the input stream.static MediaPackageImplUnmarshals XML representation of a MediaPackage via JAXB.static MediaPackageImplReads the media package from an xml node.voidverify()Verifies the media package consistency by checking the media package elements for mimetypes and checksums.
-
Field Details
-
NEGATE_TAG_PREFIX
The prefix indicating that a tag should be excluded from a search for elements usinggetElementsByTags(Collection)- See Also:
-
-
Method Details
-
getIdentifier
Returns the media package identifier.- Specified by:
getIdentifierin interfaceMediaPackage- Returns:
- the identifier
- See Also:
-
setIdentifier
- Specified by:
setIdentifierin interfaceMediaPackage- See Also:
-
getDuration
Returns the media package duration in milliseconds ornullif no duration is available.- Specified by:
getDurationin interfaceMediaPackage- Returns:
- the duration
- See Also:
-
setDuration
Sets the duration of the media package in milliseconds. This method will throw anIllegalStateExceptionif tracks have been added to the mediapackage already. Also note that as soon as the first track is added, the duration will be udpated according to the track's length.- Specified by:
setDurationin interfaceMediaPackage- Parameters:
duration- the duration in milliseconds- Throws:
IllegalStateException- if the mediapackage already contains a track- See Also:
-
getDate
Returns the media package start time.- Specified by:
getDatein interfaceMediaPackage- Returns:
- the start time
- See Also:
-
getStartDateAsString
Returns the recording time in utc format.- Returns:
- the recording time
-
setStartDateAsString
Sets the date and time of recording in utc format.- Parameters:
startTime- the start time
-
elements
Returns an iteration of the media package elements.- Specified by:
elementsin interfaceMediaPackage- Returns:
- the media package elements
- See Also:
-
getElements
Returns all the elements.- Specified by:
getElementsin interfaceMediaPackage- Returns:
- the elements
- See Also:
-
getElementByReference
Returns the element that is identified by the given reference ornullif no such element exists.- Specified by:
getElementByReferencein interfaceMediaPackage- Parameters:
reference- the reference- Returns:
- the element
- See Also:
-
getElementById
Description copied from interface:MediaPackageReturns the element that is identified by the given identifier ornullif no such element exists.- Specified by:
getElementByIdin interfaceMediaPackage- Parameters:
id- the element identifier- Returns:
- the element
- See Also:
-
getElementsByTags
Returns the elements that are tagged with any of the given tags or an empty array if no such elements are found. If any of the tags in thetagscollection start with a '-' character, any elements matching the tag will be excluded from the returned MediaPackageElement[]. Iftagsis empty or null, all elements are returned.- Specified by:
getElementsByTagsin interfaceMediaPackage- Parameters:
tags- the tags- Returns:
- the elements
- See Also:
-
getCatalogsByTags
Returns the catalogs that are tagged with any of the given tags or an empty array if no such elements are found. If any of the tags in thetagscollection start with a '-' character, any elements matching the tag will be excluded from the returned Catalog[]. Iftagsis empty or null, all catalogs are returned.- Specified by:
getCatalogsByTagsin interfaceMediaPackage- Parameters:
tags- the tags- Returns:
- the catalogs
- See Also:
-
getTracksByTags
Returns the tracks that are tagged with any of the given tags or an empty array if no such elements are found. If any of the tags in thetagscollection start with a '-' character, any elements matching the tag will be excluded from the returned Track[]. Iftagsis empty or null, all tracks are returned.- Specified by:
getTracksByTagsin interfaceMediaPackage- Parameters:
tags- the tags- Returns:
- the tracks
- See Also:
-
getElementsByFlavor
Returns all elements of this media package with the given flavor.- Specified by:
getElementsByFlavorin interfaceMediaPackage- Returns:
- the media package elements
- See Also:
-
contains
Description copied from interface:MediaPackageReturnstrueif the given element is part of the media package.- Specified by:
containsin interfaceMediaPackage- Parameters:
element- the element- Returns:
trueif the element belongs to the media package- See Also:
-
add
Description copied from interface:MediaPackageAdds catalog information to this media package.- Specified by:
addin interfaceMediaPackage- Parameters:
catalog- the catalog- See Also:
-
add
Description copied from interface:MediaPackageAdds a track to this media package, actually moving the underlying file in the filesystem. Use this method only if you do not need the track in its originial place anymore.Depending on the implementation, this method may provide significant performance benefits over copying the track.
- Specified by:
addin interfaceMediaPackage- Parameters:
track- the track- See Also:
-
add
Description copied from interface:MediaPackageAdds an attachment to this media package.- Specified by:
addin interfaceMediaPackage- Parameters:
attachment- the attachment- See Also:
-
getCatalog
Description copied from interface:MediaPackageReturns the catalog identified bycatalogIdornullif that catalog doesn't exists.- Specified by:
getCatalogin interfaceMediaPackage- Parameters:
catalogId- the catalog identifier- Returns:
- the catalogs
- See Also:
-
getCatalogs
Description copied from interface:MediaPackageReturns the catalogs associated with this media package.- Specified by:
getCatalogsin interfaceMediaPackage- Returns:
- the catalogs
- See Also:
-
getCatalogs
Description copied from interface:MediaPackageReturns the catalogs associated with this media package that matches the specified flavor.- Specified by:
getCatalogsin interfaceMediaPackage- Parameters:
flavor- the catalog type- Returns:
- the media package catalogs
- See Also:
-
getCatalogs
Description copied from interface:MediaPackageReturns the catalogs that are part of this media package and are refering to the element identified byreference.- Specified by:
getCatalogsin interfaceMediaPackage- Parameters:
reference- the reference- Returns:
- the catalogs with the specified reference
- See Also:
-
getCatalogs
Description copied from interface:MediaPackageReturns the catalogs that are part of this media package and are refering to the element identified byreference.- Specified by:
getCatalogsin interfaceMediaPackage- Parameters:
flavor- the element flavorreference- the reference- Returns:
- the catalogs with the specified reference
- See Also:
-
getTrack
Returns the track identified bytrackIdornullif that track doesn't exists.- Specified by:
getTrackin interfaceMediaPackage- Parameters:
trackId- the track identifier- Returns:
- the tracks
- See Also:
-
getTracks
Returns the tracks that are part of this media package.- Specified by:
getTracksin interfaceMediaPackage- Returns:
- the tracks
- See Also:
-
getTracksByTag
Returns the tracks that are tagged with the given tag or an empty array if no such tracks are found.- Specified by:
getTracksByTagin interfaceMediaPackage- Parameters:
tag- the tag- Returns:
- the tracks
- See Also:
-
getTracks
Returns the tracks that are part of this media package and match the given flavor as defined inTrack.- Specified by:
getTracksin interfaceMediaPackage- Parameters:
flavor- the track's flavor- Returns:
- the tracks with the specified flavor
- See Also:
-
hasTracks
public boolean hasTracks()Returnstrueif the media package contains media tracks of any kind.- Specified by:
hasTracksin interfaceMediaPackage- Returns:
trueif the media package contains tracks- See Also:
-
getUnclassifiedElements
Returns media package elements that are neither, attachments, catalogs nor tracks.- Specified by:
getUnclassifiedElementsin interfaceMediaPackage- Returns:
- the other media package elements
- See Also:
-
getAttachment
Returns the attachment identified byattachmentIdornullif that attachment does not exist.- Specified by:
getAttachmentin interfaceMediaPackage- Parameters:
attachmentId- the attachment identifier- Returns:
- the attachments
- See Also:
-
getAttachments
Returns the attachments that are part of this media package.- Specified by:
getAttachmentsin interfaceMediaPackage- Returns:
- the attachments
- See Also:
-
getAttachments
Returns the attachments that are part of this media package and match the specified flavor.- Specified by:
getAttachmentsin interfaceMediaPackage- Parameters:
flavor- the attachment flavor- Returns:
- the attachments
- See Also:
-
getPublications
Returns the presentations that are part of this media package.- Specified by:
getPublicationsin interfaceMediaPackage- Returns:
- the attachments
- See Also:
-
removeElementById
Removes the element with the given identifier from the mediapackage and returns it.- Specified by:
removeElementByIdin interfaceMediaPackage- Parameters:
id- the element identifier- See Also:
-
remove
Removes an arbitrary media package element.- Specified by:
removein interfaceMediaPackage- Parameters:
element- the media package element- See Also:
-
remove
Removes the attachment from the media package.- Specified by:
removein interfaceMediaPackage- Parameters:
attachment- the attachment- See Also:
-
remove
Removes the catalog from the media package.- Specified by:
removein interfaceMediaPackage- Parameters:
catalog- the catalog- See Also:
-
remove
Removes the track from the media package.- Specified by:
removein interfaceMediaPackage- Parameters:
track- the track- See Also:
-
add
Adds an arbitraryURIto this media package, utilizing aMediaPackageBuilderto create a suitable media package element out of the url. If the content cannot be recognized as being either a metadata catalog or multimedia track, it is added as an attachment.- Specified by:
addin interfaceMediaPackage- Parameters:
url- the element location- See Also:
-
add
public MediaPackageElement add(URI uri, MediaPackageElement.Type type, MediaPackageElementFlavor flavor) Description copied from interface:MediaPackageAdds an arbitraryURIto this media package, utilizing aMediaPackageBuilderto create a suitable media package element out of the url. If the content cannot be recognized as being either a metadata catalog or multimedia track, it is added as an attachment.- Specified by:
addin interfaceMediaPackage- Parameters:
uri- the element locationtype- the element typeflavor- the element flavor- See Also:
-
add
Adds an arbitraryMediaPackageElementto this media package.- Specified by:
addin interfaceMediaPackage- Parameters:
element- the element- See Also:
-
addDerived
Adds an element to this media package that represents a derived version ofsourceElement. Examples of a derived element could be an encoded version of a track or a converted version of a time text captions file.This method will add
derviedElementto the media package and add a reference to the original elementsourceElement. Make sure thatderivedElementfeatures the right flavor, so that you are later able to look up derived work usingMediaPackage.getDerived(MediaPackageElement, MediaPackageElementFlavor).- Specified by:
addDerivedin interfaceMediaPackage- Parameters:
derivedElement- the derived elementsourceElement- the source element- See Also:
-
getDerived
public MediaPackageElement[] getDerived(MediaPackageElement sourceElement, MediaPackageElementFlavor derivateFlavor) Returns those media package elements that are derivates ofsourceElementand feature the flavorderivateFlavor. Using this method, you could easily look up e. g. flash-encoded versions of the presenter track or converted versions of a time text captions file.- Specified by:
getDerivedin interfaceMediaPackage- Parameters:
sourceElement- the original track, catalog or attachmentderivateFlavor- the derivate flavor you are looking for- Returns:
- the derivates
- See Also:
-
verify
Description copied from interface:MediaPackageVerifies the media package consistency by checking the media package elements for mimetypes and checksums.- Specified by:
verifyin interfaceMediaPackage- Throws:
MediaPackageException- if an error occurs while checking the media package- See Also:
-
valueOf
Unmarshals XML representation of a MediaPackage via JAXB.- Parameters:
xml- the serialized xml string- Returns:
- the deserialized media package
- Throws:
MediaPackageException
-
hashCode
public int hashCode() -
equals
-
clone
Creates a deep copy of the media package.- Specified by:
clonein interfaceMediaPackage- Overrides:
clonein classObject- Returns:
- the cloned media package
- See Also:
-
toString
-
valueOf
Reads the media package from the input stream.- Parameters:
xml- the input stream- Returns:
- the deserialized media package
- Throws:
MediaPackageException
-
valueOf
Reads the media package from an xml node.- Parameters:
xml- the node- Returns:
- the deserialized media package
- Throws:
MediaPackageException
-
getContributors
Returns the names of the institutions or people who contributed to the content within this mediapackage- Specified by:
getContributorsin interfaceMediaPackage- Returns:
- the contributors
- See Also:
-
getCreators
Returns the names of the institutions or people who created this mediapackage- Specified by:
getCreatorsin interfaceMediaPackage- Returns:
- the creators of this mediapackage
- See Also:
-
getLanguage
Returns the language written and/or spoken in the media content of this mediapackage- Specified by:
getLanguagein interfaceMediaPackage- Returns:
- the language
- See Also:
-
getLicense
The license for the content in this mediapackage- Specified by:
getLicensein interfaceMediaPackage- Returns:
- the license
- See Also:
-
getSeries
Returns the series, if any, to which this mediapackage belongs- Specified by:
getSeriesin interfaceMediaPackage- Returns:
- the series
- See Also:
-
getSubjects
The keywords describing the subject(s) or categories describing the content of this mediapackage- Specified by:
getSubjectsin interfaceMediaPackage- Returns:
- the subjects
- See Also:
-
getTitle
Returns the title of the episode that this mediapackage represents.- Specified by:
getTitlein interfaceMediaPackage- Returns:
- The episode title
- See Also:
-
getSeriesTitle
Returns the title for the associated series, if any.- Specified by:
getSeriesTitlein interfaceMediaPackage- Returns:
- The series title
- See Also:
-
setSeriesTitle
- Specified by:
setSeriesTitlein interfaceMediaPackage- See Also:
-
addContributor
- Specified by:
addContributorin interfaceMediaPackage- See Also:
-
addCreator
- Specified by:
addCreatorin interfaceMediaPackage- See Also:
-
addSubject
- Specified by:
addSubjectin interfaceMediaPackage- See Also:
-
removeContributor
- Specified by:
removeContributorin interfaceMediaPackage- See Also:
-
removeCreator
- Specified by:
removeCreatorin interfaceMediaPackage- See Also:
-
removeSubject
- Specified by:
removeSubjectin interfaceMediaPackage- See Also:
-
setDate
- Specified by:
setDatein interfaceMediaPackage- See Also:
-
setLanguage
- Specified by:
setLanguagein interfaceMediaPackage- See Also:
-
setLicense
- Specified by:
setLicensein interfaceMediaPackage- See Also:
-
setSeries
- Specified by:
setSeriesin interfaceMediaPackage- See Also:
-
setTitle
- Specified by:
setTitlein interfaceMediaPackage- See Also:
-
isLive
public boolean isLive()Description copied from interface:MediaPackageWhether the media package contains live tracks.- Specified by:
isLivein interfaceMediaPackage- Returns:
- if mp is live
-