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

视频直播

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

VeLiveCameraDevice
public interface com.ss.avframework.live.VeLiveCameraDevice

相机设备管理对象。

成员函数

返回名称
int[]getRealFpsRange
intenableTorch
intsetZoomRatio
floatgetCurrentZoomRatio
floatgetMaxZoomRatio
floatgetMinZoomRatio
booleanisAutoFocusEnabled
intenableAutoFocus
intsetFocusPosition
booleanisExposurePositionSupported
intsetExposurePosition
floatgetMinExposureCompensation
floatgetMaxExposureCompensation
intsetExposureCompensation

函数说明

getRealFpsRange

int[] com.ss.avframework.live.VeLiveCameraDevice.getRealFpsRange()

获取相机支持帧率范围。

返回值

相机支持帧率范围。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

enableTorch

int com.ss.avframework.live.VeLiveCameraDevice.enableTorch(boolean enable)

开启/关闭闪光灯。

传入参数

参数名类型说明
enableboolean是否开启闪光灯。默认为 false。
  • true:开启;
  • false:关闭。

返回值

  • 0:开启/关闭成功;
  • ≠0:开启/关闭失败。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

setZoomRatio

int com.ss.avframework.live.VeLiveCameraDevice.setZoomRatio(float ratio)

设置摄像头的缩放倍数。

传入参数

参数名类型说明
ratiofloat缩放倍数。默认为原尺寸。缩放倍数的取值范围为 [getMinZoomRatio,getMaxZoomRatio]。

返回值

  • 0:缩放成功;
  • ≠0:缩放失败。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

getCurrentZoomRatio

float com.ss.avframework.live.VeLiveCameraDevice.getCurrentZoomRatio()

获取摄像头当前的缩放倍数。

返回值

  • ≤0:表示不支持缩放;
  • >0:支持缩放,数值表示当前缩放倍数。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

getMaxZoomRatio

float com.ss.avframework.live.VeLiveCameraDevice.getMaxZoomRatio()

获取摄像头的最大缩放倍数。

返回值

  • ≤0:表示不支持缩放;
  • >0:支持缩放,数值表示最大缩放倍数。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

getMinZoomRatio

float com.ss.avframework.live.VeLiveCameraDevice.getMinZoomRatio()

获取摄像头的最小缩放倍数。

返回值

  • ≤0:表示不支持缩放;
  • >0:支持缩放,数值表示最小缩放倍数。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

isAutoFocusEnabled

boolean com.ss.avframework.live.VeLiveCameraDevice.isAutoFocusEnabled()

是否支持自动对焦。

返回值

  • true:支持;
  • false:不支持。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

enableAutoFocus

int com.ss.avframework.live.VeLiveCameraDevice.enableAutoFocus(boolean enable)

开启/关闭自动对焦功能。

传入参数

参数名类型说明
enableboolean是否开启自动对焦,默认为 true。
  • true:开启;
  • false:关闭。

返回值

  • 0:开启/关闭成功;
  • ≠0:开启/关闭失败。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

setFocusPosition

int com.ss.avframework.live.VeLiveCameraDevice.setFocusPosition(
    int viewW,
    int viewH,
    int x,
    int y
)

设置摄像头的对焦位置。

传入参数

参数名类型说明
viewWint当前视图宽度。
viewHint当前视图高度。
xint以左上角为原点,对焦点距当前视图的横向坐标值。
yint以左上角为原点,对焦点距当前视图的纵向坐标值。

返回值

  • 0:设置成功;
  • ≠0:设置失败。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

isExposurePositionSupported

boolean com.ss.avframework.live.VeLiveCameraDevice.isExposurePositionSupported()

检查当前使用的摄像头是否支持手动设置曝光点。

返回值

  • YES:支持;
  • NO:不支持。

注意

必须已调用 startVideoCapture 使用 SDK 内部采集模块进行视频采集时,才能检查曝光点设置能力。

setExposurePosition

int com.ss.avframework.live.VeLiveCameraDevice.setExposurePosition(
    int viewW,
    int viewH,
    int x,
    int y
)

设置当前使用的摄像头的曝光点。

传入参数

参数名类型说明
viewWint当前视图宽度。
viewHint当前视图高度。
xint以左上角为原点,对焦点距当前视图的横向坐标值。
yint以左上角为原点,对焦点距当前视图的纵向坐标值。

返回值

  • =0:成功;
  • ≠0:失败。

注意

  • 必须已调用 startVideoCapture 使用 SDK 内部采集模块进行视频采集,并且使用 SDK 内部渲染时,才能设置曝光点;
  • 调用 stopVideoCapture 关闭内部采集后,设置的曝光点失效。

getMinExposureCompensation

float com.ss.avframework.live.VeLiveCameraDevice.getMinExposureCompensation()

获取摄像头的最小曝光补偿值。

返回值

  • ≤0:表示不支持曝光补偿;
  • >0:支持曝光补偿,数值表示最小曝光补偿。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

getMaxExposureCompensation

float com.ss.avframework.live.VeLiveCameraDevice.getMaxExposureCompensation()

获取摄像头的最大曝光补偿值。

返回值

  • ≤0:表示不支持曝光补偿;
  • >0:支持曝光补偿,数值表示最大曝光补偿。

注意

需要在调用 startVideoCapture 启动相机采集后,调用本方法。

setExposureCompensation

int com.ss.avframework.live.VeLiveCameraDevice.setExposureCompensation(float value)

设置当前使用的摄像头的曝光补偿。

传入参数

参数名类型说明
valuefloat曝光补偿值,取值范围 [getMinExposureCompensation,getMaxExposureCompensation],0 为系统默认值,表示没有曝光补偿。

返回值

  • =0:设置成功;
  • ≠0:设置失败。

注意

  • 必须已调用 startVideoCapture 使用 SDK 内部采集模块进行视频采集时,才能设置曝光补偿。
  • 调用 stopVideoCapture 关闭内部采集后,设置的曝光补偿失效。
VeLiveVideoEffectManager
public interface com.ss.avframework.live.VeLiveVideoEffectManager

视频特效管理对象。用于管理和设置视频特效,包括美颜、美形、美体、美妆、滤镜等。

成员函数

返回名称
intsetupWithConfig
voidupdateLicense
voidsetEnable
intsetAlgorithmModelPath
intsetComposeNodes
intappendComposeNodes
intremoveComposeNodes
intupdateComposerNodeIntensity
intsetFilter
intupdateFilterIntensity
intsetSticker
intsetAdvancedFeature

函数说明

setupWithConfig

int com.ss.avframework.live.VeLiveVideoEffectManager.setupWithConfig(VeLiveVideoEffectLicenseConfiguration config)

视频特效许可证配置,用于初始化视频特效管理对象。

传入参数

参数名类型说明
configVeLiveVideoEffectLicenseConfiguration特效初始化配置,详情请参见 VeLiveVideoEffectLicenseConfiguration。

返回值

  • 0:调用成功;
  • -1:调用失败。

updateLicense

void com.ss.avframework.live.VeLiveVideoEffectManager.updateLicense(VeLiveVideoEffectCallback callback)

如果您使用在线 License 认证方式,在许可证过期后,可调用该方法更新 License;

传入参数

参数名类型说明
callbackVeLiveVideoEffectCallback结果回调信息

注意

  • 需要通过调用 setupWithConfig 设置视频特效许可证后调用;
  • 本方法为异步操作。

setEnable

void com.ss.avframework.live.VeLiveVideoEffectManager.setEnable(
    boolean enable,
    VeLiveVideoEffectCallback callback
)

创建/销毁特效引擎。

传入参数

参数名类型说明
enableboolean是否创建特效引擎。默认为 false。
  • true:创建;
  • false:销毁。
callbackVeLiveVideoEffectCallback视频特效回调 VeLiveVideoEffectCallback。

返回值

  • 0:成功;
  • -1:失败。

注意

  • 该方法需要在调用 setupWithConfig 和 setAlgorithmModelPath 后调用;
  • 该方法不直接开启/关闭视频特效,您需要在调用该方法后,调用 setComposeNodes 开启视频特效;
  • 通用场景下,特效引擎会随 EffectManager 销毁而销毁。如果您对性能有较高要求,也可以在不使用特效相关功能时,调用该方法销毁特效引擎;
  • 如果重复创建/销毁特效引擎,会产生时间消耗。

setAlgorithmModelPath

int com.ss.avframework.live.VeLiveVideoEffectManager.setAlgorithmModelPath(String path)

设置特效算法模型包的路径。

传入参数

参数名类型说明
pathString特效算法模型包的路径

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

需要通过调用 setupWithConfig 设置视频特效许可证后调用。

setComposeNodes

int com.ss.avframework.live.VeLiveVideoEffectManager.setComposeNodes(String[] nodes)

设置视频特效组合。支持设置 ComposeMakeup.bundle 中的功能,包括美颜、美形、美体、美妆等。

传入参数

参数名类型说明
nodesString[]视频特效素材包路径数组

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

  • 需要在调用 setEnable 创建特效引擎后,调用本方法;
  • 重复调用本方法,仅最后一次调用生效;
  • 如果需要在当前的视频特效组合中叠加特效,可调用 appendComposeNodes 方法。

appendComposeNodes

int com.ss.avframework.live.VeLiveVideoEffectManager.appendComposeNodes(String[] nodes)

在已有的视频特效组合上,叠加视频特效素材包,您可以调用 setComposeNodes 设置视频特效组合。

传入参数

参数名类型说明
nodesString[]视频特效素材包路径数组

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

需要在调用 setEnable 创建特效引擎后,调用本方法。

removeComposeNodes

int com.ss.avframework.live.VeLiveVideoEffectManager.removeComposeNodes(String[] nodes)

调用本方法,可移除调用 setComposeNodes 和 appendComposeNodes 设置的视频特效资源。

传入参数

参数名类型说明
nodesString[]视频特效素材包路径数组

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

需要在调用 setEnable 创建特效引擎后,调用本方法。

updateComposerNodeIntensity

int com.ss.avframework.live.VeLiveVideoEffectManager.updateComposerNodeIntensity(
    String node,
    String key,
    float intensity
)

设置视频特效强度。

传入参数

参数名类型说明
nodeString视频特效素材包路径
keyString需要设置的素材 key 名称
intensityfloat需要设置的强度值。取值范围为 [0.0,1.0]

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

  • 需要在调用 setComposeNodes 设置视频特效组合或调用 appendComposeNodes 叠加视频特效素材包后,调用本方法;
  • 该方法仅适用于同时含有上述三个参数的特效资源,对于没有强度参数的特效(如贴纸),该方法无效。

setFilter

int com.ss.avframework.live.VeLiveVideoEffectManager.setFilter(String path)

设置颜色滤镜。

传入参数

参数名类型说明
pathString滤镜资源包绝对路径

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

请在调用 setEnable 开启视频特效后,调用该方法。

updateFilterIntensity

int com.ss.avframework.live.VeLiveVideoEffectManager.updateFilterIntensity(float intensity)

设置已启用的颜色滤镜强度。

传入参数

参数名类型说明
intensityfloat滤镜强度,取值范围为 [0.0,1.0]。

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

请在调用 setFilter 设置颜色滤镜后调用。

setSticker

int com.ss.avframework.live.VeLiveVideoEffectManager.setSticker(String path)

设置贴纸特效。

传入参数

参数名类型说明
pathString贴纸素材包的绝对路径

返回值

  • 0:调用成功;
  • -1:调用失败。

注意

请在调用 setEnable 开启视频特效后,调用该方法。

setAdvancedFeature

int com.ss.avframework.live.VeLiveVideoEffectManager.setAdvancedFeature(
    VeLiveVideoEffectHandleCallback callback,
    boolean isGLThread,
    boolean isAsync
)

智能美化特效的高级功能。

传入参数

参数名类型说明
callbackVeLiveVideoEffectHandleCallback将 handle 作为参数的回调函数。
isGLThreadboolean是否在 GL 线程回调 callback。
isAsyncboolean是否同步执行 callback。

注意

请在调用 setEnable 开启视频特效后,调用该方法,不要在主线程中频繁执行同步操作。

VeLivePusher
public interface com.ss.avframework.live.VeLivePusher

直播推流器。

静态函数

返回名称
static voidsetLogLevel
static voidsetEGLVersion
static voidsetEGLContext
static EGLContextgetEGLContext

成员函数

返回名称
voidrelease
voidsetObserver
voidsetStatisticsObserver
voidsetRenderView
voidsetRenderFillMode
voidsetVideoMirror
booleanisMirror
voidstartVideoCapture
voidstopVideoCapture
voidstartAudioCapture
voidstopAudioCapture
voidswitchVideoCapture
voidswitchAudioCapture
VeLiveVideoCaptureTypegetCurrentVideoCaptureType
VeLiveAudioCaptureTypegetCurrentAudioCaptureType
voidupdateCustomImage
VeLiveCameraDevicegetCameraDevice
voidsetVideoEncoderConfiguration
VeLiveVideoEncoderConfigurationgetVideoEncoderConfiguration
voidsetAudioEncoderConfiguration
VeLiveAudioEncoderConfigurationgetAudioEncoderConfiguration
voidstartPush
voidstartPushWithUrls
voidstopPush
booleanisPushing
intsetWatermark
voidstartFileRecording
voidstopFileRecording
intsetProperty
intpushExternalVideoFrame
intpushExternalAudioFrame
voidsetOrientation
intsendSeiMessage
voidsetMute
booleanisMute
VeLiveVideoEffectManagergetVideoEffectManager
intaddVideoFrameFilter
intremoveVideoFrameFilter
VeLiveAudioDevicegetAudioDevice
voidsetAudioFrameFilter
VeLiveMediaPlayercreatePlayer
VeLiveMixerManagergetMixerManager
voidstartMixSystemAudio
voidstopMixSystemAudio
booleanisScreenRecording
intaddVideoFrameListener
intremoveVideoFrameListener
intaddAudioFrameListener
intremoveAudioFrameListener
voidsnapshot

函数说明

setLogLevel

static void com.ss.avframework.live.VeLivePusher.setLogLevel(VeLivePusherLogLevel logLevel)

设置输出到控制台的日志等级。

传入参数

参数名类型说明
logLevelVeLivePusherLogLevel输出的日志级别。级别详情请参见 VeLivePusherLogLevel。

setEGLVersion

static void com.ss.avframework.live.VeLivePusher.setEGLVersion(int version)

设置 OpenGL 的版本号,默认值为 2。

传入参数

参数名类型说明
versionintOpenGL 版本号,支持的取值包括 2 和 3,分别对应 OpenGL 2.0 和 3.0 版本。

setEGLContext

static void com.ss.avframework.live.VeLivePusher.setEGLContext(EGLContext context)

设置 OpenGL 的上下文。

传入参数

参数名类型说明
contextEGLContextOpenGL 上下文。

getEGLContext

static EGLContext com.ss.avframework.live.VeLivePusher.getEGLContext()

获取 OpenGL 的上下文。

返回值

当前 OpenGL 的上下文。

release

void com.ss.avframework.live.VeLivePusher.release()

停止采集和推流,并销毁推流器。通常在调用 stopPush 结束推流后调用此方法进行清理。

setObserver

void com.ss.avframework.live.VeLivePusher.setObserver(VeLivePusherObserver observer)

设置推流器回调,通过设置回调,监听推流器的推流错误、状态、网络质量、设备、首帧等回调事件。

传入参数

参数名类型说明
observerVeLivePusherObserver推流器回调对象,详细信息请参见 VeLivePusherObserver。

注意

  • 需要在创建推流引擎后,调用本方法;
  • 重复调用本方法,仅最后一次调用生效。

setStatisticsObserver

void com.ss.avframework.live.VeLivePusher.setStatisticsObserver(
    VeLivePusherStatisticsObserver observer,
    int interval
)

设置推流器周期性回调,用于定期获取推流状态信息。

传入参数

参数名类型说明
observerVeLivePusherStatisticsObserver推流器周期性回调对象,详细信息请参见 VeLivePusherStatisticsObserver。
intervalint周期性回调的时间间隔,单位为 s,默认值为 5。

注意

  • 需要在创建推流引擎后,调用本方法;
  • 重复调用本方法,仅最后一次调用生效。

setRenderView

void com.ss.avframework.live.VeLivePusher.setRenderView(View view)

设置本地摄像头预览视图。摄像头采集到的画面,经过美颜、脸形调整、滤镜等多种效果叠加之后,最终会显示到传入的 View 上。

传入参数

参数名类型说明
viewView摄像头预览视图

setRenderFillMode

void com.ss.avframework.live.VeLivePusher.setRenderFillMode(VeLivePusherRenderMode mode)

设置本地预览画面的填充模式。

传入参数

参数名类型说明
modeVeLivePusherRenderMode填充模式。

setVideoMirror

void com.ss.avframework.live.VeLivePusher.setVideoMirror(
    VeLiveVideoMirrorType type,
    boolean mirror
)

开启/关闭镜像。

传入参数

参数名类型说明
typeVeLiveVideoMirrorType镜像类型,详细信息请参见 VeLiveVideoMirrorType。
mirrorboolean是否开启镜像。
  • true:开启;
  • false:关闭。

注意

用于配置视频镜像效果,影响采集、预览和推流画面。

isMirror

boolean com.ss.avframework.live.VeLivePusher.isMirror(
    VeLiveVideoMirrorType mirrorType,
    VeLiveVideoCaptureType captureType
)

获取指定镜像类型和采集类型下的视频镜像状态。适用于主播需要了解当前镜像状态的场景,例如直播前确认预览画面是否符合预期。

传入参数

参数名类型说明
mirrorTypeVeLiveVideoMirrorType镜像类型。详细信息请参见 VeLiveVideoMirrorType。
captureTypeVeLiveVideoCaptureType视频采集类型。详细信息请参见 VeLiveVideoCaptureType。

返回值

视频镜像状态。

  • true:已开启镜像。
  • false:未开启镜像。

startVideoCapture

void com.ss.avframework.live.VeLivePusher.startVideoCapture(VeLiveVideoCaptureType type)

开始视频采集。

传入参数

参数名类型说明
typeVeLiveVideoCaptureType视频采集类型,详细信息请参见 VeLiveVideoCaptureType

注意

调用该接口后,可以通过调用接口 stopVideoCapture 停止视频采集。

stopVideoCapture

void com.ss.avframework.live.VeLivePusher.stopVideoCapture()

停止视频采集。

注意

调用该接口后,可以通过调用接口 startVideoCapture 开始视频采集。

startAudioCapture

void com.ss.avframework.live.VeLivePusher.startAudioCapture(VeLiveAudioCaptureType type)

开始音频采集。

传入参数

参数名类型说明
typeVeLiveAudioCaptureType音频采集类型,详细信息请参见 VeLiveAudioCaptureType。

注意

调用该接口后,可以通过调用接口 stopAudioCapture 停止音频采集。

stopAudioCapture

void com.ss.avframework.live.VeLivePusher.stopAudioCapture()

停止音频采集。

注意

调用该接口后,可以通过调用接口 startAudioCapture 开始音频采集。

switchVideoCapture

void com.ss.avframework.live.VeLivePusher.switchVideoCapture(VeLiveVideoCaptureType type)

切换视频采集类型。

传入参数

参数名类型说明
typeVeLiveVideoCaptureType视频采集类型,详细信息请参见 VeLiveVideoCaptureType。

注意

该接口必须在调用接口 startVideoCapture 后调用才能生效。

switchAudioCapture

void com.ss.avframework.live.VeLivePusher.switchAudioCapture(VeLiveAudioCaptureType type)

切换音频采集类型。

传入参数

参数名类型说明
typeVeLiveAudioCaptureType音频采集类型,详细信息请参见 VeLiveAudioCaptureType。

注意

该接口必须在调用接口 startVideoCapture 后调用才能生效。

getCurrentVideoCaptureType

VeLiveVideoCaptureType com.ss.avframework.live.VeLivePusher.getCurrentVideoCaptureType()

获取当前视频采集类型。

返回值

视频采集类型,详细信息请参见 VeLiveVideoCaptureType。

getCurrentAudioCaptureType

VeLiveAudioCaptureType com.ss.avframework.live.VeLivePusher.getCurrentAudioCaptureType()

获取当前音频采集类型。

返回值

音频采集类型,详细信息请参见 VeLiveAudioCaptureType。

updateCustomImage

void com.ss.avframework.live.VeLivePusher.updateCustomImage(Bitmap image)

自定义静态图,适用于静态图推流采集类型。使用该接口时,需要将视频采集类型设置为 VeLiveVideoCaptureCustomImage,您可调用 startVideoCapture 方法,将 VeLiveVideoCaptureType 设置为 VeLiveVideoCaptureCustomImage。

传入参数

参数名类型说明
imageBitmap静态图片,用于在静态图推流采集类型下设置静态图。

getCameraDevice

VeLiveCameraDevice com.ss.avframework.live.VeLivePusher.getCameraDevice()

获取相机设备管理对象 VeLiveCameraDevice。通过设备管理,您可以使用以下功能。

  • 控制闪光灯开关
  • 设置摄像头缩放比例
  • 设置自动对焦

返回值

相机设备管理对象 VeLiveCameraDevice。

注意

该接口需要在 startVideoCapture 方法中设置 VeLiveVideoCaptureType 为 VeLiveVideoCaptureFrontCamera 或 VeLiveVideoCaptureBackCamera。

setVideoEncoderConfiguration

void com.ss.avframework.live.VeLivePusher.setVideoEncoderConfiguration(VeLiveVideoEncoderConfiguration config)

设置推流视频编码参数。

传入参数

参数名类型说明
configVeLiveVideoEncoderConfiguration推流视频参数,支持设置推流视频分辨率、编码格式、目标码率和视频 GOP 大小等信息。详情请参见 VeLiveVideoEncoderConfiguration。

注意

该接口可在推流开始前或开始后调用。

getVideoEncoderConfiguration

VeLiveVideoEncoderConfiguration com.ss.avframework.live.VeLivePusher.getVideoEncoderConfiguration()

获取推流视频编码参数。

返回值

推流视频参数,支持设置推流视频分辨率、编码格式、目标码率和视频 GOP 大小等信息。详情请参见 VeLiveVideoEncoderConfiguration。

setAudioEncoderConfiguration

void com.ss.avframework.live.VeLivePusher.setAudioEncoderConfiguration(VeLiveAudioEncoderConfiguration config)

设置推流音频编码参数。

传入参数

参数名类型说明
configVeLiveAudioEncoderConfiguration推流音频编码参数,详情请参见 VeLiveAudioEncoderConfiguration。

注意

该接口需要在 startPush 或 startPushWithUrls 方法之前调用。

getAudioEncoderConfiguration

VeLiveAudioEncoderConfiguration com.ss.avframework.live.VeLivePusher.getAudioEncoderConfiguration()

获取推流音频编码参数。

返回值

推流音频编码参数,详情请参见 VeLiveAudioEncoderConfiguration。

startPush

void com.ss.avframework.live.VeLivePusher.startPush(String url)

开始推流。

传入参数

参数名类型说明
urlString推流地址,用于将直播流推送到目标服务器。

startPushWithUrls

void com.ss.avframework.live.VeLivePusher.startPushWithUrls(String[] urls)

开始推流,支持备用推流地址。

传入参数

参数名类型说明
urlsString[]推流地址列表,包含一个或多个推流地址。

注意

当主推流地址不可用时,会自动切换到备用推流地址继续推流。

stopPush

void com.ss.avframework.live.VeLivePusher.stopPush()

停止推流。

注意

停止推流后,可以通过调用 startPush 或 startPushWithUrls 方法重新开始推流。

isPushing

boolean com.ss.avframework.live.VeLivePusher.isPushing()

当前是否正在推流中,可用来查询推流器的当前状态。

返回值

是否正在推流。

  • true:正在推流中;
  • false:已经停止推流。

setWatermark

int com.ss.avframework.live.VeLivePusher.setWatermark(
    Bitmap image,
    float x,
    float y,
    float scale
)

设置推流水印。

传入参数

参数名类型说明
imageBitmap水印图片。取值为 null 时,表示禁用水印。
xfloat水印的水平偏移量,即水印图片相对视频流左上角的横向偏移与视频流宽度的比值,取值范围为 [0.0,1.0]。
yfloat水印的垂直偏移量,即水印图片相对视频流左上角的纵向偏移与视频流高度的比值,取值范围为 [0.0,1.0]。
scalefloat水印图片的缩放比例,取值范围为 [0.0,1.0]。

返回值

  • 0:水印设置成功;
  • <0:水印设置失败。

startFileRecording

void com.ss.avframework.live.VeLivePusher.startFileRecording(
    String path,
    VeLiveFileRecorderConfiguration config,
    VeLiveFileRecordingListener listener
)

开始本地文件录制。

传入参数

参数名类型说明
pathString录制文件保存路径,不能为空。
configVeLiveFileRecorderConfiguration文件录制设置,详情请参见 VeLiveFileRecorderConfiguration。
listenerVeLiveFileRecordingListener本地文件录制的监听,详情请参见 VeLiveFileRecordingListener。

stopFileRecording

void com.ss.avframework.live.VeLivePusher.stopFileRecording()

停止本地文件录制。

注意

该接口需要在 startFileRecording 方法之后调用。

setProperty

int com.ss.avframework.live.VeLivePusher.setProperty(
    String key,
    Object value
)

高级配置。

传入参数

参数名类型说明
keyString推流高级配置为 JSON 格式的字符串,此参数为 JSON 结构中的 Key。您可通过提交工单联系技术支持,了解配置方法。
valueObject推流高级配置为 JSON 格式的字符串,此参数为 JSON 结构中的 Value。您可通过提交工单联系技术支持,了解配置方法。

返回值

  • 0:成功;
  • -1:失败,参数错误。

pushExternalVideoFrame

int com.ss.avframework.live.VeLivePusher.pushExternalVideoFrame(VeLiveVideoFrame frame)

推送外部视频帧数据。

传入参数

参数名类型说明
frameVeLiveVideoFrame视频帧的数据信息,详情请参见 VeLiveVideoFrame。

返回值

  • 0:成功;
  • <0:失败。

注意

调用该接口时,需要将视频采集类型设置为 VeLiveVideoCaptureExternal,您可调用 startVideoCapture 方法,将 VeLiveVideoCaptureType 设置为 VeLiveVideoCaptureExternal。

pushExternalAudioFrame

int com.ss.avframework.live.VeLivePusher.pushExternalAudioFrame(VeLiveAudioFrame frame)

推送外部音频帧数据。

传入参数

参数名类型说明
frameVeLiveAudioFrame外部音频数据。详情请参见 VeLiveAudioFrame。

返回值

  • 0:成功;
  • <0:失败。

注意

该接口需要在 startAudioCapture 方法中设置 VeLiveAudioCaptureType 为 VeLiveAudioCaptureExternal。

setOrientation

void com.ss.avframework.live.VeLivePusher.setOrientation(VeLiveOrientation orientation)

设置推流视频帧朝向。默认为竖屏推流。

传入参数

参数名类型说明
orientationVeLiveOrientation视频帧朝向,详情请参见 VeLiveOrientation。

sendSeiMessage

int com.ss.avframework.live.VeLivePusher.sendSeiMessage(
    String key,
    Object value,
    int repeat,
    boolean isKeyFrame,
    boolean allowsCovered
)

通过视频帧发送 SEI 消息。

传入参数

参数名类型说明
keyStringSEI 消息为 JSON 格式的字符串。此参数为 JSON 结构中的 Key。
valueObjectSEI 消息为 JSON 格式的字符串。此参数为 JSON 结构中的 Value。
repeatint消息发送重复的次数。例如,repeat 取值为 20,isKeyFrame 取值为 YES,则会在视频帧开始的连续 20 个关键帧中添加 SEI 消息。
isKeyFrameboolean是否仅在关键帧中包含 SEI 消息。
  • true:仅在关键帧中包含;
  • false:所有帧中均包含。
allowsCoveredboolean是否允许覆盖。
  • true:允许;
  • false:不允许。

返回值

  • 0:成功;
  • <0:失败。

注意

该接口需要在调用 startPush 或 startPushWithUrls 方法之后调用。

setMute

void com.ss.avframework.live.VeLivePusher.setMute(boolean mute)

设置静音。

传入参数

参数名类型说明
muteboolean是否设置为静音。默认为正常推流。
  • true:静音推流;
  • false:正常推流。

isMute

boolean com.ss.avframework.live.VeLivePusher.isMute()

当前是否是静音状态。

返回值

  • true:当前是静音状态;
  • false:当前非静音状态。

getVideoEffectManager

VeLiveVideoEffectManager com.ss.avframework.live.VeLivePusher.getVideoEffectManager()

获取视频特效管理对象 VeLiveVideoEffectManager。通过视频特效管理,您可以使用以下功能。

  • 设置美颜
  • 设置特效
  • 设置素材
  • 设置贴图
  • 设置滤镜

返回值

视频特效管理对象 VeLiveVideoEffectManager。

注意

该接口需要集成智能美化特效 SDK 后才能使用。

addVideoFrameFilter

int com.ss.avframework.live.VeLivePusher.addVideoFrameFilter(
    VeLivePixelFormat format,
    VeLiveVideoBufferType bufferType,
    VeLiveVideoFrameFilter filter
)

自定义视频处理。

传入参数

参数名类型说明
formatVeLivePixelFormat视频像素格式,详情请参见 VeLivePixelFormat。
bufferTypeVeLiveVideoBufferType视频数据类型,详情请参见 VeLiveVideoBufferType。
filterVeLiveVideoFrameFilter视频数据处理回调,详情请参见 VeLiveVideoFrameFilter。

返回值

  • 0:成功;
  • <0:失败。

removeVideoFrameFilter

int com.ss.avframework.live.VeLivePusher.removeVideoFrameFilter(VeLiveVideoFrameFilter filter)

移除已添加的视频帧自定义处理监听。

传入参数

参数名类型说明
filterVeLiveVideoFrameFilter视频数据处理回调,需要与 addVideoFrameFilter 中传入的实例一致。详情请参见 VeLiveVideoFrameFilter。

返回值

  • 0:成功;
  • <0:失败。

注意

如果没有添加过此监听回调或者监听回调已被移除,调用此方法将返回失败。

getAudioDevice

VeLiveAudioDevice com.ss.avframework.live.VeLivePusher.getAudioDevice()

获取音频模块管理对象。

返回值

音频模块管理对象 VeLiveAudioDevice。

注意

该接口需要在 startAudioCapture 方法中设置 VeLiveAudioCaptureType 为 VeLiveAudioCaptureMicrophone。

setAudioFrameFilter

void com.ss.avframework.live.VeLivePusher.setAudioFrameFilter(VeLiveAudioFrameFilter filter)

自定义音频处理。

传入参数

参数名类型说明
filterVeLiveAudioFrameFilter音频帧滤镜对象 VeLiveAudioFrameFilter 。

createPlayer

VeLiveMediaPlayer com.ss.avframework.live.VeLivePusher.createPlayer()

创建播放器。

返回值

播放器管理对象 VeLiveMediaPlayer。

getMixerManager

VeLiveMixerManager com.ss.avframework.live.VeLivePusher.getMixerManager()

获取混流管理对象。

返回值

混流管理对象 VeLiveMixerManager。

startMixSystemAudio

void com.ss.avframework.live.VeLivePusher.startMixSystemAudio()

开始系统音频采集。

stopMixSystemAudio

void com.ss.avframework.live.VeLivePusher.stopMixSystemAudio()

停止系统音频采集。

isScreenRecording

boolean com.ss.avframework.live.VeLivePusher.isScreenRecording()

获取当前是否处于屏幕采集状态。

addVideoFrameListener

int com.ss.avframework.live.VeLivePusher.addVideoFrameListener(VeLiveVideoFrameListener listener)

添加视频帧的监听回调,用于获取推流器输出的视频帧。

传入参数

参数名类型说明
listenerVeLiveVideoFrameListener视频帧的监听回调,详细信息请参见 VeLiveVideoFrameListener。

返回值

  • 0:成功;
  • <0:失败。

removeVideoFrameListener

int com.ss.avframework.live.VeLivePusher.removeVideoFrameListener(VeLiveVideoFrameListener listener)

移除已添加的视频帧监听回调。

传入参数

参数名类型说明
listenerVeLiveVideoFrameListener视频帧的监听回调,详细信息请参见 VeLiveVideoFrameListener。

返回值

  • 0:成功;
  • <0:失败。

注意

如果没有添加过此监听回调或者监听回调已被移除,调用此方法将返回失败。

addAudioFrameListener

int com.ss.avframework.live.VeLivePusher.addAudioFrameListener(VeLiveAudioFrameListener listener)

添加音频帧的监听回调,用于获取推流器输出的音频帧。

传入参数

参数名类型说明
listenerVeLiveAudioFrameListener音频帧监听回调,详细信息请参见 VeLiveAudioFrameListener。

返回值

  • 0:成功;
  • <0:失败。

removeAudioFrameListener

int com.ss.avframework.live.VeLivePusher.removeAudioFrameListener(VeLiveAudioFrameListener listener)

移除已添加的音频帧监听回调。

传入参数

参数名类型说明
listenerVeLiveAudioFrameListener音频帧的监听回调,详细信息请参见 VeLiveAudioFrameListener。

返回值

  • 0:成功;
  • <0:失败。

注意

如果没有添加过此监听回调或者监听回调已被移除,调用此方法将返回失败。

snapshot

void com.ss.avframework.live.VeLivePusher.snapshot(VeLiveSnapshotListener listener)

视频截图。

传入参数

参数名类型说明
listenerVeLiveSnapshotListener截图监听对象,详情请参见 VeLiveSnapshotListener。

VeLiveMixerManager
public interface com.ss.avframework.live.VeLiveMixerManager

音视频混流器管理对象。支持添加/移除音视频流、发送自定义音视频帧、更新混流布局等。

成员函数

返回名称
intaddVideoStream
intaddAudioStream
intaddAudioStream
intgetOriginVideoStream
intgetOriginAudioStream
intgetOriginScreenStream
intgetOriginSystemAudioStream
voidsendCustomVideoFrame
voidsendCustomAudioFrame
voidupdateStreamMixDescription
voidremoveVideoStream
voidremoveAudioStream

函数说明

addVideoStream

int com.ss.avframework.live.VeLiveMixerManager.addVideoStream()

添加一路需要混流的视频流到混流器中。

返回值

视频流 ID。

addAudioStream

int com.ss.avframework.live.VeLiveMixerManager.addAudioStream()

添加一路音频流到混流器中。

返回值

音频流 ID。

addAudioStream

int com.ss.avframework.live.VeLiveMixerManager.addAudioStream(VeLiveAudioMixType type)

添加一路音频流到混流器中,并指定混流类型。

传入参数

参数名类型说明
typeVeLiveAudioMixType混流类型,详情请参见 VeLiveAudioMixType 。

返回值

音频流 ID。

getOriginVideoStream

int com.ss.avframework.live.VeLiveMixerManager.getOriginVideoStream()

获取主路视频流 ID。

getOriginAudioStream

int com.ss.avframework.live.VeLiveMixerManager.getOriginAudioStream()

获取主路音频流 ID。

getOriginScreenStream

int com.ss.avframework.live.VeLiveMixerManager.getOriginScreenStream()

获取主路屏幕流 ID。

getOriginSystemAudioStream

int com.ss.avframework.live.VeLiveMixerManager.getOriginSystemAudioStream()

获取主路系统音频流 ID。

sendCustomVideoFrame

void com.ss.avframework.live.VeLiveMixerManager.sendCustomVideoFrame(
    VeLiveVideoFrame frame,
    int streamId
)

发送指定混流 ID 的自定义视频帧数据。

传入参数

参数名类型说明
frameVeLiveVideoFrame自定义的视频帧,详情请参见 VeLiveVideoFrame 。
streamIdint需要混流的视频流 ID。

sendCustomAudioFrame

void com.ss.avframework.live.VeLiveMixerManager.sendCustomAudioFrame(
    VeLiveAudioFrame frame,
    int streamId
)

发送指定混流 ID 的自定义音频帧数据。

传入参数

参数名类型说明
frameVeLiveAudioFrame自定义的音频帧,详情请参见 VeLiveAudioFrame 。
streamIdint混流的音频流 ID。

updateStreamMixDescription

void com.ss.avframework.live.VeLiveMixerManager.updateStreamMixDescription(VeLiveStreamMixDescription mixDescription)

更新音视频混流的布局。

传入参数

参数名类型说明
mixDescriptionVeLiveStreamMixDescription新的音视频混流布局,详情请参见 VeLiveStreamMixDescription。

removeVideoStream

void com.ss.avframework.live.VeLiveMixerManager.removeVideoStream(int streamId)

从混流器中移除一路非主路的视频流。

传入参数

参数名类型说明
streamIdint需要移除的非主路视频流 ID。

removeAudioStream

void com.ss.avframework.live.VeLiveMixerManager.removeAudioStream(int streamId)

从混流器中移除一路非主路的音频流。

传入参数

参数名类型说明
streamIdint需要移除的非主路音频流 ID。

VeLiveMediaPlayer
public interface com.ss.avframework.live.VeLiveMediaPlayer

媒体播放器对象。

成员函数

返回名称
voidrelease
voidsetListener
intprepare
intstart
intstop
voidpause
voidresume
longgetDuration
intseek
voidenableMixer
voidenableAutoEq
voidsetFrameListener
voidsetBGMVolume
voidsetVoiceVolume
voidenableBGMLoop

函数说明

release

void com.ss.avframework.live.VeLiveMediaPlayer.release()

销毁播放器实例。

setListener

void com.ss.avframework.live.VeLiveMediaPlayer.setListener(VeLiveMediaPlayerListener listener)

设置播放状态的监听。

传入参数

参数名类型说明
listenerVeLiveMediaPlayerListener播放状态监听。详情请参见 VeLiveMediaPlayerListener。

注意

重复调用本方法,仅最后一次调用生效。

prepare

int com.ss.avframework.live.VeLiveMediaPlayer.prepare(String url)

设置文件路径。支持的文件格式包括 MP3、AAC、M4A、WAV。

传入参数

参数名类型说明
urlString文件路径。

返回值

  • 0:成功;
  • ≠0:失败。

start

int com.ss.avframework.live.VeLiveMediaPlayer.start()

开始播放。

注意

需要在调用 start 开始播放后,调用本方法。

stop

int com.ss.avframework.live.VeLiveMediaPlayer.stop()

停止播放。

返回值

  • 0:成功;
  • ≠0:失败。

注意

需要在调用 start 开始播放后,调用本方法。

pause

void com.ss.avframework.live.VeLiveMediaPlayer.pause()

暂停播放。

注意

需要在调用 start 开始播放后,调用本方法。

resume

void com.ss.avframework.live.VeLiveMediaPlayer.resume()

恢复播放。

注意

需要在调用 pause 暂停播放后,调用本方法。

getDuration

long com.ss.avframework.live.VeLiveMediaPlayer.getDuration()

获取文件的总时长,单位为 ms。

返回值

  • >0:成功,音频文件时长;
  • ≤0:失败。

注意

需要在调用 start 开始播放后,调用本方法。

seek

int com.ss.avframework.live.VeLiveMediaPlayer.seek(long posMs)

设置播放进度。

传入参数

参数名类型说明
posMslong播放时间,单位为 ms。

返回值

  • 0:成功;
  • ≠0:失败。

enableMixer

void com.ss.avframework.live.VeLiveMediaPlayer.enableMixer(boolean enable)

开启/关闭音频是否混音到直播流。

传入参数

参数名类型说明
enableboolean开启/关闭,默认为 false。
  • ture:开启;
  • false:关闭。

enableAutoEq

void com.ss.avframework.live.VeLiveMediaPlayer.enableAutoEq(
    float sourceLufs,
    float targetLufs
)

开启/关闭自动音量均衡。

传入参数

参数名类型说明
sourceLufsfloat源响度。
targetLufsfloat目标响度。

setFrameListener

void com.ss.avframework.live.VeLiveMediaPlayer.setFrameListener(VeLiveMediaPlayerFrameListener listener)

设置音视频帧回调的监听。

传入参数

参数名类型说明
listenerVeLiveMediaPlayerFrameListener音视频帧回调监听。详情请参见 VeLiveMediaPlayerFrameListener。

注意

重复调用本方法,仅最后一次调用生效。

setBGMVolume

void com.ss.avframework.live.VeLiveMediaPlayer.setBGMVolume(float volume)

设置播放音频的音量。

传入参数

参数名类型说明
volumefloat播放音频音量,取值范围为 [0.0,4.0]。

setVoiceVolume

void com.ss.avframework.live.VeLiveMediaPlayer.setVoiceVolume(float volume)

设置音频采集音量。

传入参数

参数名类型说明
volumefloat音频采集音量,取值范围为 [0.0,4.0]。

注意

需要在调用 start 开始播放背景音乐后,调用本方法。

enableBGMLoop

void com.ss.avframework.live.VeLiveMediaPlayer.enableBGMLoop(boolean loop)

设置是否循环播放。

传入参数

参数名类型说明
loopboolean是否循环播放。默认为 false。
  • true:循环播放;
  • false:不循环播放。

VeLiveAudioDevice
public interface com.ss.avframework.live.VeLiveAudioDevice

音频设备管理类。该类提供了用于管理和控制音频设备,包括设置音量、获取当前音量的方法。

成员函数

返回名称
voidsetVoiceLoudness
floatgetVoiceLoudness

函数说明

setVoiceLoudness

void com.ss.avframework.live.VeLiveAudioDevice.setVoiceLoudness(float level)

设置音量响度。

传入参数

参数名类型说明
levelfloat音量响度等级,取值范围为 [0.0,4.0]。

getVoiceLoudness

float com.ss.avframework.live.VeLiveAudioDevice.getVoiceLoudness()

获取当前音量响度。

返回值

当前音量响度等级。

最近更新时间:2026.01.06 19:52:23
这个页面对您有帮助吗?
有用
有用
无用
无用