LiteAVSDK
腾讯云音视频 SDK ,服务于数万家企业客户的高可用组件,致力于最大限度地节省您的研发成本。
TXVodDownloadManager

详细描述


结构体说明

◆ TXVodDownloadDataSource

class TXVodDownloadDataSource

属性

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

属性说明

◆ appId

- (int) appId
readwritenonatomicassign

应用appId。必填

◆ auth

- (TXPlayerAuthParams*) auth
readwritenonatomicassign

fileid信息

◆ fileId

- (NSString*) fileId
readwritenonatomiccopy

文件Id

◆ overlayIv

- (NSString*) overlayIv
readwritenonatomiccopy

加解密参数 overlayIv

◆ overlayKey

- (NSString*) overlayKey
readwritenonatomiccopy

HLS EXT-X-KEY 加解密参数

◆ pSign

- (NSString*) pSign
readwritenonatomiccopy

签名信息

◆ quality

- (TXVodQuality) quality
readwritenonatomicassign

下载清晰度,默认原画

◆ templateName

- (NSString*) templateName
readwritenonatomiccopy

清晰度模板。如果后台转码是自定义模板,请在这里填写模板名。templateName和quality同时设置时,以templateName为v准

◆ token

- (NSString*) token
readwritenonatomiccopy

如地址有加密,请填写token

◆ userName

- (NSString*) userName
readwritenonatomiccopy

账户名称

◆ TXVodDownloadMediaInfo

class TXVodDownloadMediaInfo

构造函数

(BOOL) - isDownloadFinished
 

属性

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
 

函数文档

◆ isDownloadFinished()

- (BOOL) isDownloadFinished

是否下载完成

属性说明

◆ dataSource

- (TXVodDownloadDataSource*) dataSource
readwriteatomic

fileid下载对象(可选)

◆ downloadSegments

- (int) downloadSegments
readwritenonatomicassign

已下载的分段数

◆ downloadSize

- (int) downloadSize
readwritenonatomicassign

已下载大小,单位:byte

◆ downloadState

- (TXVodDownloadMediaInfoState) downloadState
readwritenonatomicassign

下载状态

◆ duration

- (int) duration
readwritenonatomicassign

时长

◆ playableDuration

- (int) playableDuration
readwritenonatomicassign

可播放时长

◆ playPath

- (NSString*) playPath
readwritenonatomiccopy

播放路径,可传给TXVodPlayer播放

◆ progress

- (float) progress
readwritenonatomicassign

进度

◆ segments

- (int) segments
readwritenonatomicassign

分段总数

◆ size

- (int) size
readwritenonatomicassign

文件总大小,单位:byte

◆ speed

- (int) speed
readwritenonatomicassign

下载速度,byte每秒

◆ url

- (NSString*) url
readwritenonatomiccopy

下载地址

◆ userName

- (NSString*) userName
readwritenonatomiccopy

账户名称

◆ TXVodDownloadDelegate-p

protocol TXVodDownloadDelegate-p

构造函数

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

函数文档

◆ hlsKeyVerify:url:data:()

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

下载HLS,遇到加密的文件,将解密key给外部校验

参数
mediaInfo下载对象
urlUrl地址
data服务器返回
返回
0:校验正确,继续下载;否则校验失败,抛出下载错误(SDK 获取失败)

◆ onDownloadError:errorCode:errorMsg:()

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

下载错误

◆ onDownloadFinish:()

- (void) onDownloadFinish: (TXVodDownloadMediaInfo *)  mediaInfo

下载完成

◆ onDownloadProgress:()

- (void) onDownloadProgress: (TXVodDownloadMediaInfo *)  mediaInfo

下载进度

◆ onDownloadStart:()

- (void) onDownloadStart: (TXVodDownloadMediaInfo *)  mediaInfo

下载开始

◆ onDownloadStop:()

- (void) onDownloadStop: (TXVodDownloadMediaInfo *)  mediaInfo

下载停止

◆ TXVodDownloadManager

class TXVodDownloadManager

构造函数

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

类方法

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

属性

id< TXVodDownloadDelegatedelegate
 
NSDictionary * headers
 

函数文档

◆ deleteDownloadFile:()

- (BOOL) deleteDownloadFile: (NSString *)  playPath

删除下载产生的文件

返回
文件正在下载将无法删除,返回NO

◆ deleteDownloadMediaInfo:()

- (void) deleteDownloadMediaInfo: (TXVodDownloadMediaInfo *)  downloadMediaInfo

删除下载信息

参数
downloadMediaInfodownloadMediaInfo

◆ encryptHexStringHls:()

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

加密

参数
originHexStroriginHexStr

◆ genRandomHexStringForHls()

+ (NSString *) genRandomHexStringForHls

加密相关 获取加密随机数

◆ getDownloadMediaInfo:()

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

获取下载信息

参数
mediamedia

◆ getDownloadMediaInfoList()

- (NSArray<TXVodDownloadMediaInfo *> *) getDownloadMediaInfoList

获取下载列表,调用前必须设置download meta,具体见setDownloadMeta方法

◆ getOverlayKeyIv:userName:fileId:qualityId:()

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

获取HLS EXT-X-KEY 加解密的overlayKey和overlayIv

参数
appIdappId
userNameuserName
fileIdfileId
qualityIdqualityId

◆ setDownloadPath:()

- (void) setDownloadPath: (NSString *)  path

设置下载文件的根目录。

参数
path目录地址,如不存在,将自动创建
警告
开始下载前必须设置,否则不能下载

◆ shareInstance()

+ (TXVodDownloadManager *) shareInstance

全局单例接口

◆ startDownload:()

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

下载文件

参数
source下载源。
返回
成功返回下载对象,否则nil
警告
目前只支持hls下载

◆ startDownload:url:()

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

下载文件

参数
usernameusername
urlurl

◆ stopDownload:()

- (void) stopDownload: (TXVodDownloadMediaInfo *)  media

停止下载

参数
media停止下载对象

属性说明

◆ delegate

- (id<TXVodDownloadDelegate>) delegate
readwritenonatomicweak

下载任务回调

◆ headers

- (NSDictionary*) headers
readwritenonatomicstrong

设置 HTTP 头

枚举类型说明

◆ TXDownloadError

enum TXDownloadError : NSInteger

下载错误码

枚举值
TXDownloadSuccess 

下载成功

TXDownloadAuthFaild 

fileid鉴权失败

TXDownloadNoFile 

无此清晰度文件

TXDownloadFormatError 

格式不支持

TXDownloadDisconnet 

网络断开

TXDownloadHlsKeyError 

获取HLS解密key失败

TXDownloadPathError 

下载目录访问失败

◆ TXVodDownloadMediaInfoState

enum TXVodDownloadMediaInfoState : NSInteger

下载状态

枚举值
TXVodDownloadMediaInfoStateInit 
TXVodDownloadMediaInfoStateStart 
TXVodDownloadMediaInfoStateStop 
TXVodDownloadMediaInfoStateError 
TXVodDownloadMediaInfoStateFinish 

◆ TXVodQuality

enum TXVodQuality : NSInteger

下载视频的清晰度

枚举值
TXVodQualityOD 

原画

TXVodQualityFLU 

流畅

TXVodQualitySD 

标清

TXVodQualityHD 

高清

TXVodQualityFHD 

全高清

TXVodQuality2K 

2K

TXVodQuality4K 

4K