OTVPersistenceManager


@interface OTVPersistenceManager : NSObject

OTVPersistenceManager is a singleton that manages all download related functionality. It utilises OTVDownloadingAssetManager for outstanding downloads and OTVAssetsManager for completed downloads.

  • Declaration

    Objective-C

    @property (nonatomic, class, readonly, strong) OTVPersistenceManager * _Nonnull shared
  • Start a media stream dowloading. note: You MUST NOT share the same license delegate instance for multiple downloading. \param urlAsset Asset needs to be downloaded

    \param title Stream’s title

    \param licenseDelegate Delegate to fetch the license

    \param artwork artwork Data

    \param options download options

    returns: an asset created for this download.

    Declaration

    Objective-C

    - (OTVPersistenceAsset *_Nullable)
        startDownloadWithUrlAsset:(AVURLAsset *_Nonnull)urlAsset
                            title:(NSString *_Nonnull)title
                  licenseDelegate:(id<OTVLicenseDelegate> _Nullable)licenseDelegate
                          artwork:(NSData *_Nullable)artwork
                          options:(NSDictionary<NSString *, id> *_Nullable)options;
  • Start Preparing a media stream ready for dowloading. note:

    • To begin the download you must wait for the prepared download state on the OTVPersistenceAsset returned here.
    • Once the OTVPersistenceAsset has entered prepared state:
      • You can check the mediaInfo values on the OTVPersistenceAsset
      • You can query the OTVPersistenceAsset.mediaInfo.availableStreamInfo to see all the information needed to start downloading the asset.
      • You can query the OTVPersistenceAsset.mediaInfo.availableDrmInfo to get the drm information of the asset.
    • You SHOULD retain the object returned from preparedDownload, and pass the object to call startDownload: persistenceAsset… when state is changed to Prepared

    \param url Url of asset needs to be downloaded

    \param title Stream’s title

    returns: an asset created for this download.

    Declaration

    Objective-C

    - (OTVPersistenceAsset *_Nonnull)prepareDownloadWithUrl:(NSURL *_Nonnull)url
                                                      title:
                                                          (NSString *_Nonnull)title;
  • Start a media stream dowloading for a OTVPersistenceAsset note:

    • You MUST call prepareDownload and wait for state Prepared on the OTVPersistenceAsset before calling this function
      • If the stream is FPS encrypted, you MUST call setupFPS: on the prepared OTVPersistenceAsset before calling this function, and pass an OTVLicenseDelegate instance;
      • If the stream is PRM encrypted, you MUST call setupPRM: on the prepared OTVPersistenceAsset before call this function, and pass an OTVPRMAVURLAsset object;
      • If the stream is clear one, you SHOULD NOT call setupFPS: or setupPRM: on the prepared OTVPersistenceAsset.
      • You can set a number of values on the OTVPersistenceAsset to choose what resolution and bitrate you want to download
      • You can do this by setting OTVPersistenceAsset.mediaInfo.selectedStreamInfo from selection one of the OTVPersistenceAsset.mediaInfo.availableStreamInfo
      • If no value is set for OTVPersistenceAsset.mediaInfo.selectedStreamInfo we will check the options value passed into this function.
      • If neither of these values are set then we will use the highest possible value you are able to download.

    \param asset an object of OTVPersistenceAsset in prepared state

    \param artwork artwork Data

    \param options download options

    \param avMediaSelectionOptions the media selection to download, if it is not set, the default selection will be download

    returns: True if download start successful, False if there is some error, e.g. the asset is not in prepared state.

    Declaration

    Objective-C

    - (BOOL)startDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset
                           artwork:(NSData *_Nullable)artwork
                           options:(NSDictionary<NSString *, id> *_Nullable)options
           avMediaSelectionOptions:
               (NSArray<AVMediaSelection *> *_Nullable)avMediaSelectionOptions;
  • Start a media stream dowloading for a OTVPersistenceAsset note:

    • You MUST call prepareDownload and wait for state Prepared on the OTVPersistenceAsset before calling this function
      • If the stream is FPS encrypted, you MUST call setupFPS: on the prepared OTVPersistenceAsset before calling this function, and pass an OTVLicenseDelegate instance;
      • If the stream is PRM encrypted, you MUST call setupPRM: on the prepared OTVPersistenceAsset before call this function, and pass an OTVPRMAVURLAsset object;
      • If the stream is clear one, you SHOULD NOT call setupFPS: or setupPRM: on the prepared OTVPersistenceAsset.
      • You can set a number of values on the OTVPersistenceAsset to choose what resolution and bitrate you want to download
      • You can do this by setting OTVPersistenceAsset.mediaInfo.selectedStreamInfo from selection one of the OTVPersistenceAsset.mediaInfo.availableStreamInfo
      • If no value is set for OTVPersistenceAsset.mediaInfo.selectedStreamInfo we will check the options value passed into this function.
      • If neither of these values are set then we will use the highest possible value you are able to download.

    \param asset an object of OTVPersistenceAsset in prepared state

    \param artwork artwork Data

    \param options download options

    returns: True if download start successful, False if there is some error, e.g. the asset is not in prepared state.

    Declaration

    Objective-C

    - (BOOL)startDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset
                           artwork:(NSData *_Nullable)artwork
                           options:(NSDictionary<NSString *, id> *_Nullable)options;
  • Return downloading and downloaded assets.

    Declaration

    Objective-C

    - (NSArray<OTVPersistenceAsset *> *_Nullable)getDownloads;
  • Pause the downloading of assigned asset. \param asset the asset to be paused.

    Declaration

    Objective-C

    - (BOOL)pauseDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset;
  • Resume the paused downloading asset. \param asset the asset to be resumed.

    Declaration

    Objective-C

    - (BOOL)resumeDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset;
  • Cancel or remove the asset. \param asset the asset to be cancelled or removed.

    Declaration

    Objective-C

    - (BOOL)deleteDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset;