typedef NS_ENUM( NSInteger, VeLivePlayerResolutionSwitchReason )
直播播放器清晰度档位变化原因。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerResolutionSwitchByAuto | 0 | ABR 自动切档。 |
| VeLivePlayerResolutionSwitchByManual | 1 | 调用 switchResolution:手动切换档位。 |
@interface VeLivePlayerConfiguration : NSObject
播放器初始化相关配置。
| 类型 | 名称 |
|---|---|
| BOOL | enableSei |
| BOOL | enableBinarySei |
| BOOL | enableHardwareDecode |
| BOOL | enableLiveDNS |
| BOOL | enableStatisticsCallback |
| NSInteger | statisticsCallbackInterval |
| NSInteger | networkTimeoutMs |
| NSInteger | retryIntervalTimeMs |
| NSInteger | retryMaxCount |
| NSInteger | stallRetryTimeout |
| 返回 | 名称 |
|---|---|
| instancetype | init |
@property (nonatomic, assign) BOOL enableSei;
是否开启字符串 SEI 消息的解析,默认值为 NO。
YES:开启;NO:关闭。@property (nonatomic, assign) BOOL enableBinarySei;
是否开启二进制 SEI 消息的解析,默认值为 NO。
YES:开启;NO:关闭。注意
二进制 SEI 开启后,字符串 SEI 的回调将不再发送。
@property (nonatomic, assign) BOOL enableHardwareDecode;
是否开启硬件解码功能,默认值为 YES。开启硬件解码后,如果出现硬件解码启动失败或硬件解码失败的情况,播放器内部会自动切换为软解。
YES:开启;NO:关闭。@property (nonatomic, assign) BOOL enableLiveDNS;
是否开启本地 DNS 预解析,默认值为 YES。开启本地 DNS 预解析可以缩短启播时间。如果本地 DNS 预解析出现异常,可能会影响播放器的正常使用。
YES:开启;NO:关闭。@property (nonatomic, assign) BOOL enableStatisticsCallback;
是否开启播放信息周期性回调。默认值为 NO。周期性回调参数详细说明请参见 VeLivePlayerStatistics 。当 enableStatisticsCallback 为 YES,且 statisticsCallbackInterval 大于 0 时,播放器会在指定的时间间隔内,周期性地回调播放器状态信息。
YES:开启;NO:关闭。@property (nonatomic, assign) NSInteger statisticsCallbackInterval;
播放信息周期性回调的时间间隔,单位为 s,默认值为 5。当 enableStatisticsCallback 为 YES,且 statisticsCallbackInterval 大于 0 时,播放器会在指定的时间间隔内,周期性地回调播放器状态信息。
@property (nonatomic, assign) NSInteger networkTimeoutMs;
网络超时时间,单位为 ms,默认值为 5000。播放器发起网络请求,如果超过了该时间仍未收到服务器响应,则认为网络请求失败。
@property (nonatomic, assign) NSInteger retryIntervalTimeMs;
重试时间间隔。单位为 ms,默认值为 5000。如果需要为每个流单独设置重试间隔,可以设置 retryIntervalTimeMs。
@property (nonatomic, assign) NSInteger retryMaxCount;
在网络连接错误的情况下,播放器的最大重试次数。默认值为 5。如果取值为 0,表示关闭播放器内部重试。如果需要为每个流单独设置最大重试次数,可以设置 retryMaxCount。
@property (nonatomic, assign) NSInteger stallRetryTimeout;
卡顿超时停止重试阈值。当卡顿时长超过该阈值时,播放器将不再进行重试。单位为 ms。默认值为 10000,即 10 秒。
- (instancetype _Nonnull)init;
默认初始化方法。
@interface VeLivePlayerStream : NSObject
流地址信息。
| 类型 | 名称 |
|---|---|
| NSString* | url |
| VeLivePlayerResolution | resolution |
| int | bitrate |
| VeLivePlayerProtocol | protocol |
| VeLivePlayerFormat | format |
| VeLivePlayerStreamType | type |
| NSUInteger | priority |
| NSInteger | retryMaxCount |
| NSInteger | retryIntervalTimeMs |
| 返回 | 名称 |
|---|---|
| instancetype | init |
@property (nonatomic, copy, nonnull) NSString *url;
播放地址。
@property (nonatomic, assign) VeLivePlayerResolution resolution;
清晰度档位,详情请参见 VeLivePlayerResolution。
@property (nonatomic, assign) int bitrate;
播放码率,单位为 bps。
@property (nonatomic, assign) VeLivePlayerProtocol protocol;
传输协议,详情请参见 VeLivePlayerProtocol。
@property (nonatomic, assign) VeLivePlayerFormat format;
播放格式,详情请参见 VeLivePlayerFormat。
@property (nonatomic, assign) VeLivePlayerStreamType type;
播放流类型为主路或备路,详情请参见 VeLivePlayerStreamType。
@property (nonatomic, assign) NSUInteger priority;
流的优先级。取值必须为 0(默认值)或正整数。取值越大,优先级越高。
@property (nonatomic, assign) NSInteger retryMaxCount;
流的最大重试次数,即总播放尝试次数(包含首次尝试)。例如,若取值为 3,则在首次播放失败后,播放器最多会再重试 2 次。取值如下:
-1(默认值):使用 VeLivePlayerConfiguration 中 retryMaxCount 的取值。0:不会尝试播放当前流。> 0:具体次数。@property (nonatomic, assign) NSInteger retryIntervalTimeMs;
重试时间间隔。单位为 ms,默认值为 -1。若取值为 -1,则使用 VeLivePlayerConfiguration 中 retryIntervalTimeMs 的取值。
- (instancetype)init;
单路直播流配置初始化方法。
typedef NS_ENUM( NSUInteger, VeLivePlayerLogLevel )
直播播放器日志打印级别。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerLogLevelVerbose | 0 | 输出 VERBOSE、DEBUG、INFO、WARNING 和 ERROR 级别的日志。 |
| VeLivePlayerLogLevelDebug | 1 | 输出 DEBUG、INFO、WARNING 和 ERROR 级别的日志。 |
| VeLivePlayerLogLevelInfo | 2 | 输出 INFO、WARNING 和 ERROR 级别的日志。 |
| VeLivePlayerLogLevelWarn | 3 | 输出 WARNING 和 ERROR 级别的日志。 |
| VeLivePlayerLogLevelError | 4 | 输出 ERROR 级别的日志。 |
| VeLivePlayerLogLevelNone | 5 | 关闭日志打印。 |
@interface VeLivePlayerAudioFrame : NSObject
音频帧数据。
| 类型 | 名称 |
|---|---|
| VeLivePlayerAudioBufferType | bufferType |
| int | sampleRate |
| int | channels |
| int | bitDepth |
| CMTime | pts |
| NSData* | data |
| int | samples |
@property (nonatomic, readonly) VeLivePlayerAudioBufferType bufferType;
音频帧数据封装格式,详情请参见 VeLivePlayerAudioBufferType。
@property (nonatomic, readonly) int sampleRate;
音频采样率,单位为 Hz。
@property (nonatomic, readonly) int channels;
声道数。
@property (nonatomic, readonly) int bitDepth;
音频位深度。
@property (nonatomic, readonly) CMTime pts;
音频渲染时间戳,单位为 ms。
@property (nonatomic, strong, readonly) NSData* data;
PCM 音频数据。
@property (nonatomic, readonly) int samples;
音频采样点个数。
@interface VeLivePlayerVideoFrame : NSObject
视频帧数据。
| 类型 | 名称 |
|---|---|
| VeLivePlayerVideoBufferType | bufferType |
| VeLivePlayerPixelFormat | pixelFormat |
| NSInteger | width |
| NSInteger | height |
| int64_t | pts |
| CVPixelBufferRef | pixelBuffer |
| CMSampleBufferRef | sampleBuffer |
| NSData* | data |
@property (nonatomic, readonly) VeLivePlayerVideoBufferType bufferType;
视频帧数据封装格式,详情请参见 VeLivePlayerVideoBufferType。
@property (nonatomic, readonly) VeLivePlayerPixelFormat pixelFormat;
视频帧像素格式,详情请参见 VeLivePlayerPixelFormat。
@property (nonatomic, readonly) NSInteger width;
视频宽度,单位为 px。
@property (nonatomic, readonly) NSInteger height;
视频高度,单位为 px。
@property (nonatomic, readonly) int64_t pts;
视频帧的渲染时间戳,单位为 ms。
@property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;
pixelFormat 为 VeLivePlayerVideoBufferTypePixelBuffer 时的视频数据。
@property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;
pixelFormat 为 VeLivePlayerVideoBufferTypeSampleBuffer 时的视频数据。
@property (nonatomic, strong, readonly, nullable) NSData* data;
pixelFormat 为 VeLivePlayerVideoBufferTypeNSData 时的视频数据。
typedef NS_ENUM( NSInteger, VeLivePlayerSupportResolutionSwitchError )
分辨率档位切换报错信息。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerErrorResNotFound | -1 | 没有找到对应分辨率档位。 |
| VeLivePlayerErrorSameRes | -2 | 和当前分辨率档位相同。 |
| VeLivePlayerErrorStatusInvalid | -3 | 播放器状态为非 prepare 状态。 |
| VeLivePlayerErrorInvalidRes | -4 | 分辨率档位错误。 |
| VeLivePlayerErrorConfigNotSupport | -5 | 配置不支持。 |
| VeLivePlayerErrorFormatNotSupport | -6 | 格式不支持。 |
@interface VeLivePlayerStreamData : NSObject
播放地址相关配置。
| 类型 | 名称 |
|---|---|
| BOOL | enableABR |
| BOOL | enableMainBackupSwitch |
| BOOL | enableSmoothSwitchResolution |
| VeLivePlayerResolution | defaultResolution |
| VeLivePlayerFormat | defaultFormat |
| VeLivePlayerProtocol | defaultProtocol |
| NSArray<VeLivePlayerStream*>* | mainStream |
| NSArray<VeLivePlayerStream*>* | backupStream |
@property (nonatomic, assign) BOOL enableABR;
是否打开 ABR 平滑切档功能,默认为 NO。
YES:开启;NO:关闭。@property (nonatomic, assign) BOOL enableMainBackupSwitch;
是否打开主备切换,默认为 NO。
YES:开启;NO:关闭。@property (nonatomic, assign) BOOL enableSmoothSwitchResolution;
是否开启平滑切换清晰度功能。默认值为 NO。开启后,在调用 switchResolution: 手动切换清晰度时,SDK 会尝试进行平滑过渡,避免出现黑屏或卡顿。取值如下:
YES:开启。NO:关闭。@property (nonatomic, assign) VeLivePlayerResolution defaultResolution;
播放器的默认清晰度档位,默认使用原始流清晰度,详情请参见 VeLivePlayerResolution。
@property (nonatomic, assign) VeLivePlayerFormat defaultFormat;
播放器的默认播放格式,默认值为 FLV,详情请参见 VeLivePlayerFormat。
@property (nonatomic, assign) VeLivePlayerProtocol defaultProtocol;
播放器的默认播放传输层协议,默认值为 TCP,详情请参见 VeLivePlayerProtocol。
@property (nonatomic, copy, nullable) NSArray<VeLivePlayerStream *> * mainStream;
主路流地址列表,详情请参见 VeLivePlayerStream。
@property (nonatomic, copy, nullable) NSArray<VeLivePlayerStream *> * backupStream;
备路流地址列表,详情请参见 VeLivePlayerStream。
typedef NS_ENUM( NSInteger, VeLivePlayerAudioBufferType )
音频数据封装格式。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerAudioBufferUnknown | 0 | 未知格式。 |
| VeLivePlayerAudioBufferTypeSampleBuffer | 1 | CVSampleBufferRef 格式,音频数据以样本缓冲区 sample buffer 的形式进行处理和渲染。 |
| VeLivePlayerAudioBufferTypeNSData | 2 | NSData 格式,音频数据以 NSData 对象的形式进行处理和渲染。 |
typedef NS_ENUM( NSInteger, VeLivePlayerVideoBufferType )
视频数据封装格式。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerVideoBufferTypeUnknown | 0 | 未知格式。 |
| VeLivePlayerVideoBufferTypePixelBuffer | 1 | CVPixelBufferRef 格式。 |
| VeLivePlayerVideoBufferTypeSampleBuffer | 2 | CVSampleBufferRef 格式。 |
| VeLivePlayerVideoBufferTypeNSData | 3 | NSData 格式。 |
typedef NS_ENUM( NSInteger, VeLivePlayerProtocol )
直播播放传输协议。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerProtocolTCP | 0 | TCP 协议。 |
| VeLivePlayerProtocolQUIC | 1 | QUIC 协议。 |
| VeLivePlayerProtocolTLS | 2 | TLS 协议。 |
| VeLivePlayerProtocolHTTP2 | 3 | HTTP/2 协议。 |
| VeLivePlayerProtocolDefault | 4 | 默认值。播放器将根据拉流地址自动识别网络协议。目前仅支持自动识别 TCP 和 TLS 协议。如需使用 QUIC 或 HTTP/2 协议,请使用对应取值。 |
typedef NS_ENUM( NSInteger, VeLivePlayerFillMode )
直播播放器画面的填充模式。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerFillModeAspectFill | 0 | 视频填满画布。视频帧等比缩放,直至填满画布,超出屏幕的部分将被裁剪,画面可能不完整。 |
| VeLivePlayerFillModeAspectFit | 1 | 显示完整的视频帧。视频帧等比缩放,直至视频帧恰好在画布上全部显示。如果视频帧长宽比例与画布不同,视窗上未被视频帧填满区域将填充为黑色。 |
| VeLivePlayerFillModeFullFill | 2 | 视频帧自适应画布。视频帧非等比缩放,直至填满画布。在此过程中,视频帧的长宽比例可能会发生变化。 |
typedef NS_ENUM( NSInteger, VeLivePlayerRotation )
视频顺时针旋转角度。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerRotation0 | 0 | 关闭旋转。 |
| VeLivePlayerRotation90 | 90 | 顺时针旋转 90 度。 |
| VeLivePlayerRotation180 | 180 | 顺时针旋转 180 度。 |
| VeLivePlayerRotation270 | 270 | 顺时针旋转 270 度。 |
typedef NS_ENUM( NSInteger, VeLivePlayerMirror )
视频镜像。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerMirrorNone | 0 | 关闭镜像。 |
| VeLivePlayerMirrorHorizontal | 1 | 水平镜像。 |
| VeLivePlayerMirrorVertical | 2 | 垂直镜像。 |
typedef NS_ENUM( NSInteger, VeLivePlayerPixelFormat )
视频帧像素格式。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerPixelFormatUnknown | 0 | 未知格式。 |
| VeLivePlayerPixelFormatI420 | 2 | YUVI420 格式。 |
typedef NS_ENUM( NSInteger, VeLivePlayerStatus )
直播播放器状态。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerStatusPrepared | 0 | 播放器准备完成,等待渲染。 |
| VeLivePlayerStatusPlaying | 1 | 正在播放状态。 |
| VeLivePlayerStatusPaused | 2 | 暂停播放状态。 |
| VeLivePlayerStatusStopped | 3 | 停止播放状态。 |
| VeLivePlayerStatusError | 4 | 播放器发生错误。 |
| VeLivePlayerStatusStalled | 5 | 播放器发生卡顿。 |
@interface VeLivePlayerStatistics : NSObject
播放周期性统计信息。
| 类型 | 名称 |
|---|---|
| NSURL* | url |
| BOOL | isHardWareDecode |
| int | delayMs |
| int | stallTimeMs |
| long | bandwidthEstimation |
| NSString* | videoCodec |
| int | width |
| int | height |
| float | fps |
| long | bitrate |
| long | videoBufferMs |
| long | audioBufferMs |
| VeLivePlayerFormat | format |
| VeLivePlayerProtocol | protocol |
@property (nonatomic, strong, readonly, nullable) NSURL* url;
当前直播的播放地址。
@property (nonatomic, readonly) BOOL isHardWareDecode;
是否使用硬件解码。
YES:硬解;NO:非硬解。@property (nonatomic, readonly) int delayMs;
当前播放延时,单位为 ms。
@property (nonatomic, readonly) int stallTimeMs;
从当前视频开始播放起,累计的卡顿时长,单位为 ms。
@property (nonatomic, readonly) long bandwidthEstimation;
带宽预测 ,单位为 kbps。
@property (nonatomic, copy, readonly, nullable) NSString* videoCodec;
视频的编码类型。
@property (nonatomic, readonly) int width;
当前播放视频的宽度,单位为 px。
@property (nonatomic, readonly) int height;
当前播放视频的高度,单位为 px。
@property (nonatomic, readonly) float fps;
当前播放视频的帧率,单位为 fps。
@property (nonatomic, readonly) long bitrate;
实时下载的码率,单位为 kbps。
@property (nonatomic, readonly) long videoBufferMs;
视频播放的缓冲区 buffer 大小,单位为 ms。
@property (nonatomic, readonly) long audioBufferMs;
音频播放的缓冲区 buffer 大小,单位为 ms。
@property (nonatomic, readonly) VeLivePlayerFormat format;
当前播放的视频格式。
@property (nonatomic, readonly) VeLivePlayerProtocol protocol;
当前播放的传输协议。
@interface VeLivePlayerStreamInfo : NSObject
流信息
| 类型 | 名称 |
|---|---|
| int | width |
| int | height |
| int | bandwidth |
| NSString* | url |
@property (nonatomic, assign) int width;
视频的宽度,单位为 px。
@property (nonatomic, assign) int height;
视频的高度,单位为 px。
@property (nonatomic, assign) int bandwidth;
视频的带宽,单位为Bps
@property (nonatomic, copy) NSString *url;
视频的url。
typedef NS_ENUM( NSUInteger, VeLivePlayerType )
播放器类型。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerTypeOwn | 0 | 自研播放器。 |
| VeLivePlayerTypeSystem | 1 | 系统播放器。 |
typedef NS_ENUM( NSInteger, VeLivePlayerStreamType )
直播播放流类型。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerStreamTypeMain | 0 | 主路流。 |
| VeLivePlayerStreamTypeBackup | 1 | 备路流。 |
typedef NS_ENUM( NSInteger, VeLivePlayerFormat )
直播播放格式。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerFormatFLV | 0 | FLV 格式。 |
| VeLivePlayerFormatHLS | 1 | HLS 格式。 |
| VeLivePlayerFormatRTM | 2 | RTM 格式。 |
typedef NS_ENUM( NSInteger, VeLivePlayerResolution )
直播播放器的清晰度档位。
| 类型 | 值 | 说明 |
|---|---|---|
| VeLivePlayerResolutionOrigin | 0 | 原始流。 |
| VeLivePlayerResolutionUHD | 1 | UHD 超高清。 |
| VeLivePlayerResolutionFHD | 2 | FHD 全高清 |
| VeLivePlayerResolutionHD | 3 | HD 高清。 |
| VeLivePlayerResolutionSD | 4 | SD 标清。 |
| VeLivePlayerResolutionLD | 5 | LD 低清。 |
| VeLivePlayerResolutionAUTO | 8 | 自动档位。 |
typedef NSString * VeLivePlayerProperty;
高级配置。
| 类型 | 名称 |
|---|---|
| VeLivePlayerProperty | VeLivePlayerKeySetParamsHttpHeaders |
| VeLivePlayerProperty | VeLivePlayerKeySetParamsLowLatencyFlv |
OBJC_EXTERN const VeLivePlayerProperty VeLivePlayerKeySetParamsHttpHeaders;
设置播放器发起 HTTP 请求时携带的自定义请求头。常用于传递鉴权令牌(Token)、Cookie 或业务追踪标识等额外信息。具体使用方法,详见自定义 HTTP 请求头。
OBJC_EXTERN const VeLivePlayerProperty VeLivePlayerKeySetParamsLowLatencyFlv;
设置 FLV 低延时(延时 2–3 秒)参数配置。具体使用方法,详见 FLV 低延时。