Class Download

java.lang.Object
com.castlabs.sdk.downloader.Download
All Implemented Interfaces:
Serializable

public class Download extends Object implements Serializable
The download model class
See Also:
  • Field Details

    • STATE_QUEUED

      public static final int STATE_QUEUED
      The download is queued for loading
      See Also:
    • STATE_LOADING

      public static final int STATE_LOADING
      The download is currently downloading
      See Also:
    • STATE_ERROR

      public static final int STATE_ERROR
      At least one chunk download failed and the download is in error state
      See Also:
    • STATE_DONE

      public static final int STATE_DONE
      The download is completed
      See Also:
    • STATE_IDLE

      public static final int STATE_IDLE
      The download is paused
      See Also:
  • Constructor Details

    • Download

      public Download(@NonNull String id, @NonNull String remoteUrl, @NonNull File localBaseFolder, boolean mergeVideoTracks)
      Create Download with specified Id, manifest URL and base folder for storage.
      Parameters:
      id - Current download Id
      remoteUrl - Manifest remote URL
      localBaseFolder - Base folder for storing current download
  • Method Details

    • getId

      @NonNull public String getId()
      Returns:
      The unique ID that identifies this download
    • getRemoteUrl

      @NonNull public String getRemoteUrl()
      Returns:
      The remote URL that us the primary source for this download
    • getLocalBaseFolder

      @NonNull public File getLocalBaseFolder()
      The local folder that contains the files for this download. Each download usually has a unique folder that contains all files related to this download.
      Returns:
      The local folder that contains the files for this download
    • getMergeVideoTracks

      public boolean getMergeVideoTracks()
      The flag specifying the video tracks should be merged or not
      Returns:
      The merge video tracks flag
    • getVideoTrackQualities

      @Nullable public VideoTrackQuality[] getVideoTrackQualities()
      All available (remote) video representations. This represents all video qualities that are available on the remote, not only the locally available representations.
      Returns:
      All available video representations
    • getTrickPlayTrackQualities

      @Nullable public VideoTrackQuality[] getTrickPlayTrackQualities()
      All available (remote) trick-play representations. This represents all trick-play qualities that are available on the remote, not only the locally available representations.
      Returns:
      All available trick-play representations
    • getDownloadedSize

      public long getDownloadedSize()
      Returns the size in bytes of the currently download data on disk.
      Returns:
      Currently downloaded data
    • getAudioTracks

      @Nullable public AudioTrack[] getAudioTracks()
      Get all available (remote) audio tracks or null if no audio tracks are available. This represents all audio tracks that are available on the remote, not only the locally available tracks.
      Returns:
      The available (remote) audio tracks
    • getSubtitleTracks

      @Nullable public SubtitleTrack[] getSubtitleTracks()
      Get all available (remote) subtitle tracks or null if no subtitle tracks are available. This represents all subtitle tracks that are available on the remote, not only the locally available tracks.
      Returns:
      The available (remote) subtitle tracks
    • getSelectedVideoTrackQuality

      public int getSelectedVideoTrackQuality()
      Get the index of the selected video track
      Returns:
      The index of the selected video track.
    • setSelectedVideoTrackQuality

      public void setSelectedVideoTrackQuality(int selectedVideoTrackQuality)
      Set the selected video track quality using its index in the list of available representations.
      Parameters:
      selectedVideoTrackQuality - The video track quality index
    • getSelectedTrickPlayTrackQuality

      public int getSelectedTrickPlayTrackQuality()
      Get the index of the selected trick-play track
      Returns:
      The index of the selected trick-play track.
    • setSelectedTrickPlayTrackQuality

      public void setSelectedTrickPlayTrackQuality(int selectedTrickPlayTrackQuality)
      Set the selected trick-play track quality using its index in the list of available representations.
      Parameters:
      selectedTrickPlayTrackQuality - The trick-play track quality index
    • getSelectedAudioTracks

      @Nullable public int[] getSelectedAudioTracks()
      Get the array of selected audio tracks by index
      Returns:
      The array of selected audio tracks by index
    • setSelectedAudioTracks

      public void setSelectedAudioTracks(@Nullable int[] selectedAudioTracks)
      Set the array of selected audio tracks
      Parameters:
      selectedAudioTracks - The selected audio tracks
    • getSelectedSubtitleTracks

      @Nullable public int[] getSelectedSubtitleTracks()
      Returns:
      The array of selected subtitle tracks by index
    • setSelectedSubtitleTracks

      public void setSelectedSubtitleTracks(@Nullable int[] selectedSubtitleTracks)
      Set the selected subtitle tracks by index
      Parameters:
      selectedSubtitleTracks - The selected subtitle tracks by index
    • getLocalManifestUrl

      @Nullable public String getLocalManifestUrl()
      Returns the path to the local Manifest. Once the download is completed, this path can be used to start playback of the local content.
      Returns:
      The path to the local manifest
    • getDrmConfiguration

      @Nullable public DrmConfiguration getDrmConfiguration()
      Returns the content DRM configuration.
      Returns:
      Content DRM configuration
    • getState

      public int getState()
      Get the current state of this download
      Returns:
      The current state of this download
    • getEstimatedSize

      public long getEstimatedSize()
      Returns the total size of all selected tracks of this download.

      Note that the manifest size only will be returned when no tracks are selected.

      Please also note that the number of bytes returned here is an estimate of the total size of the download. Depending on the download source, i.e. file, DASH, or SmoothStreaming, information from the source is used to create this estimate. For example, for SmoothStreaming content, a track size is estimated based on the bitrate and the duration of the track. The same is true for segmented DASH. If a DASH source is based on single files, we try to use the information from the manifest that is used to generate the range requests to estimate the size. The latter is more accurate than simply using the specified bitrate, but it is still an estimate.

      Returns:
      The estimated size in bytes of this download
    • getSize

      public long getSize(int mediaType, int trackIndex)
      Returns the size of the chunk with the given media type, i.e SdkConsts.VIDEO, SdkConsts.AUDIO, SdkConsts.TEXT, or SdkConsts.OTHER, and its track index.
      Parameters:
      mediaType - The media type
      trackIndex - The track index
      Returns:
      The size in bytes or 0
    • getSize

      public long getSize(int mediaType, int trackIndex, boolean isTrickPlay)
      Returns the size of the chunk with the given media type, i.e SdkConsts.VIDEO, SdkConsts.AUDIO, SdkConsts.TEXT, or SdkConsts.OTHER, and its track index.
      Parameters:
      mediaType - The media type
      trackIndex - The track index
      isTrickPlay - Whether the track is trick-play or not
      Returns:
      The size in bytes or 0
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object
    • getSubtitleTrackDownloads

      public com.castlabs.sdk.downloader.TrackDownload[] getSubtitleTrackDownloads()
    • getHeaderParams

      @NonNull public Bundle getHeaderParams()
      Returns a Bundle with the extra header key:values that will be added to the requests.

      This Bundle will contain the headers informed with the SdkConsts.INTENT_HEADER_PARAMS_BUNDLE key in the Bundle passed to DownloadServiceBinder.prepareDownload(Context, Bundle, Downloader.ModelReadyCallback).

      Returns:
      a Bundle with the extra header key:values that will be added to the requests.
    • setHeaderParams

      public void setHeaderParams(@Nullable Bundle headers)
      Sets the headers to add to the download requests.

      If null, all already existing headers will be cleared.

      Parameters:
      headers - a Bundle containing headers to add to the download requests
    • getQueryParams

      @NonNull public Bundle getQueryParams()
      Returns a Bundle with the extra query params that will be added to the requests.

      This Bundle will contain the query params informed with the SdkConsts.INTENT_QUERY_PARAMS_BUNDLE key in the Bundle passed to DownloadServiceBinder.prepareDownload(Context, Bundle, Downloader.ModelReadyCallback).

      Returns:
      a Bundle with the extra query params that will be added to the requests.
    • setQueryParams

      public void setQueryParams(@Nullable Bundle queryParams)
      Sets the query params to add to the download requests.

      If null, all already existing query params will be cleared.

      Parameters:
      queryParams - a Bundle containing query params to add to the download requests