Commit b4acb77c authored by Hanruisong's avatar Hanruisong
Browse files

feat: 更新到 4.14.2

1.新增真机架构SDK。
parent 5aafef39
//
// DWBatchDownloadUtility.h
// Demo
//
// Created by zwl on 2019/1/21.
// Copyright © 2019 com.bokecc.www. All rights reserved.
//
#import <Foundation/Foundation.h>
@class DWVodVideoModel;
NS_ASSUME_NONNULL_BEGIN
typedef void(^BatchDownloadUtilityFinishBlock)(NSArray <DWVodVideoModel *> *playInfosArray);
typedef void(^BatchDownloadUtilityErrorBlock)(NSError *error);
@interface DWBatchDownloadUtility : NSObject
/**
* @brief 媒体类型,1为视频 2为音频 0为视频+音频,若不传该参数默认为视频
*/
@property(nonatomic,copy)NSString *mediatype;
/**
* @brief 授权验证码,需要的话请设置,默认为空
*/
@property(nonatomic,copy)NSString *verificationCode;
//注意! 回调方法可能不在主线程中,如果在里面进行UI操作,请回到主线程中进行
/**
* @brief 全部视频数据获取出错
*/
@property(nonatomic,copy)BatchDownloadUtilityErrorBlock errorBlock;
/**
* @brief 视频数据获取完成
*/
@property(nonatomic,copy)BatchDownloadUtilityFinishBlock finishBlock;
/*!
* @method
* @abstract 初始化DWBatchDownloadUtility
* @discussion 会对视频数据进行去重操作,如果传入数组中有重复的视频id或获取某个视频失败,可能会导致最后输出的视频数据长度跟传入的视频id的数量不一致
* @param userId 用户ID,不能为nil
* @param key 用户秘钥,不能为nil
* @param videoIds 视频id数组,不能为nil。最多同时获取10个视频id的播放地址,超出10个按10个获取
* @result DWBatchDownloadUtility对象
*/
-(instancetype)initWithUserId:(NSString *)userId key:(NSString *)key AndVideoIds:(NSArray *)videoIds;
/*!
* @method
* @abstract 开始获取批量下载数据
* @discussion 开始获取批量下载数据
*/
-(void)start;
@end
NS_ASSUME_NONNULL_END
//
// DWDownloadModel.h
// Demo
//
// Created by luyang on 2017/4/18.
// Copyright © 2017年 com.bokecc.www. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
// 下载状态
typedef NS_ENUM(NSUInteger, DWDownloadState) {
DWDownloadStateNone, // 未下载 或 下载删除了
DWDownloadStateReadying, // 等待下载
DWDownloadStateRunning, // 正在下载
DWDownloadStateSuspended, // 下载暂停
DWDownloadStateCompleted, // 下载完成
DWDownloadStateFailed // 下载失败
};
@class DWDownloadProgress;
@class DWDownloadModel;
@class DWVideoSubtitleModel;
@class DWVideoLogoModel;
// 进度更新block
typedef void (^DWDownloadProgressBlock)(DWDownloadProgress *progress,DWDownloadModel *downloadModel);
// 状态更新block
typedef void (^DWDownloadStateBlock)(DWDownloadModel *downloadModel, NSError *error);
///下载模型
@interface DWDownloadModel : NSObject
/**
* @brief 下载地址
*/
@property(nonatomic, strong, readonly)NSString * downloadURL;
/**
* @brief 文件名
*/
@property(nonatomic, strong, readonly)NSString * fileName;
/**
* @brief 存储路径
*/
@property(nonatomic, strong, readonly)NSString * filePath;
/**
* @brief 下载状态
*/
@property(nonatomic, assign, readonly)DWDownloadState state;
/**
* @brief 文件类型,1 视频 2 音频
*/
@property(nonatomic, strong, readonly)NSString * mediaType;
/**
* @brief 文件后缀名
*/
@property(nonatomic ,strong, readonly)NSString * mimeType;
/**
* @brief 清晰度
*/
@property(nonatomic, strong, readonly)NSString * quality;
/**
* @brief 清晰度描述
*/
@property(nonatomic, strong, readonly)NSString * desp;
/**
* @brief VR视频
*/
@property(nonatomic, assign, readonly)BOOL vrMode;
/**
* @brief resumeData
*/
@property(nonatomic, strong, readonly)NSData * resumeData;
/**
* @brief userId
*/
@property(nonatomic, strong, readonly)NSString * userId;
/**
* @brief 视频id
*/
@property(nonatomic, strong, readonly)NSString * videoId;
/**
* @brief 跑马灯数据
*/
@property(nonatomic, strong, readonly)NSString * marqueeStr;
/**
* @brief 字幕类型,-1 无字幕 ,0 subtitle, 1 subtitle2, 2 双语
*/
@property(nonatomic, assign, readonly)NSInteger defaultSubtitle;
/**
* @brief 字幕模式,-1 无字幕 ,0 固定字号, 1 自适应模式
*/
@property(nonatomic, assign, readonly)NSInteger subtitlemodel;
/**
* @brief 字幕1
*/
@property(nonatomic, strong, readonly)DWVideoSubtitleModel * subtitle;
/**
* @brief 字幕2
*/
@property(nonatomic, strong, readonly)DWVideoSubtitleModel * subtitle2;
/**
* @brief 自定义LOGO
*/
@property(nonatomic, strong, readonly)DWVideoLogoModel * videoLogo;
/**
* @brief 自定义字段,根据自己需求适当添加,比如添加媒体图片,标题等
*/
@property(nonatomic, strong)NSDictionary * othersInfo;
/**
* @brief 解压状态,非点播业务不需要关注此值。0 未解压,1 解压中,2 解压完成,3 解压失败
*/
@property(nonatomic, assign)NSInteger decompressionState;
/**
* @brief 下载进度
*/
@property(nonatomic, strong ,readonly)DWDownloadProgress *progress;
/**
* @brief 下载进度更新block
*/
@property(nonatomic, copy)DWDownloadProgressBlock progressBlock;
/**
* @brief 下载状态更新block
*/
@property(nonatomic, copy)DWDownloadStateBlock stateBlock;
@end
///下载进度
@interface DWDownloadProgress : NSObject
/**
* @brief 续传大小
*/
@property(nonatomic, assign, readonly)int64_t resumeBytesWritten;
/**
* @brief 每次写入的数量
*/
@property(nonatomic, assign, readonly)int64_t bytesWritten;
/**
* @brief 已下载的数量
*/
@property(nonatomic, assign, readonly)int64_t totalBytesWritten;
/**
* @brief 文件的总大小
*/
@property(nonatomic, assign, readonly)int64_t totalBytesExpectedToWrite;
/**
* @brief 下载进度
*/
@property(nonatomic, assign, readonly)float progress;
/**
* @brief 下载速度
*/
@property(nonatomic, assign, readonly)float speed;
/**
* @brief 下载剩余时间
*/
@property(nonatomic, assign, readonly)int remainingTime;
@end
NS_ASSUME_NONNULL_END
//
// DWDownloadSessionManager+File.h
// Demo
//
// Created by zwl on 2019/5/5.
// Copyright © 2019 com.bokecc.www. All rights reserved.
//
#import "DWDownloadSessionManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface DWDownloadSessionManager (File)
+(DWDownloadModel *)createDownloadModelWithUrl:(NSString *)downloadURL FileName:(NSString *)fileName MimeType:(NSString *)mimeType AndOthersInfo:(NSDictionary *)othersInfo;
-(void)decompressionFinish:(DWDownloadModel *)downloadModel;
-(BOOL)checkLocalResourceWithUrl:(NSString *)downloadURL;
@end
NS_ASSUME_NONNULL_END
//
// DWDownloadSessionManager.h
// Demo
//
// Created by zwl on 2019/2/25.
// Copyright © 2019 com.bokecc.www. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "DWDownloadModel.h"
#import <HDBaseUtils/HDURLSessionManager.h>
NS_ASSUME_NONNULL_BEGIN
@class DWVodVideoModel;
// 下载代理
@protocol DWDownloadSessionDelegate <NSObject>
@optional
/** 更新下载进度回调
@param downloadModel 自身对象
@param progress 下载进度
*/
-(void)downloadModel:(DWDownloadModel *)downloadModel didUpdateProgress:(DWDownloadProgress *)progress;
/** 更新下载状态/出现error时回调
@param downloadModel 自身对象
@param error 错误信息
*/
-(void)downloadModel:(DWDownloadModel *)downloadModel error:(NSError *)error;
/** 后台下载完成时回调
*/
-(void)downloadBackgroundSessionCompletion;
@end
@interface DWDownloadSessionManager : NSObject
/**
* @brief 下载任务队列
*/
@property(nonatomic,strong,readonly)NSArray <DWDownloadModel *> * downloadModelList;
/**
* @brief 代理
*/
@property(nonatomic,weak)id<DWDownloadSessionDelegate> delegate;
/**
注意:修改下载设置后,对已经存在的下载任务可能无效,请清空下载任务之后修改设置
*/
/**
* @brief 是否允许使用移动流量 YES支持 NO不支持 默认支持
*/
@property(nonatomic,assign)BOOL allowsCellular;
/**
* @brief 全部并发,默认YES, 当YES时,忽略maxDownloadCount
*/
@property(nonatomic,assign)BOOL isBatchDownload;
/**
* @brief 允许同时下载的最大并发数,默认为1,最大为4
*/
@property(nonatomic,assign)NSInteger maxDownloadCount;
/**
* @brief 等待下载队列 先进先出 默认YES,当NO时,先进后出
*/
@property(nonatomic,assign)BOOL resumeDownloadFIFO;
/*!
* @method
* @abstract 初始化DWDownloadSessionManager
* @discussion 初始化DWDownloadSessionManager
* @result DWDownloadSessionManager对象
*/
+(DWDownloadSessionManager *)manager;
/*!
* @method
* @abstract 初始化DWDownloadModel
* @discussion 初始化DWDownloadModel
* @param videoMdoel 点播视频model,非空
* @param quality 媒体品质,非空
* @param othersInfo 自定义字段,可为空
* @result 创建成功返回DWDownloadModel对象,如果失败,返回nil
*/
+(DWDownloadModel *)createDownloadModel:(DWVodVideoModel *)videoMdoel Quality:(NSString *)quality AndOthersInfo:(nullable NSDictionary *)othersInfo;
/*!
* @method
* @abstract 插入自定义LOGO
* @discussion 在startWithDownloadModel:方法前调用,否则会导致自定义水印无法正常下载
* @param downloadModel DWDownloadModel对象
* @param videoLogo 自定义水印对象
* @result 插入成功返回YES,失败返回NO
*/
-(BOOL)insertVideoLogoWithDownloadModel:(DWDownloadModel *)downloadModel VideoLogo:(DWVideoLogoModel *)videoLogo;
/*!
* @method
* @abstract 开始下载任务
* @discussion 开始下载任务
* @param downloadModel DWDownloadModel对象
*/
-(void)startWithDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 开始下载任务
* @discussion 所有回调均已回到主线程中
* @param downloadModel DWDownloadModel对象
* @param progress 下载进度回调
* @param state 下载状态变动回调
*/
-(void)startWithDownloadModel:(DWDownloadModel *)downloadModel progress:(DWDownloadProgressBlock)progress state:(DWDownloadStateBlock)state;
/*!
* @method
* @abstract 暂停下载任务
* @discussion 暂停下载任务
* @param downloadModel DWDownloadModel对象
*/
-(void)suspendWithDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 恢复下载任务
* @discussion 恢复下载任务
* @param downloadModel DWDownloadModel对象
*/
-(void)resumeWithDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 删除下载任务以及本地缓存
* @discussion 删除下载任务以及本地缓存
* @param downloadModel DWDownloadModel对象
*/
-(void)deleteWithDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 暂停全部任务
* @discussion 暂停全部任务
*/
-(void)suspendAllDownloadModel;
/*!
* @method
* @abstract 删除全部任务
* @discussion 删除全部任务
*/
-(void)deleteAllDownloadModel;
/*!
* @method
* @abstract 获取下载模型
* @discussion 获取下载模型
* @param URLString 下载地址
* @result DWDownloadModel对象
*/
-(DWDownloadModel *)downLoadingModelForURLString:(NSString *)URLString;
/*!
* @method
* @abstract 判断当前资源是已在下载队列中
* @discussion 判断当前资源是已在下载队列中
* @param videoId 视频id,非空
* @param quality 媒体品质,非空
* @result 查询结果
*/
-(BOOL)checkLocalResourceWithVideoId:(NSString *)videoId WithQuality:(NSString *)quality;
/*!
* @method
* @abstract 判断downloadModel下载链接是否有效
* @discussion 下载链接具有时效性,若超时,请调用reStartDownloadUrlWithNewUrlString:AndDownloadModel:方法
* @param downloadModel DWDownloadModel对象
* @result 查询结果
*/
-(BOOL)isValidateURLWithDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 根据新的下载地址,继续下载此任务
* @discussion 下载链接超时时,调用此方法继续下载当前任务
* @param newUrlString 新的下载地址
* @param downloadModel DWDownloadModel对象
*/
-(void)reStartDownloadUrlWithNewUrlString:(NSString *)newUrlString AndDownloadModel:(DWDownloadModel *)downloadModel;
/*!
* @method
* @abstract 事件透传
* @discussion 获取appdelegate,handleEventsForBackgroundURLSession事件回调
* @param identifier identifier
* @param completionHandler completionHandler
*/
-(void)setBackgroundSession:(NSString *)identifier CompletionHandler:(void (^)())completionHandler;
/*!
* @method
* @abstract 3.x.x升级4.x.x以上版本所使用的过渡方法
* @discussion 若从3.x.x版本升级到4.x.x,会出现旧版本下载的音视频文件找不到的情况。
可以通过执行此方法,生成新版SDk的下载任务
* @param loaclPath 对于已完成的任务,必填。对于未完成的任务,请务必传nil
* @param downloadUrl 网络下载地址。对于未完成的任务,必填
* @param mediaType 文件类型,1 视频 2 音频。若不填写,默认视频
* @param quality 清晰度,若不填写,默认 10
* @param desp 清晰度描述,若不填写,默认 标清
* @param vrMode 是否是VR视频。默认 NO
* @param othersInfo 自定义字段,根据自己需求适当添加,比如添加媒体图片,标题等
* @param userId 用户ID,选填
* @param videoId 视频ID,选填
* @param totalBytesWritten 已下载的数量。对于未完成的任务,必填
* @param totalBytesExpectedToWrite 文件的总大小。对于未完成的任务,必填
* @result 若过渡成功,返回DWDownloadModel对象,否则返回nil
*/
-(DWDownloadModel *)migrateDownloadTask:(nullable NSString *)loaclPath
DownloadUrl:(nullable NSString *)downloadUrl
MediaType:(nullable NSString *)mediaType
Quality:(nullable NSString *)quality
Desp:(nullable NSString *)desp
VRMode:(BOOL)vrMode
OthersInfo:(nullable NSDictionary *)othersInfo
UserId:(nullable NSString *)userId
VideoId:(nullable NSString *)videoId
TotalBytesWritten:(int64_t)totalBytesWritten
TotalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;
@end
NS_ASSUME_NONNULL_END
//
// DWDownloadUtility.h
// DWDownloadManagerDemo
//
// Created by luyang on 17/4/18.
//
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
///下载工具类
@interface DWDownloadUtility : NSObject
/*!
* @method
* @abstract 返回文件大小
* @discussion 返回文件大小
* @param contentLength 文件大小
* @result 文件大小
*/
+(float)calculateFileSizeInUnit:(unsigned long long)contentLength;
/*!
* @method
* @abstract 返回文件大小的单位
* @discussion 返回文件大小的单位
* @param contentLength 文件大小
* @result 文件大小单位
*/
+(NSString *)calculateUnit:(unsigned long long)contentLength;
@end
NS_ASSUME_NONNULL_END
//
// DWErrorCode.h
// Demo
//
// Created by zwl on 2018/10/18.
// Copyright © 2018 com.bokecc.www. All rights reserved.
//
#ifndef DWErrorCode_h
#define DWErrorCode_h
typedef NS_ENUM(NSUInteger, DWSDK_SERVICE_ERROR) {
ERROR_INFO_NOTMATCH = 1000 , //视频参数错误
ERROR_VIDEO_UNAVAILABLE = 1001 , //视频不可用
ERROR_VIDEO_PROCESSING = 1002 , //视频处理中
ERROR_VIDEO_DELETE = 1003 , //视频已删除
ERROR_VIDEO_TRANFAILURE = 1004 , //视频转码失败
ERROR_REQUEST_FAILURE = 1005 , //网络请求失败
ERROR_VIDEO_ANALYSIS = 1006 , //PlayInfo数据解析失败
ERROR_VIDEO_UNKNOW = 1007 , //未知错误
ERROR_PLAYERSKIN_VIDEOUNAVAILABLE = 1201 , //视频资源不存在
ERROR_PLAYERSKIN_LOCALUNAVAILABLE = 1202 , //离线资源不存在
ERROR_PLAYERSKIN_DISABLEAUTOROTATE = 1203 , //禁止手动旋转
ERROR_PLAYERSKIN_BUFFEREMPTY = 1204 , //暂无缓冲数据
ERROR_PLAYERSKIN_BUFFERTIMEOUT = 1205 , //缓冲超时
ERROR_PLAYERSKIN_LOADTIMEOUT = 1206 , //加载超时
ERROR_AFINFO_NOTMATCH = 1301 , //广告参数错误