OpenTV Player SDK For iOS  version 2.30.0
NMPDownloadManager Class Reference

This class offers the downloading and the storage management of adaptive streaming assets. More...

#import <DownloadManager.h>

Inheritance diagram for NMPDownloadManager:

Instance Methods

(instancetype) - initWithRefreshMetadata:
 Returns an instance of NMPDownloadManager which manage for downloading feature of HLS streams. More...
 
(BOOL) - registerDownloadListener:
 Registers an INMPDownloadListener object to the DownloadManager. More...
 
(BOOL) - unregisterDownloadListener:
 Unregisters an INMPDownloadListener interface from the DownloadManager. More...
 
(NSString *) - registerDownload:
 Registers an asset download to the NMPDownloadManager via its URL. More...
 
(NSArray *) - getDownloads
 Returns all downloads currently registered in the download manager. More...
 
(NMPDownload *) - getDownloadByUUID:
 Get the download registered to the download manager matching the UUID specified in parameter. More...
 
(NSArray *) - getDownloadByContentId:
 Returns all downloads matching the Content ID specified in parameter. More...
 
(BOOL) - removeDownload:
 Removes the download specified in parameter. More...
 
(BOOL) - startDownload:bitrate:
 Starts the download specified in parameter. More...
 
(BOOL) - resumeDownload:
 Resumes the paused or failed download specified in parameter. More...
 
(BOOL) - pauseDownload:
 Pauses the running download specified in parameter. More...
 
(NSString *) - getPrivateMetadata:
 Returns the private string previously associated to the download. More...
 
(void) - setPrivateMetadata:withUUID:
 Associate a private string to the download. More...
 
(BOOL) - refreshDownload:
 Refreshes the running download specified in parameter. More...
 

Detailed Description

This class offers the downloading and the storage management of adaptive streaming assets.

The client application can register, start, pause or remove the download of assets. Information pertaining to the downloads can be queried. The queries extract snapshots of the downloads in the form of one or more NMPDownload objects.

Before usage, the DownloadManager must be provided with a storage path and an IDownloadListener interfacing object. Once the path has been set and one IDownloadListener has been registered, the client application can start registering downloads. Downloads registered to the DownloadManager will immediately attempt to access the network and retrieve metadata pertaining to the asset requested, but the raw media data will not be downloaded before the download is explicitly started by the client application.

The preparing and downloading are driven by the callbacks of IDownloadListener.

Objects of this class can be instantiated multiple times, but all instances will point to a single underlying database maintaining all ongoing or finished downloads. The lifecycle of downloads are directly linked to the DownloadManager.

The DownloadManager currently supports the following adaptive streaming protocols and protocol versions :

  • HTTP Live Streaming, up to protocol version 5
See also
NMPDownload
INMPDownloadListener

Definition at line 59 of file DownloadManager.h.

Method Documentation

◆ getDownloadByContentId:()

- (NSArray*) getDownloadByContentId: (NSString *)  xContentId

Returns all downloads matching the Content ID specified in parameter.

Parameters
[in]xContentIdContent ID of the download.
Returns
A collection of Download objects. The collection will be empty if not found.

◆ getDownloadByUUID:()

- (NMPDownload*) getDownloadByUUID: (NSString *)  xUUID

Get the download registered to the download manager matching the UUID specified in parameter.

Parameters
[in]xUUIDUniversal Unique ID of the download.
Returns
A Download object or null if not found.

◆ getDownloads()

- (NSArray*) getDownloads

Returns all downloads currently registered in the download manager.

Returns
A collection of Download objects.

◆ getPrivateMetadata:()

- (NSString *) getPrivateMetadata: (NSString *)  xUUID

Returns the private string previously associated to the download.

Parameters
[in]xUUIDUniversal Unique ID of the download.
Returns
The private string previously associated, null if no string has ever been set.

◆ initWithRefreshMetadata:()

- (instancetype) initWithRefreshMetadata: (BOOL)  xEnabled

Returns an instance of NMPDownloadManager which manage for downloading feature of HLS streams.

Parameters
[in]xEnabledPass YES to allow paused or failed download to refresh the playlist on resume. NO to resume without refreshing.
Returns
An instance of NMPDownloadManager

◆ pauseDownload:()

- (BOOL) pauseDownload: (NSString *)  xUUID

Pauses the running download specified in parameter.

The download will change to the STATE_PAUSED state.

Parameters
[in]xUUIDUniversal Unique ID of the download.
Returns
true if the action succeeded; false if the UUID does not exist.

◆ refreshDownload:()

- (BOOL) refreshDownload: (NSString *)  xUUID

Refreshes the running download specified in parameter.

The download will change to the STATE_REFRESHING state. Refresh the original playlist to get again with fresh URLs then carry on with the download maintaining the segments that have already succeeded. Query the DB to get the original playlist

Parameters
[in]xUUIDUniversal Unique ID of the download.
Returns
true if the action succeeded; false otherwise.

◆ registerDownload:()

- (NSString *) registerDownload: (NSString *)  xUrl

Registers an asset download to the NMPDownloadManager via its URL.

Parameters
[in]xUrlThe URL to the master manifest of an adaptive streaming asset.
Returns
The Universal Unique ID attributed to the download, or null if the download could not be registered.

◆ registerDownloadListener:()

- (BOOL) registerDownloadListener: (id< INMPDownloadListener >)  xListener

Registers an INMPDownloadListener object to the DownloadManager.

All callbacks coming from the NMPDownloadManager will be fired on this interface.

Currently only support one listener.

Parameters
[in]xListenerAn INMPDownloadListener interface object to register
Returns
true if the action succeeded; false if the UUID does not exist.

◆ removeDownload:()

- (BOOL) removeDownload: (NSString *)  xUUID

Removes the download specified in parameter.

The download will disappear from the list of downloads and be unregistered from the download manager. onDownloadRemoved() will be fired when effective.

Parameters
[in]xUUIDUniversal Unique ID of the download
Returns
true if the action succeeded; false if the UUID does not exist.

◆ resumeDownload:()

- (BOOL) resumeDownload: (NSString *)  xUUID

Resumes the paused or failed download specified in parameter.

The download will change to the STATE_RUNNING state.

Parameters
[in]xUUIDUniversal Unique ID of the download.
Returns
true if the action succeeded; false if the UUID does not exist.

◆ setPrivateMetadata:withUUID:()

- (void) setPrivateMetadata: (NSString *)  xMetadata
withUUID: (NSString *)  xUUID 

Associate a private string to the download.

This allows the client application to associate applicative data with the download. The format is at the developper's convenience. (JSON, XML, ...)

Parameters
[in]xUUIDUniversal Unique ID of the download.
[in]xMetadataString to associate to the download.

◆ startDownload:bitrate:()

- (BOOL) startDownload: (NSString *)  xUUID
bitrate: (unsigned int)  xBitrate 

Starts the download specified in parameter.

The download will change to the STATE_RUNNING state.

Parameters
[in]xUUIDUniversal Unique ID of the download.
[in]xBitrateThe consumption bitrate to use with the download. Only bitrates found in MediaInfo objects are eligible.
Returns
true if the action succeeded; false if the UUID does not exist.

◆ unregisterDownloadListener:()

- (BOOL) unregisterDownloadListener: (id< INMPDownloadListener >)  xListener

Unregisters an INMPDownloadListener interface from the DownloadManager.

Parameters
[in]xListenerAn INMPDownloadListener interface object to unregister
Returns
true if the action succeeded; false if the UUID does not exist.