LiteAVSDK
Tencent Cloud TRTC SDK, is a high availability components serving tens of thousands of enterprise customers, which is committed to helping you to minimize your research and development costs.
TXVodDownloadManager

Data Structures

class  TXVodDownloadDataSource
 
class  TXVodDownloadMediaInfo
 
protocol  <TXVodDownloadDelegate>
 
class  TXVodDownloadManager
 

Enumerations

enum  TXVodQuality : NSInteger
 
enum  TXDownloadError : NSInteger
 
enum  TXVodDownloadMediaInfoState : NSInteger
 

Detailed Description


Data Structure Documentation

◆ TXVodDownloadDataSource

class TXVodDownloadDataSource

The download source through fileid

+ Inheritance diagram for TXVodDownloadDataSource:

Properties

TXPlayerAuthParamsauth
 
TXVodQuality quality
 
NSString * token
 
NSString * templateName
 
NSString * fileId
 
NSString * pSign
 
int appId
 
NSString * userName
 
NSString * overlayKey
 
NSString * overlayIv
 

Property Documentation

◆ appId

- (int) appId
readwritenonatomicassign

The application's appId, which is required.

◆ auth

- (TXPlayerAuthParams*) auth
readwritenonatomicassign

The fileid information.

◆ fileId

- (NSString*) fileId
readwritenonatomiccopy

The file ID.

◆ overlayIv

- (NSString*) overlayIv
readwritenonatomiccopy

◆ overlayKey

- (NSString*) overlayKey
readwritenonatomiccopy

The HLS EXT-X-KEY encryption and decryption parameters.

◆ pSign

- (NSString*) pSign
readwritenonatomiccopy

The signature information.

◆ quality

- (TXVodQuality) quality
readwritenonatomicassign

The download definition, which is the original resolution by default.

◆ templateName

- (NSString*) templateName
readwritenonatomiccopy

The definition template. If the backend performs transcoding with a custom template, enter the template name here. If both templateName and quality are set, templateName will prevail.

◆ token

- (NSString*) token
readwritenonatomiccopy

Enter the token if the address is encrypted.

◆ userName

- (NSString*) userName
readwritenonatomiccopy

The account name.

◆ TXVodDownloadMediaInfo

class TXVodDownloadMediaInfo

The file object to be downloaded.

+ Inheritance diagram for TXVodDownloadMediaInfo:

Instance Methods

(BOOL) - isDownloadFinished
 

Properties

TXVodDownloadDataSourcedataSource
 
NSString * url
 
NSString * userName
 
int duration
 
int playableDuration
 
int size
 
int downloadSize
 
int segments
 
int downloadSegments
 
float progress
 
NSString * playPath
 
int speed
 
TXVodDownloadMediaInfoState downloadState
 

Method Documentation

◆ isDownloadFinished()

- (BOOL) isDownloadFinished

Property Documentation

◆ dataSource

- (TXVodDownloadDataSource*) dataSource
readwriteatomic

The download object specified byfileid, which is optional.

◆ downloadSegments

- (int) downloadSegments
readwritenonatomicassign

The number of downloaded segments.

◆ downloadSize

- (int) downloadSize
readwritenonatomicassign

The size of the downloaded part in bytes.

◆ downloadState

- (TXVodDownloadMediaInfoState) downloadState
readwritenonatomicassign

◆ duration

- (int) duration
readwritenonatomicassign

The duration.

◆ playableDuration

- (int) playableDuration
readwritenonatomicassign

The playable duration.

◆ playPath

- (NSString*) playPath
readwritenonatomiccopy

The playback path, which can be passed in to TXVodPlayer for playback.

◆ progress

- (float) progress
readwritenonatomicassign

The progress.

◆ segments

- (int) segments
readwritenonatomicassign

The total number of segments.

◆ size

- (int) size
readwritenonatomicassign

The total file size in bytes.

◆ speed

- (int) speed
readwritenonatomicassign

The download speed in B/s.

◆ url

- (NSString*) url
readwritenonatomiccopy

The download URL.

◆ userName

- (NSString*) userName
readwritenonatomiccopy

The account name.

◆ TXVodDownloadDelegate-p

protocol TXVodDownloadDelegate-p

The download callback.

+ Inheritance diagram for <TXVodDownloadDelegate>:

Instance Methods

(void) - onDownloadStart:
 
(void) - onDownloadProgress:
 
(void) - onDownloadStop:
 
(void) - onDownloadFinish:
 
(void) - onDownloadError:errorCode:errorMsg:
 
(int) - hlsKeyVerify:url:data:
 

Method Documentation

◆ hlsKeyVerify:url:data:()

- (int) hlsKeyVerify: (TXVodDownloadMediaInfo *)  mediaInfo
url: (NSString *)  url
data: (NSData *)  data 

Send the decryption key to the player for verification if the HLS file to be downloaded is encrypted.

Parameters
mediaInfoThe download object
urlThe URL
dataThe server response
Returns
0:The decryption key is correct, and file download continues; otherwise, a download error (the SDK failed to get the decryption key) will be reported.

◆ onDownloadError:errorCode:errorMsg:()

- (void) onDownloadError: (TXVodDownloadMediaInfo *)  mediaInfo
errorCode: (TXDownloadError code
errorMsg: (NSString *)  msg 

Download error.

◆ onDownloadFinish:()

- (void) onDownloadFinish: (TXVodDownloadMediaInfo *)  mediaInfo

Download was completed.

◆ onDownloadProgress:()

- (void) onDownloadProgress: (TXVodDownloadMediaInfo *)  mediaInfo

The download progress.

◆ onDownloadStart:()

- (void) onDownloadStart: (TXVodDownloadMediaInfo *)  mediaInfo

Download started.

◆ onDownloadStop:()

- (void) onDownloadStop: (TXVodDownloadMediaInfo *)  mediaInfo

Download stopped.

◆ TXVodDownloadManager

class TXVodDownloadManager

The download manager.

+ Inheritance diagram for TXVodDownloadManager:

Instance Methods

(void) - setDownloadPath:
 
(TXVodDownloadMediaInfo *) - startDownload:
 
(TXVodDownloadMediaInfo *) - startDownload:url:
 
(void) - stopDownload:
 
(BOOL) - deleteDownloadFile:
 
(void) - deleteDownloadMediaInfo:
 
(NSArray< TXVodDownloadMediaInfo * > *) - getDownloadMediaInfoList
 
(TXVodDownloadMediaInfo *) - getDownloadMediaInfo:
 
(NSString *) - getOverlayKeyIv:userName:fileId:qualityId:
 

Class Methods

(TXVodDownloadManager *) + shareInstance
 
(NSString *) + genRandomHexStringForHls
 
(NSString *) + encryptHexStringHls:
 

Properties

id< TXVodDownloadDelegatedelegate
 
NSDictionary * headers
 

Method Documentation

◆ deleteDownloadFile:()

- (BOOL) deleteDownloadFile: (NSString *)  playPath

Delete the file generated by download.

Returns
NO will be returned if the file is being downloaded and cannot be deleted.

◆ deleteDownloadMediaInfo:()

- (void) deleteDownloadMediaInfo: (TXVodDownloadMediaInfo *)  downloadMediaInfo

Delete the download information.

Parameters
downloadMediaInfodownloadMediaInfo

◆ encryptHexStringHls:()

+ (NSString *) encryptHexStringHls: (NSString *)  originHexStr

Perform encryption

Parameters
originHexStroriginHexStr

◆ genRandomHexStringForHls()

+ (NSString *) genRandomHexStringForHls

The encryption configuration Get the random number for encryption.

◆ getDownloadMediaInfo:()

- (TXVodDownloadMediaInfo *) getDownloadMediaInfo: (TXVodDownloadMediaInfo *)  media

Get the download information.

Parameters
mediamedia

◆ getDownloadMediaInfoList()

- (NSArray<TXVodDownloadMediaInfo *> *) getDownloadMediaInfoList

Get the download list. You must set the download meta before calling this API. For more information, see the setDownloadMeta method.

◆ getOverlayKeyIv:userName:fileId:qualityId:()

- (NSString *) getOverlayKeyIv: (int)  appId
userName: (NSString *)  userName
fileId: (NSString *)  fileId
qualityId: (int)  qualityId 

Get the overlayKey and overlayIv for HLS EXT-X-KEY encryption and decryption.

Parameters
appIdappId
userNameuserName
fileIdfileId
qualityIdqualityId

◆ setDownloadPath:()

- (void) setDownloadPath: (NSString *)  path

Set the root directory for downloaded files

Parameters
pathThe directory path. If it doesn't exist, it will be created automatically.
Warning
This parameter must be configured before download starts; otherwise, download will fail.

◆ shareInstance()

+ (TXVodDownloadManager *) shareInstance

The global singleton API

◆ startDownload:()

- (TXVodDownloadMediaInfo *) startDownload: (TXVodDownloadDataSource *)  source

The downloaded file

Parameters
sourceThe download source
Returns
The download object will be returned if the request succeeds; otherwise, nil will be returned.
Warning
Currently, only HLS files can be downloaded.

◆ startDownload:url:()

- (TXVodDownloadMediaInfo *) startDownload: (NSString *)  username
url: (NSString *)  url 

Download a file

Parameters
usernameusername
urlurl

◆ stopDownload:()

- (void) stopDownload: (TXVodDownloadMediaInfo *)  media

Stop download

Parameters
mediaThe object for which download stopped

Property Documentation

◆ delegate

- (id<TXVodDownloadDelegate>) delegate
readwritenonatomicweak

The download task callback

◆ headers

- (NSDictionary*) headers
readwritenonatomicstrong

Set the httpHeader

Enumeration Type Documentation

◆ TXDownloadError

enum TXDownloadError : NSInteger

The download error code

Enumerator
TXDownloadSuccess 

Download succeeded.

TXDownloadAuthFaild 

Failed to authenticate the fileid.

TXDownloadNoFile 

The file with the specified resolution does not exist.

TXDownloadFormatError 

The format is not supported.

TXDownloadDisconnet 

The network was disconnected.

TXDownloadHlsKeyError 

Failed to get the HLS decryption key.

TXDownloadPathError 

Failed to access the download directory.

◆ TXVodDownloadMediaInfoState

enum TXVodDownloadMediaInfoState : NSInteger

The download status

Enumerator
TXVodDownloadMediaInfoStateInit 
TXVodDownloadMediaInfoStateStart 
TXVodDownloadMediaInfoStateStop 
TXVodDownloadMediaInfoStateError 
TXVodDownloadMediaInfoStateFinish 

◆ TXVodQuality

enum TXVodQuality : NSInteger

The definition of the downloaded video

Enumerator
TXVodQualityOD 

Original.

TXVodQualityFLU 

LD.

TXVodQualitySD 

SD.

TXVodQualityHD 

HD.

TXVodQualityFHD 

FHD.

TXVodQuality2K 

2K

TXVodQuality4K 

4K