Interface AdaptivePlaylist

All Superinterfaces:
Cloneable, Comparable<MediaPackageElement>, ManifestContributor, MediaPackageElement, Track

public interface AdaptivePlaylist extends 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.
  • Field Details

    • logger

      static final org.slf4j.Logger logger
      Media package element type.
    • uriPatt

      static final Pattern uriPatt
    • filePatt

      static final Pattern filePatt
    • extVariant

      static final List<String> extVariant
    • extMaster

      static final List<String> extMaster
    • masterPatt

      static final Pattern masterPatt
    • variantPatt

      static final Pattern variantPatt
    • isHLSFilePred

      static final Predicate<File> isHLSFilePred
    • isPlaylistPred

      static final Predicate<String> isPlaylistPred
    • isHLSTrackPred

      static final Predicate<Track> isHLSTrackPred
  • Method Details

    • isPlaylist

      static boolean isPlaylist(String filename)
    • isPlaylist

      static boolean isPlaylist(File file)
    • isPlaylist

      static boolean isPlaylist(Track track)
    • hasHLSPlaylist

      static boolean hasHLSPlaylist(Collection<MediaPackageElement> elements)
    • getSortedTracks

      static List<Track> getSortedTracks(List<Track> files, boolean segmentsOnly)
    • checkForMaster

      static boolean checkForMaster(File file) throws IOException
      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

      static boolean checkForVariant(File file) throws IOException
      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

      static Set<String> getVariants(File file) throws IOException
      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

      static Set<String> getReferencedFiles(File file, boolean segmentsOnly) throws IOException
      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

      static void setLogicalName(Track track)
      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 IOException
      Set HLS Tracks references to point to immediate parent, post inspection
      Parameters:
      tracks - - all tracks in an HLS adaptive playlist
      getFileFromURI - - a way to map uri to file
      Throws:
      IOException - if failed to read files
    • hlsRenameAllFiles

      static List<File> hlsRenameAllFiles(List<File> hlsFiles, Map<File,File> map) throws IOException
      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 playlists
      map - - the mapping of the references to the actual file location
      Returns:
      the fixed files
      Throws:
      IOException - if failed to read files
    • hlsRewriteFileReference

      static void hlsRewriteFileReference(File srcFile, Map<String,String> mapNames) throws IOException
      Fix all the HLS file references in a manifest when a referenced file is renamed
      Parameters:
      srcFile - - srcFile to be rewritten
      mapNames - - mapped from old name to new name
      Throws:
      IOException - if failed
    • hlsRewriteFileReference

      static void hlsRewriteFileReference(File srcFile, File destFile, Map<String,String> mapNames) throws IOException
      Fix 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 change
      destFile - - dest file to hold results
      mapNames - - mapping from oldName to newName
      Throws:
      IOException - if failed
    • logicalNameFileMap

      static Map<String,File> logicalNameFileMap(List<Track> tracks, Function<URI,File> getFileFromURI)
      Return logical name mapped to file
      Parameters:
      tracks - from a HLS manifest
      getFileFromURI - is a function to get file from an URI
      Returns:
      names mapped to file
    • logicalNameURLMap

      static Map<String,URI> logicalNameURLMap(List<Track> tracks)
    • urlRelativeToMasterMap

      static HashMap<String,String> urlRelativeToMasterMap(List<Track> tracks)
      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, NotFoundException
      Replace the content of a playlist file in place, use in composer only - not in workspace
      Parameters:
      file - as playlist
      map - - mapping from reference/logical name to new path
      Returns:
      playlist with changed file names based on the map
      Throws:
      IOException - if can't access file
      NotFoundException - if file not found
    • relativize

      static String relativize(URI referer, URI referee) throws URISyntaxException
      Find relative path to referee URL if a link is in the referer page
      Parameters:
      referer - - pointer to file
      referee - - pointee
      Returns:
      referee path as a relative path from referer URL
      Throws:
      URISyntaxException - if bad URI
    • relativizeF

      static File relativizeF(String s1, String s2) throws URISyntaxException
      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 playlist
      mpDir - - 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 missing
      IOException - if can't read
      URISyntaxException - if bad URI