public interface ILivePusher
AlivcLivePusher
Modifier and Type | Method and Description |
---|---|
int |
addDynamicsAddons(java.lang.String path,
float x,
float y,
float w,
float h)
添加动态贴纸
|
void |
addWaterMark(java.lang.String path,
float x,
float y,
float width)
添加水印,起点位置坐标x[0,width) y[0,height),宽度(0,width],最多添加3个
需在startPreview之后调用
|
void |
changeResolution(AlivcResolutionEnum resolutionEnum)
change resolution dynamically
|
void |
destroy()
释放推流
|
void |
focusCameraAtAdjustedPoint(float x,
float y,
boolean autoFocus)
对焦,对焦点的坐标x[0,屏幕宽度],y[0,屏幕宽度]
|
int |
getCurrentExposure()
获取采集曝光
|
AlivcLivePushStats |
getCurrentStatus()
获取当前状态
|
int |
getCurrentZoom()
获取当前缩放值
|
AlivcLivePushError |
getLastError()
获取最近的错误值
|
AlivcLivePushStatsInfo |
getLivePushStatsInfo()
获取推流统计数据
|
java.lang.String |
getLiveTraceId()
获取直播trace id
|
int |
getMaxZoom()
获取摄像头支持的最大缩放值, 0 : 不支持缩放 大于0 : 最大缩放值
|
java.lang.String |
getPushUrl()
获取推流URL
|
int |
getSupportedMaxExposure()
获取采集支持最大曝光
|
int |
getSupportedMinExposure()
获取采集支持最小曝光
|
void |
init(android.content.Context context,
AlivcLivePushConfig config)
初始化推流参数
|
void |
inputStreamAudioData(byte[] data,
int size,
int sampleRate,
int channels,
long pts)
输入自定义音频数据
|
void |
inputStreamAudioPtr(long dataPtr,
int size,
int sampleRate,
int channels,
long pts)
输入自定义音频数据
|
void |
inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
输入自定义视频流
|
void |
inputStreamVideoPtr(long dataptr,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
输入自定义视频流
|
boolean |
isCameraSupportAutoFocus()
获取是否支持自动对焦
|
boolean |
isCameraSupportFlash()
获取是否支持闪光灯
|
boolean |
isNetworkPushing()
获取当前网络推流状态
|
boolean |
isPushing()
是否正在推流
|
void |
pause()
暂停推流
|
void |
pauseBGM()
暂停播放背景音乐
|
void |
pauseScreenCapture()
暂停录屏推流(隐私开)
|
void |
reconnectPushAsync(java.lang.String url)
重新连接进行推流
|
void |
removeDynamicsAddons(int id)
删除动态贴纸
|
void |
restartPush()
重新开始推流
|
void |
restartPushAync()
重新开始推流
|
void |
resume()
恢复推流
|
void |
resumeAsync()
异步恢复推流
|
void |
resumeBGM()
恢复播放背景音乐
|
void |
resumeScreenCapture()
恢复录屏推流(隐私关)
|
void |
sendMessage(java.lang.String info,
int repeat,
int delay,
boolean isKeyFrame)
推流端发送自定义消息
|
void |
setAudioDenoise(boolean on)
设置音频降噪
|
int |
setAudioEffectReverbMode(AlivcLivePushAudioEffectReverbMode mode)
设置混响音效模式
推流前和推流过程中调用都生效
|
int |
setAudioEffectVoiceChangeMode(AlivcLivePushAudioEffectVoiceChangeMode mode)
设置变声音效模式
推流前和推流过程中调用都生效
|
void |
setAutoFocus(boolean autoFocus)
设置自动对焦
|
void |
setBGMEarsBack(boolean isOpen)
设置耳返开关
|
void |
setBGMLoop(boolean isLoop)
设置背景音乐是否循环播放
|
void |
setBGMVolume(int volume)
设置背景音乐混音 人声音量
|
void |
setCaptureVolume(int volume)
设置背景音乐混音 音乐音量
|
void |
setCustomAudioFilter(AlivcLivePushCustomAudioFilter customAudioFilter)
设置用户自定义音频处理回调
|
void |
setCustomDetect(AlivcLivePushCustomDetect customVideoDetect)
设置用户自定义视频人脸识别回调
|
void |
setCustomFilter(AlivcLivePushCustomFilter customVideoFilter)
设置用户自定义视频美颜回调
|
void |
setExposure(int exposure)
设置采集曝光
|
void |
setFlash(boolean flash)
是否打开闪光灯
|
int |
setLiveMixTranscodingConfig(AlivcLiveTranscodingConfig config)
设置云端的混流(转码)参数
一个直播间中可能有不止一位主播,而且每个主播都有自己的画面和声音,但对于 CDN 观众来说,他们只需要一路直播流
所以您需要将多路音视频流混成一路标准的直播流,这就需要混流转码
在连麦场景下,需要将主播和连麦观众音视频流混成一路标准的直播流,供CDN观众观看
在PK场景下,需要将进行PK的多个主播的音视频流混成一路标准的直播流,供CDN观众观看
|
void |
setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener)
设置背景播放通知事件
|
void |
setLivePusherReference(AlivcLivePusher livePusher)
设置直播推流实例
|
void |
setLivePushErrorListener(AlivcLivePushErrorListener errorListener)
设置推流错误事件
|
void |
setLivePushInfoListener(AlivcLivePushInfoListener infoListener)
设置推流通知事件
|
void |
setLivePushNetworkListener(AlivcLivePushNetworkListener networkListner)
设置网络通知事件
|
void |
setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
设置render的context监听
|
void |
setMinVideoBitrate(int minVideoBitrate)
设置最小视频码率[100,5000] (Kbps)
|
void |
setMute(boolean mute)
是否静音
|
void |
setPreviewMirror(boolean mirror)
预览镜像开关
|
void |
setPreviewMode(AlivcPreviewDisplayMode mode)
设置预览显示模式
|
void |
setPreviewOrientation(AlivcPreviewOrientationEnum orientation)
设置推流方向,默认竖屏
|
void |
setPushMirror(boolean mirror)
推流端是否水平镜像
|
void |
setQualityMode(AlivcQualityModeEnum mode)
设置视频质量模式
|
void |
setScreenOrientation(int orientation)
录屏模式下,设置感应的屏幕旋转角度
|
void |
setTargetVideoBitrate(int targetVideoBitrate)
设置目标视频码率[100,5000](Kbps)
|
void |
setWatermarkVisible(boolean visible)
设置水印可见
|
void |
setZoom(int zoom)
设置缩放[0,getMaxZoom()]
|
void |
snapshot(int count,
int interval,
AlivcSnapshotListener listener)
视频流截图
|
void |
startBGMAsync(java.lang.String path)
播放背景音
|
int |
startCamera(android.view.SurfaceView surfaceView)
录屏模式下,开启摄像头预览
如果不需要预览,则surfaceview填为null
|
int |
startCameraMix(float x,
float y,
float w,
float h)
录屏模式下,开启摄像头混流
|
int |
startIntelligentDenoise()
开启音频智能降噪
1、使用智能降噪,请关闭普通降噪;两者功能互斥使用
2、智能降噪功能以插件形式提供,调用该接口前,请确保已集成了libpluginAliDenoise.so;插件获取方式请参考官网文档;
3、此接口可以通话过程中控制打开智能降噪功能,通话过程中可以支持开启和关闭智能降噪
4、默认关闭,开启后可能导致功耗增加,智能降噪适合于会议,教育等语音通讯为主的场景,不适合有背景音乐的场景
注意事项!!!
|
void |
startPreview(android.content.Context context,
android.widget.FrameLayout frameLayout,
boolean isAnchor)
开始预览
|
void |
startPreview(android.view.SurfaceView surfaceView)
开始预览
|
void |
startPreviewAysnc(android.view.SurfaceView surfaceView)
异步开始预览
|
void |
startPush(java.lang.String url)
开始推流
|
void |
startPushAysnc(java.lang.String url)
开始推流
|
void |
stopBGMAsync()
停止播放背景音乐
|
void |
stopCamera()
录屏模式下,关闭摄像头预览
|
void |
stopCameraMix()
录屏模式下,停止摄像头混流
|
int |
stopIntelligentDenoise()
关闭音频智能降噪
此接口可以通话过程中控制关闭智能降噪功能
|
void |
stopPreview()
结束预览
|
void |
stopPush()
结束推流
|
void |
switchCamera()
切换摄像头
|
void init(android.content.Context context, AlivcLivePushConfig config) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- 上下文config
- 配置java.lang.IllegalArgumentException
- 如果 config为空,或者config的值为无效(例如码率的值超过范围)java.lang.IllegalStateException
- 如果状态不对,例如已经初始化,但是还没有销毁void destroy() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化void setLivePusherReference(AlivcLivePusher livePusher)
livePusher
- 推流实例void startPreview(android.view.SurfaceView surfaceView) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
surfaceView
- surfaceviewjava.lang.IllegalArgumentException
- 如果surfaceView为空,或者surfaceView的surface未创建/已销毁java.lang.IllegalStateException
- 如果状态不对,例如还未初始化void startPreviewAysnc(android.view.SurfaceView surfaceView) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
surfaceView
- surfaceviewjava.lang.IllegalArgumentException
- 如果surfaceView为空,或者surfaceView的surface未创建/已销毁java.lang.IllegalStateException
- 如果状态不对,例如还未初始化void startPreview(android.content.Context context, android.widget.FrameLayout frameLayout, boolean isAnchor) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- frameLayout
- isAnchor
- java.lang.IllegalArgumentException
java.lang.IllegalStateException
void stopPreview() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid startPush(java.lang.String url) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
url
- 推流Urljava.lang.IllegalArgumentException
- 如果url为空,或者不是有效的url格式java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid startPushAysnc(java.lang.String url) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
url
- 推流Urljava.lang.IllegalArgumentException
- 如果url为空,或者不是有效的url格式java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid restartPush() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPushvoid restartPushAync() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPushvoid reconnectPushAsync(java.lang.String url) throws java.lang.IllegalStateException
IllegalStateException,例如还未初始化/未startPreview/未startPush/已经stopPush
java.lang.IllegalStateException
void stopPush() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPushvoid pause() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/已经pausevoid resume() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resumevoid resumeAsync() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resumevoid switchCamera() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid setAutoFocus(boolean autoFocus) throws java.lang.IllegalStateException
autoFocus
- 自动聚焦java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid focusCameraAtAdjustedPoint(float x, float y, boolean autoFocus) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
x
- 对焦的点x坐标y
- 对焦的点y坐标yautoFocus
- 是否自动聚焦java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewjava.lang.IllegalArgumentException
void setZoom(int zoom) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
zoom
- 0~getMaxZoom()java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewjava.lang.IllegalArgumentException
int getMaxZoom() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewint getCurrentZoom() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid setMute(boolean mute) throws java.lang.IllegalStateException
mute
- true:静音推流 false:正常推流java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPushvoid setFlash(boolean flash) throws java.lang.IllegalStateException
flash
- true:打开闪光灯 false:关闭闪光灯java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid setPushMirror(boolean mirror) throws java.lang.IllegalStateException
mirror
- true:打开推流镜像 false:关闭推流镜像java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPushvoid setPreviewMirror(boolean mirror) throws java.lang.IllegalStateException
mirror
- true:打开预览镜像 false:关闭预览镜像java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreviewvoid setTargetVideoBitrate(int targetVideoBitrate) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
targetVideoBitrate
- 目标视频编码码率java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPushjava.lang.IllegalArgumentException
void setMinVideoBitrate(int minVideoBitrate) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
minVideoBitrate
- 最小视频编码码率java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPushjava.lang.IllegalArgumentException
boolean isCameraSupportAutoFocus()
boolean isCameraSupportFlash()
boolean isPushing() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPushboolean isNetworkPushing() throws java.lang.IllegalStateException
java.lang.IllegalStateException
void setCustomDetect(AlivcLivePushCustomDetect customVideoDetect)
customVideoDetect
- 回调接口void setCustomFilter(AlivcLivePushCustomFilter customVideoFilter)
customVideoFilter
- 回调接口void setCustomAudioFilter(AlivcLivePushCustomAudioFilter customAudioFilter)
customAudioFilter
- 回调接口AlivcLivePushStats getCurrentStatus()
void setLivePushErrorListener(AlivcLivePushErrorListener errorListener)
errorListener
- 错误监听器void setLivePushInfoListener(AlivcLivePushInfoListener infoListener)
infoListener
- 通知监听器void setLivePushNetworkListener(AlivcLivePushNetworkListener networkListner)
networkListner
- 通知监听器void setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener)
pushBGMListener
- 通知监听器void setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
renderCtxListener
- render的context监听AlivcLivePushStatsInfo getLivePushStatsInfo() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化java.lang.String getPushUrl()
void setPreviewOrientation(AlivcPreviewOrientationEnum orientation)
orientation
- 推流方向int setAudioEffectVoiceChangeMode(AlivcLivePushAudioEffectVoiceChangeMode mode)
推流前和推流过程中调用都生效
mode
- 变声音效模式变声音效模式枚举
int setAudioEffectReverbMode(AlivcLivePushAudioEffectReverbMode mode)
推流前和推流过程中调用都生效
mode
- 混响音效模式混响音效模式枚举
void startBGMAsync(java.lang.String path) throws java.lang.IllegalStateException
path
- 背景音乐路径java.lang.IllegalStateException
void stopBGMAsync() throws java.lang.IllegalStateException
java.lang.IllegalStateException
void pauseBGM() throws java.lang.IllegalStateException
java.lang.IllegalStateException
void resumeBGM() throws java.lang.IllegalStateException
java.lang.IllegalStateException
void setBGMLoop(boolean isLoop) throws java.lang.IllegalStateException
isLoop
- 是否循环 true:循环 false:不循环java.lang.IllegalStateException
void setBGMEarsBack(boolean isOpen) throws java.lang.IllegalStateException
isOpen
- 是否循环 true:开启耳返 false:关闭耳返java.lang.IllegalStateException
void setBGMVolume(int volume) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
volume
- 人声音量大小 范围:[0 ~ 100] 默认:50IllegalStateException,IllegalArgumentException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
void setCaptureVolume(int volume) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
volume
- 音乐音量大小 范围:[0 ~ 100] 默认:50IllegalStateException,IllegalArgumentException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
void setAudioDenoise(boolean on)
on
- true:开启 false:关闭int startIntelligentDenoise()
1、使用智能降噪,请关闭普通降噪;两者功能互斥使用 2、智能降噪功能以插件形式提供,调用该接口前,请确保已集成了libpluginAliDenoise.so;插件获取方式请参考官网文档; 3、此接口可以通话过程中控制打开智能降噪功能,通话过程中可以支持开启和关闭智能降噪 4、默认关闭,开启后可能导致功耗增加,智能降噪适合于会议,教育等语音通讯为主的场景,不适合有背景音乐的场景
注意事项!!! 如遇libMNN相关的so冲突,请检查当前工程中是否使用到了视频云的其它产品,如美颜SDK/Animoji SDK 美颜SDK/Animoji SDK中,包含libMNN相关的so,因此外部无需再导入一份,只保留libpluginAliDenoise.so, 全局MNN相关的库,统一留一份即可; 具体请查看官网文档或API文档,或者您可以咨询技术同学协助解决问题;
int stopIntelligentDenoise()
此接口可以通话过程中控制关闭智能降噪功能
void setQualityMode(AlivcQualityModeEnum mode) throws java.lang.IllegalStateException
mode
- java.lang.IllegalStateException
void setPreviewMode(AlivcPreviewDisplayMode mode) throws java.lang.IllegalStateException
mode
- java.lang.IllegalStateException
void pauseScreenCapture() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/已经pausevoid resumeScreenCapture() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resumeAlivcLivePushError getLastError()
void changeResolution(AlivcResolutionEnum resolutionEnum)
void addWaterMark(java.lang.String path, float x, float y, float width)
path
- 水印图片x
- 水印左上角x轴位置 相对位置 0~1y
- 水印右上角y轴位置 相对位置 0~1width
- 水印显示宽度 相对位置 0~1void setWatermarkVisible(boolean visible)
visible
- 是否可见int startCamera(android.view.SurfaceView surfaceView) throws java.lang.IllegalStateException
surfaceView
- java.lang.IllegalStateException
void stopCamera()
void setScreenOrientation(int orientation)
orientation
- int startCameraMix(float x, float y, float w, float h)
x
- 混流显示x初始位置(0~1.0f)y
- 混流显示y初始位置(0~1.0f)w
- 混流显示宽度(0~1.0f)h
- 混流显示高度(0~1.0f)void stopCameraMix()
void snapshot(int count, int interval, AlivcSnapshotListener listener)
count
- 截取图片的个数,该参数仅在普通模式下生效!!!interval
- 每张图片的间隔,该参数仅在普通模式下生效!!!listener
- 截图回调void inputStreamVideoPtr(long dataptr, int width, int height, int stride, int size, long pts, int rotation)
dataptr
- native内存指针width
- 视频图像宽度height
- 视频图像高度size
- 视频图像sizepts
- 视频图像pts(us)rotation
- 视频图像旋转角度void inputStreamVideoData(byte[] data, int width, int height, int stride, int size, long pts, int rotation)
data
- 视频图像byte arraywidth
- 视频图像宽度height
- 视频图像高度size
- 视频图像sizepts
- 视频图像pts(us)rotation
- 视频图像旋转角度void inputStreamAudioPtr(long dataPtr, int size, int sampleRate, int channels, long pts)
dataPtr
- 音频数据native内存指针size
- pts
- 音频数据pts(US)void inputStreamAudioData(byte[] data, int size, int sampleRate, int channels, long pts)
data
- 音频数据 byte arraysize
- pts
- 音频数据pts(US)int addDynamicsAddons(java.lang.String path, float x, float y, float w, float h)
path
- 贴纸路径,带config.jsonx
- 显示起始x位置(0~1.0f)y
- 显示起始y位置(0~1.0f)w
- 显示宽度(0~1.0f)h
- 显示高度(0~1.0f)void removeDynamicsAddons(int id)
id
- 贴纸idvoid setExposure(int exposure)
int getCurrentExposure()
int getSupportedMinExposure()
int getSupportedMaxExposure()
void sendMessage(java.lang.String info, int repeat, int delay, boolean isKeyFrame)
info
- 需要插入流的SEI消息体,建议是json格式repeat
- 发送的帧数delay
- 延时多少毫秒发送isKeyFrame
- 是否只发送关键帧int setLiveMixTranscodingConfig(AlivcLiveTranscodingConfig config)
config
- 参考AlivcLiveDef.h中关于AlivcLiveTranscodingConfig的介绍,如果传入nil,则取消云端混流转码java.lang.String getLiveTraceId()