You need to enable JavaScript to run this app.
文档中心
视频直播

视频直播

复制全文
下载 pdf
SDK API 参考
类型详情
复制全文
下载 pdf
类型详情

VeLivePlayerResolutionSwitchReason
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerResolutionSwitchReason
)

直播播放器清晰度档位变化原因。

枚举值

类型值说明
VeLivePlayerResolutionSwitchByAuto0ABR 自动切档。
VeLivePlayerResolutionSwitchByManual1调用 switchResolution:手动切换档位。

VeLivePlayerConfiguration
@interface VeLivePlayerConfiguration : NSObject

播放器初始化相关配置。

成员变量

类型名称
BOOLenableSei
BOOLenableBinarySei
BOOLenableHardwareDecode
BOOLenableLiveDNS
BOOLenableStatisticsCallback
NSIntegerstatisticsCallbackInterval
NSIntegernetworkTimeoutMs
NSIntegerretryIntervalTimeMs
NSIntegerretryMaxCount
NSIntegerstallRetryTimeout

成员函数

返回名称
instancetypeinit

变量说明

enableSei

@property (nonatomic, assign) BOOL enableSei;

是否开启字符串 SEI 消息的解析,默认值为 NO。

  • YES:开启;
  • NO:关闭。

enableBinarySei

@property (nonatomic, assign) BOOL enableBinarySei;

是否开启二进制 SEI 消息的解析,默认值为 NO。

  • YES:开启;
  • NO:关闭。

注意

二进制 SEI 开启后,字符串 SEI 的回调将不再发送。

enableHardwareDecode

@property (nonatomic, assign) BOOL enableHardwareDecode;

是否开启硬件解码功能,默认值为 YES。开启硬件解码后,如果出现硬件解码启动失败或硬件解码失败的情况,播放器内部会自动切换为软解。

  • YES:开启;
  • NO:关闭。

enableLiveDNS

@property (nonatomic, assign) BOOL enableLiveDNS;

是否开启本地 DNS 预解析,默认值为 YES。开启本地 DNS 预解析可以缩短启播时间。如果本地 DNS 预解析出现异常,可能会影响播放器的正常使用。

  • YES:开启;
  • NO:关闭。

enableStatisticsCallback

@property (nonatomic, assign) BOOL enableStatisticsCallback;

是否开启播放信息周期性回调。默认值为 NO。周期性回调参数详细说明请参见 VeLivePlayerStatistics 。当 enableStatisticsCallback 为 YES,且 statisticsCallbackInterval 大于 0 时,播放器会在指定的时间间隔内,周期性地回调播放器状态信息。

  • YES:开启;
  • NO:关闭。

statisticsCallbackInterval

@property (nonatomic, assign) NSInteger statisticsCallbackInterval;

播放信息周期性回调的时间间隔,单位为 s,默认值为 5。当 enableStatisticsCallback 为 YES,且 statisticsCallbackInterval 大于 0 时,播放器会在指定的时间间隔内,周期性地回调播放器状态信息。

networkTimeoutMs

@property (nonatomic, assign) NSInteger networkTimeoutMs;

网络超时时间,单位为 ms,默认值为 5000。播放器发起网络请求,如果超过了该时间仍未收到服务器响应,则认为网络请求失败。

retryIntervalTimeMs

@property (nonatomic, assign) NSInteger retryIntervalTimeMs;

重试时间间隔。单位为 ms,默认值为 5000。如果需要为每个流单独设置重试间隔,可以设置 retryIntervalTimeMs。

retryMaxCount

@property (nonatomic, assign) NSInteger retryMaxCount;

在网络连接错误的情况下,播放器的最大重试次数。默认值为 5。如果取值为 0,表示关闭播放器内部重试。如果需要为每个流单独设置最大重试次数,可以设置 retryMaxCount。

stallRetryTimeout

@property (nonatomic, assign) NSInteger stallRetryTimeout;

卡顿超时停止重试阈值。当卡顿时长超过该阈值时,播放器将不再进行重试。单位为 ms。默认值为 10000,即 10 秒。

函数说明

init

- (instancetype _Nonnull)init;

默认初始化方法。

VeLivePlayerStream
@interface VeLivePlayerStream : NSObject

流地址信息。

成员变量

类型名称
NSString*url
VeLivePlayerResolutionresolution
intbitrate
VeLivePlayerProtocolprotocol
VeLivePlayerFormatformat
VeLivePlayerStreamTypetype
NSUIntegerpriority
NSIntegerretryMaxCount
NSIntegerretryIntervalTimeMs

成员函数

返回名称
instancetypeinit

变量说明

url

@property (nonatomic, copy, nonnull) NSString *url;

播放地址。

resolution

@property (nonatomic, assign) VeLivePlayerResolution resolution;

清晰度档位,详情请参见 VeLivePlayerResolution。

bitrate

@property (nonatomic, assign) int bitrate;

播放码率,单位为 bps。

protocol

@property (nonatomic, assign) VeLivePlayerProtocol protocol;

传输协议,详情请参见 VeLivePlayerProtocol。

format

@property (nonatomic, assign) VeLivePlayerFormat format;

播放格式,详情请参见 VeLivePlayerFormat。

type

@property (nonatomic, assign) VeLivePlayerStreamType type;

播放流类型为主路或备路,详情请参见 VeLivePlayerStreamType。

priority

@property (nonatomic, assign) NSUInteger priority;

流的优先级。取值必须为 0(默认值)或正整数。取值越大,优先级越高。

retryMaxCount

@property (nonatomic, assign) NSInteger retryMaxCount;

流的最大重试次数,即总播放尝试次数(包含首次尝试)。例如,若取值为 3,则在首次播放失败后,播放器最多会再重试 2 次。取值如下:

  • -1(默认值):使用 VeLivePlayerConfiguration 中 retryMaxCount 的取值。
  • 0:不会尝试播放当前流。
  • > 0:具体次数。

retryIntervalTimeMs

@property (nonatomic, assign) NSInteger retryIntervalTimeMs;

重试时间间隔。单位为 ms,默认值为 -1。若取值为 -1,则使用 VeLivePlayerConfiguration 中 retryIntervalTimeMs 的取值。

函数说明

init

- (instancetype)init;

单路直播流配置初始化方法。

VeLivePlayerLogLevel
typedef NS_ENUM(
    NSUInteger,
    VeLivePlayerLogLevel
)

直播播放器日志打印级别。

枚举值

类型值说明
VeLivePlayerLogLevelVerbose0输出 VERBOSE、DEBUG、INFO、WARNING 和 ERROR 级别的日志。
VeLivePlayerLogLevelDebug1输出 DEBUG、INFO、WARNING 和 ERROR 级别的日志。
VeLivePlayerLogLevelInfo2输出 INFO、WARNING 和 ERROR 级别的日志。
VeLivePlayerLogLevelWarn3输出 WARNING 和 ERROR 级别的日志。
VeLivePlayerLogLevelError4输出 ERROR 级别的日志。
VeLivePlayerLogLevelNone5关闭日志打印。

VeLivePlayerAudioFrame
@interface VeLivePlayerAudioFrame : NSObject

音频帧数据。

成员变量

类型名称
VeLivePlayerAudioBufferTypebufferType
intsampleRate
intchannels
intbitDepth
CMTimepts
NSData*data
intsamples

变量说明

bufferType

@property (nonatomic, readonly) VeLivePlayerAudioBufferType bufferType;

音频帧数据封装格式,详情请参见 VeLivePlayerAudioBufferType。

sampleRate

@property (nonatomic, readonly) int sampleRate;

音频采样率,单位为 Hz。

channels

@property (nonatomic, readonly) int channels;

声道数。

  • 1:单声道;
  • 2:双声道。

bitDepth

@property (nonatomic, readonly) int bitDepth;

音频位深度。

pts

@property (nonatomic, readonly) CMTime pts;

音频渲染时间戳,单位为 ms。

data

@property (nonatomic, strong, readonly) NSData* data;

PCM 音频数据。

samples

@property (nonatomic, readonly) int samples;

音频采样点个数。

VeLivePlayerVideoFrame
@interface VeLivePlayerVideoFrame : NSObject

视频帧数据。

成员变量

类型名称
VeLivePlayerVideoBufferTypebufferType
VeLivePlayerPixelFormatpixelFormat
NSIntegerwidth
NSIntegerheight
int64_tpts
CVPixelBufferRefpixelBuffer
CMSampleBufferRefsampleBuffer
NSData*data

变量说明

bufferType

@property (nonatomic, readonly) VeLivePlayerVideoBufferType bufferType;

视频帧数据封装格式,详情请参见 VeLivePlayerVideoBufferType。

pixelFormat

@property (nonatomic, readonly) VeLivePlayerPixelFormat pixelFormat;

视频帧像素格式,详情请参见 VeLivePlayerPixelFormat。

width

@property (nonatomic, readonly) NSInteger width;

视频宽度,单位为 px。

height

@property (nonatomic, readonly) NSInteger height;

视频高度,单位为 px。

pts

@property (nonatomic, readonly) int64_t pts;

视频帧的渲染时间戳,单位为 ms。

pixelBuffer

@property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;

pixelFormat 为 VeLivePlayerVideoBufferTypePixelBuffer 时的视频数据。

sampleBuffer

@property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;

pixelFormat 为 VeLivePlayerVideoBufferTypeSampleBuffer 时的视频数据。

data

@property (nonatomic, strong, readonly, nullable) NSData* data;

pixelFormat 为 VeLivePlayerVideoBufferTypeNSData 时的视频数据。

VeLivePlayerSupportResolutionSwitchError
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerSupportResolutionSwitchError
)

分辨率档位切换报错信息。

枚举值

类型值说明
VeLivePlayerErrorResNotFound-1没有找到对应分辨率档位。
VeLivePlayerErrorSameRes-2和当前分辨率档位相同。
VeLivePlayerErrorStatusInvalid-3播放器状态为非 prepare 状态。
VeLivePlayerErrorInvalidRes-4分辨率档位错误。
VeLivePlayerErrorConfigNotSupport-5配置不支持。
VeLivePlayerErrorFormatNotSupport-6格式不支持。

VeLivePlayerStreamData
@interface VeLivePlayerStreamData : NSObject

播放地址相关配置。

成员变量

类型名称
BOOLenableABR
BOOLenableMainBackupSwitch
BOOLenableSmoothSwitchResolution
VeLivePlayerResolutiondefaultResolution
VeLivePlayerFormatdefaultFormat
VeLivePlayerProtocoldefaultProtocol
NSArray<VeLivePlayerStream*>*mainStream
NSArray<VeLivePlayerStream*>*backupStream

变量说明

enableABR

@property (nonatomic, assign) BOOL enableABR;

是否打开 ABR 平滑切档功能,默认为 NO。

  • YES:开启;
  • NO:关闭。

enableMainBackupSwitch

@property (nonatomic, assign) BOOL enableMainBackupSwitch;

是否打开主备切换,默认为 NO。

  • YES:开启;
  • NO:关闭。

enableSmoothSwitchResolution

@property (nonatomic, assign) BOOL enableSmoothSwitchResolution;

是否开启平滑切换清晰度功能。默认值为 NO。开启后,在调用 switchResolution: 手动切换清晰度时,SDK 会尝试进行平滑过渡,避免出现黑屏或卡顿。取值如下:

  • YES:开启。
  • NO:关闭。

defaultResolution

@property (nonatomic, assign) VeLivePlayerResolution defaultResolution;

播放器的默认清晰度档位,默认使用原始流清晰度,详情请参见 VeLivePlayerResolution。

defaultFormat

@property (nonatomic, assign) VeLivePlayerFormat defaultFormat;

播放器的默认播放格式,默认值为 FLV,详情请参见 VeLivePlayerFormat。

defaultProtocol

@property (nonatomic, assign) VeLivePlayerProtocol defaultProtocol;

播放器的默认播放传输层协议,默认值为 TCP,详情请参见 VeLivePlayerProtocol。

mainStream

@property (nonatomic, copy, nullable) NSArray<VeLivePlayerStream *> * mainStream;

主路流地址列表,详情请参见 VeLivePlayerStream。

backupStream

@property (nonatomic, copy, nullable) NSArray<VeLivePlayerStream *> * backupStream;

备路流地址列表,详情请参见 VeLivePlayerStream。

VeLivePlayerAudioBufferType
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerAudioBufferType
)

音频数据封装格式。

枚举值

类型值说明
VeLivePlayerAudioBufferUnknown0未知格式。
VeLivePlayerAudioBufferTypeSampleBuffer1CVSampleBufferRef 格式,音频数据以样本缓冲区 sample buffer 的形式进行处理和渲染。
VeLivePlayerAudioBufferTypeNSData2NSData 格式,音频数据以 NSData 对象的形式进行处理和渲染。

VeLivePlayerVideoBufferType
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerVideoBufferType
)

视频数据封装格式。

枚举值

类型值说明
VeLivePlayerVideoBufferTypeUnknown0未知格式。
VeLivePlayerVideoBufferTypePixelBuffer1CVPixelBufferRef 格式。
VeLivePlayerVideoBufferTypeSampleBuffer2CVSampleBufferRef 格式。
VeLivePlayerVideoBufferTypeNSData3NSData 格式。

VeLivePlayerProtocol
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerProtocol
)

直播播放传输协议。

枚举值

类型值说明
VeLivePlayerProtocolTCP0TCP 协议。
VeLivePlayerProtocolQUIC1QUIC 协议。
VeLivePlayerProtocolTLS2TLS 协议。
VeLivePlayerProtocolHTTP23HTTP/2 协议。
VeLivePlayerProtocolDefault4默认值。播放器将根据拉流地址自动识别网络协议。目前仅支持自动识别 TCP 和 TLS 协议。如需使用 QUIC 或 HTTP/2 协议,请使用对应取值。

VeLivePlayerFillMode
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerFillMode
)

直播播放器画面的填充模式。

枚举值

类型值说明
VeLivePlayerFillModeAspectFill0视频填满画布。视频帧等比缩放,直至填满画布,超出屏幕的部分将被裁剪,画面可能不完整。
VeLivePlayerFillModeAspectFit1显示完整的视频帧。视频帧等比缩放,直至视频帧恰好在画布上全部显示。如果视频帧长宽比例与画布不同,视窗上未被视频帧填满区域将填充为黑色。
VeLivePlayerFillModeFullFill2视频帧自适应画布。视频帧非等比缩放,直至填满画布。在此过程中,视频帧的长宽比例可能会发生变化。

VeLivePlayerRotation
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerRotation
)

视频顺时针旋转角度。

枚举值

类型值说明
VeLivePlayerRotation00关闭旋转。
VeLivePlayerRotation9090顺时针旋转 90 度。
VeLivePlayerRotation180180顺时针旋转 180 度。
VeLivePlayerRotation270270顺时针旋转 270 度。

VeLivePlayerMirror
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerMirror
)

视频镜像。

枚举值

类型值说明
VeLivePlayerMirrorNone0关闭镜像。
VeLivePlayerMirrorHorizontal1水平镜像。
VeLivePlayerMirrorVertical2垂直镜像。

VeLivePlayerPixelFormat
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerPixelFormat
)

视频帧像素格式。

枚举值

类型值说明
VeLivePlayerPixelFormatUnknown0未知格式。
VeLivePlayerPixelFormatI4202YUVI420 格式。

VeLivePlayerStatus
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerStatus
)

直播播放器状态。

枚举值

类型值说明
VeLivePlayerStatusPrepared0播放器准备完成,等待渲染。
VeLivePlayerStatusPlaying1正在播放状态。
VeLivePlayerStatusPaused2暂停播放状态。
VeLivePlayerStatusStopped3停止播放状态。
VeLivePlayerStatusError4播放器发生错误。
VeLivePlayerStatusStalled5播放器发生卡顿。

VeLivePlayerStatistics
@interface VeLivePlayerStatistics : NSObject

播放周期性统计信息。

成员变量

类型名称
NSURL*url
BOOLisHardWareDecode
intdelayMs
intstallTimeMs
longbandwidthEstimation
NSString*videoCodec
intwidth
intheight
floatfps
longbitrate
longvideoBufferMs
longaudioBufferMs
VeLivePlayerFormatformat
VeLivePlayerProtocolprotocol

变量说明

url

@property (nonatomic, strong, readonly, nullable) NSURL* url;

当前直播的播放地址。

isHardWareDecode

@property (nonatomic, readonly) BOOL isHardWareDecode;

是否使用硬件解码。

  • YES:硬解;
  • NO:非硬解。

delayMs

@property (nonatomic, readonly) int delayMs;

当前播放延时,单位为 ms。

stallTimeMs

@property (nonatomic, readonly) int stallTimeMs;

从当前视频开始播放起,累计的卡顿时长,单位为 ms。

bandwidthEstimation

@property (nonatomic, readonly) long bandwidthEstimation;

带宽预测 ,单位为 kbps。

videoCodec

@property (nonatomic, copy, readonly, nullable) NSString* videoCodec;

视频的编码类型。

width

@property (nonatomic, readonly) int width;

当前播放视频的宽度,单位为 px。

height

@property (nonatomic, readonly) int height;

当前播放视频的高度,单位为 px。

fps

@property (nonatomic, readonly) float fps;

当前播放视频的帧率,单位为 fps。

bitrate

@property (nonatomic, readonly) long bitrate;

实时下载的码率,单位为 kbps。

videoBufferMs

@property (nonatomic, readonly) long videoBufferMs;

视频播放的缓冲区 buffer 大小,单位为 ms。

audioBufferMs

@property (nonatomic, readonly) long audioBufferMs;

音频播放的缓冲区 buffer 大小,单位为 ms。

format

@property (nonatomic, readonly) VeLivePlayerFormat format;

当前播放的视频格式。

protocol

@property (nonatomic, readonly) VeLivePlayerProtocol protocol;

当前播放的传输协议。

VeLivePlayerStreamInfo
@interface VeLivePlayerStreamInfo : NSObject

流信息

成员变量

类型名称
intwidth
intheight
intbandwidth
NSString*url

变量说明

width

@property (nonatomic, assign) int width;

视频的宽度,单位为 px。

height

@property (nonatomic, assign) int height;

视频的高度,单位为 px。

bandwidth

@property (nonatomic, assign) int bandwidth;

视频的带宽,单位为Bps

url

@property (nonatomic, copy) NSString *url;

视频的url。

VeLivePlayerType
typedef NS_ENUM(
    NSUInteger,
    VeLivePlayerType
)

播放器类型。

枚举值

类型值说明
VeLivePlayerTypeOwn0自研播放器。
VeLivePlayerTypeSystem1系统播放器。

VeLivePlayerStreamType
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerStreamType
)

直播播放流类型。

枚举值

类型值说明
VeLivePlayerStreamTypeMain0主路流。
VeLivePlayerStreamTypeBackup1备路流。

VeLivePlayerFormat
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerFormat
)

直播播放格式。

枚举值

类型值说明
VeLivePlayerFormatFLV0FLV 格式。
VeLivePlayerFormatHLS1HLS 格式。
VeLivePlayerFormatRTM2RTM 格式。

VeLivePlayerResolution
typedef NS_ENUM(
    NSInteger,
    VeLivePlayerResolution
)

直播播放器的清晰度档位。

枚举值

类型值说明
VeLivePlayerResolutionOrigin0原始流。
VeLivePlayerResolutionUHD1UHD 超高清。
VeLivePlayerResolutionFHD2FHD 全高清
VeLivePlayerResolutionHD3HD 高清。
VeLivePlayerResolutionSD4SD 标清。
VeLivePlayerResolutionLD5LD 低清。
VeLivePlayerResolutionAUTO8自动档位。

VeLivePlayerProperty
typedef NSString * VeLivePlayerProperty;

高级配置。

成员变量

类型名称
VeLivePlayerPropertyVeLivePlayerKeySetParamsHttpHeaders
VeLivePlayerPropertyVeLivePlayerKeySetParamsLowLatencyFlv

变量说明

VeLivePlayerKeySetParamsHttpHeaders

OBJC_EXTERN const VeLivePlayerProperty VeLivePlayerKeySetParamsHttpHeaders;

设置播放器发起 HTTP 请求时携带的自定义请求头。常用于传递鉴权令牌(Token)、Cookie 或业务追踪标识等额外信息。具体使用方法,详见自定义 HTTP 请求头。

VeLivePlayerKeySetParamsLowLatencyFlv

OBJC_EXTERN const VeLivePlayerProperty VeLivePlayerKeySetParamsLowLatencyFlv;

设置 FLV 低延时(延时 2–3 秒)参数配置。具体使用方法,详见 FLV 低延时。

最近更新时间:2026.10.12 12:01:53
这个页面对您有帮助吗?
有用
有用
无用
无用