Package org.opencastproject.mediapackage
Interface AdaptivePlaylist
- All Superinterfaces:
Cloneable,Comparable<MediaPackageElement>,ManifestContributor,MediaPackageElement,Track
HLS-VOD
This interface describes methods and fields for an adaptive manifest playlist. as defined in
https://tools.ietf.org/html/draft-pantos-http-live-streaming-20 This is text file which references media tracks or
playlists in the same mediapackage using relative path names (usual) or absolute URI. Master Playlist tags MUST NOT
appear in a Media Playlist; Media Segment tag MUST NOT appear in a Master Playlist.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFix HLS playlists/media already in the workspace as the result of an ingest This builds the hierarchies of a HLS playlist with masters as the roots.static classNested classes/interfaces inherited from interface org.opencastproject.mediapackage.MediaPackageElement
MediaPackageElement.Type -
Field Summary
Fields -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleancheckForMaster(File file) Return true if this is a master manifest (contains variants manifest and no media segments)static booleancheckForVariant(File file) Return true if this is a variant manifest (contains media segments only)fixReferences(List<Track> tracks, File mpDir) Fix the playlist references in a publication.getReferencedFiles(File file, boolean segmentsOnly) Given a playlist - recursively get all referenced files in the same filesystem with relative linksgetSortedTracks(List<Track> files, boolean segmentsOnly) getVariants(File file) Given a master or variant playlist/manifest - get referenced files.static booleanhasHLSPlaylist(Collection<MediaPackageElement> elements) Fix all the playlists locations and references based on a file map from old name to new name.static voidFix all the HLS file references in a manifest when a referenced file is renamed All the mapped files should be in the same directory, make sure they are not workspace files (no md5)static voidhlsRewriteFileReference(File srcFile, Map<String, String> mapNames) Fix all the HLS file references in a manifest when a referenced file is renamedstatic voidSet HLS Tracks references to point to immediate parent, post inspectionstatic booleanisPlaylist(File file) static booleanisPlaylist(String filename) static booleanisPlaylist(Track track) Return logical name mapped to filelogicalNameURLMap(List<Track> tracks) static Stringrelativize(URI referer, URI referee) Find relative path to referee URL if a link is in the referer pagestatic FilerelativizeF(String s1, String s2) static FilereplaceTrackFileInPlace(File file, Map<String, String> map) Replace the content of a playlist file in place, use in composer only - not in workspacestatic voidsetLogicalName(Track track) Set the path of the url as the logical nameurlRelativeToMasterMap(List<Track> tracks) Return track urls as relative to the master playlist (only one in the list)Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.opencastproject.mediapackage.ManifestContributor
toManifestMethods inherited from interface org.opencastproject.mediapackage.MediaPackageElement
addTag, clearReference, clearTags, clone, containsTag, containsTag, generateIdentifier, getChecksum, getElementDescription, getElementType, getFlavor, getIdentifier, getMediaPackage, getMimeType, getReference, getSize, getTags, getURI, referTo, referTo, removeTag, setChecksum, setElementDescription, setFlavor, setIdentifier, setMimeType, setReference, setSize, setTags, setURI, verifyMethods inherited from interface org.opencastproject.mediapackage.Track
getDescription, getDuration, getLogicalName, getStreams, hasAudio, hasMaster, hasSubtitle, hasVideo, isLive, isMaster, setLogicalName, setMaster
-
Field Details
-
logger
static final org.slf4j.Logger loggerMedia package element type. -
uriPatt
-
filePatt
-
extVariant
-
extMaster
-
masterPatt
-
variantPatt
-
isHLSFilePred
-
isPlaylistPred
-
isHLSTrackPred
-
-
Method Details
-
isPlaylist
-
isPlaylist
-
isPlaylist
-
hasHLSPlaylist
-
getSortedTracks
-
checkForMaster
Return true if this is a master manifest (contains variants manifest and no media segments)- Parameters:
file- - media file- Returns:
- true if is a master manifest
- Throws:
IOException- if bad file
-
checkForVariant
Return true if this is a variant manifest (contains media segments only)- Parameters:
file- - media file- Returns:
- true if is a HLS playlist but not master
- Throws:
IOException- if bad file - can't access or otherwise
-
getVariants
Given a master or variant playlist/manifest - get referenced files. This does not deal with files referenced by tags yet.- Parameters:
file- to parse- Returns:
- Set of names referenced
- Throws:
IOException- if can't access file
-
getReferencedFiles
Given a playlist - recursively get all referenced files in the same filesystem with relative links- Parameters:
file- media file- Returns:
- Set of names referenced
- Throws:
IOException- if can't access file
-
setLogicalName
Set the path of the url as the logical name- Parameters:
track- - tag with name
-
hlsSetReferences
static void hlsSetReferences(List<Track> tracks, Function<URI, File> getFileFromURI) throws IOExceptionSet HLS Tracks references to point to immediate parent, post inspection- Parameters:
tracks- - all tracks in an HLS adaptive playlistgetFileFromURI- - a way to map uri to file- Throws:
IOException- if failed to read files
-
hlsRenameAllFiles
Fix all the playlists locations and references based on a file map from old name to new name.- Parameters:
hlsFiles- - List of all files in a playlist including playlistsmap- - the mapping of the references to the actual file location- Returns:
- the fixed files
- Throws:
IOException- if failed to read files
-
hlsRewriteFileReference
Fix all the HLS file references in a manifest when a referenced file is renamed- Parameters:
srcFile- - srcFile to be rewrittenmapNames- - mapped from old name to new name- Throws:
IOException- if failed
-
hlsRewriteFileReference
static void hlsRewriteFileReference(File srcFile, File destFile, Map<String, String> mapNames) throws IOExceptionFix all the HLS file references in a manifest when a referenced file is renamed All the mapped files should be in the same directory, make sure they are not workspace files (no md5)- Parameters:
srcFile- - source file to changedestFile- - dest file to hold resultsmapNames- - mapping from oldName to newName- Throws:
IOException- if failed
-
logicalNameFileMap
Return logical name mapped to file- Parameters:
tracks- from a HLS manifestgetFileFromURI- is a function to get file from an URI- Returns:
- names mapped to file
-
logicalNameURLMap
-
urlRelativeToMasterMap
Return track urls as relative to the master playlist (only one in the list)- Parameters:
tracks- from an HLS playlist- Returns:
- track urls as relative to the master playlist
-
replaceTrackFileInPlace
static File replaceTrackFileInPlace(File file, Map<String, String> map) throws IOException, NotFoundExceptionReplace the content of a playlist file in place, use in composer only - not in workspace- Parameters:
file- as playlistmap- - mapping from reference/logical name to new path- Returns:
- playlist with changed file names based on the map
- Throws:
IOException- if can't access fileNotFoundException- if file not found
-
relativize
Find relative path to referee URL if a link is in the referer page- Parameters:
referer- - pointer to filereferee- - pointee- Returns:
- referee path as a relative path from referer URL
- Throws:
URISyntaxException- if bad URI
-
relativizeF
- Throws:
URISyntaxException
-
fixReferences
static List<Track> fixReferences(List<Track> tracks, File mpDir) throws MediaPackageException, NotFoundException, IOException, URISyntaxException Fix the playlist references in a publication. The playlist files are replaced in place using relative link instead of the filename- Parameters:
tracks- - tracks that represent a HLS playlistmpDir- - distribution media package file directory which represents the file storage of the URI used in the tracks- Returns:
- the tracks with the files updated
- Throws:
MediaPackageException- if files do not conform to HLS spec.NotFoundException- if files are missingIOException- if can't readURISyntaxException- if bad URI
-