AliVCSDK  4.5.1
阿里云音视频SDK,为视频开发者提供一站式接入服务
com.alivc.live.pusher.AlivcLivePusher类 参考

推流接口类 更多...

类 com.alivc.live.pusher.AlivcLivePusher 继承关系图:

Public 成员函数

void init (Context context, AlivcLivePushConfig config) throws IllegalArgumentException, IllegalStateException
 
void destroy () throws IllegalStateException
 
void setLivePusherReference (AlivcLivePusher livePusher)
 
void startPreview (SurfaceView surfaceView) throws IllegalArgumentException, IllegalStateException
 
void startPreviewAsync (SurfaceView surfaceView) throws IllegalArgumentException, IllegalStateException
 
void startPreview (Context context, FrameLayout frameLayout, boolean isAnchor) throws IllegalArgumentException, IllegalStateException
 
void stopPreview () throws IllegalStateException
 
void startPush (String url) throws IllegalArgumentException, IllegalStateException
 
void startPushAsync (String url) throws IllegalArgumentException, IllegalStateException
 
void restartPush () throws IllegalStateException
 
void restartPushAsync () throws IllegalStateException
 
void reconnectPushAsync (String url) throws IllegalStateException
 
void stopPush () throws IllegalStateException
 
void pause () throws IllegalStateException
 
void resume () throws IllegalStateException
 
void resumeAsync () throws IllegalStateException
 
void switchCamera () throws IllegalStateException
 
void setAutoFocus (boolean autoFocus) throws IllegalStateException
 
void focusCameraAtAdjustedPoint (float x, float y, boolean autoFocus) throws IllegalArgumentException, IllegalStateException
 
void setZoom (int zoom) throws IllegalArgumentException, IllegalStateException
 
int getMaxZoom () throws IllegalStateException
 
int getCurrentZoom () throws IllegalStateException
 
void setMute (boolean mute) throws IllegalStateException
 
void setFlash (boolean flash) throws IllegalStateException
 
void setPushMirror (boolean mirror) throws IllegalStateException
 
void setPreviewMirror (boolean mirror) throws IllegalStateException
 
void setTargetVideoBitrate (int targetVideoBitrate) throws IllegalArgumentException, IllegalStateException
 
void setMinVideoBitrate (int minVideoBitrate) throws IllegalArgumentException, IllegalStateException
 
boolean isCameraSupportAutoFocus ()
 
boolean isCameraSupportFlash ()
 
boolean isPushing () throws IllegalStateException
 
boolean isNetworkPushing () throws IllegalStateException
 
void setCustomDetect (AlivcLivePushCustomDetect customVideoDetect)
 
void setCustomFilter (AlivcLivePushCustomFilter customVideoFilter)
 
void setCustomAudioFilter (AlivcLivePushCustomAudioFilter customAudioFilter)
 
AlivcLivePushStats getCurrentStatus ()
 
void setLivePushErrorListener (AlivcLivePushErrorListener errorListener)
 
void setLivePushInfoListener (AlivcLivePushInfoListener infoListener)
 
void setLivePushNetworkListener (AlivcLivePushNetworkListener networkListener)
 
void setLivePushBGMListener (AlivcLivePushBGMListener pushBGMListener)
 
void setLivePushRenderContextListener (AlivcLivePusherRenderContextListener renderCtxListener)
 
AlivcLivePushStatsInfo getLivePushStatsInfo () throws IllegalStateException
 
String getPushUrl ()
 
void setPreviewOrientation (AlivcPreviewOrientationEnum orientation)
 
int setAudioEffectVoiceChangeMode (AlivcLivePushAudioEffectVoiceChangeMode mode)
 
int setAudioEffectReverbMode (AlivcLivePushAudioEffectReverbMode mode)
 
void startBGMAsync (String path) throws IllegalStateException
 
void stopBGMAsync () throws IllegalStateException
 
void pauseBGM () throws IllegalStateException
 
void resumeBGM () throws IllegalStateException
 
void setBGMLoop (boolean isLoop) throws IllegalStateException
 
void setBGMEarsBack (boolean isOpen) throws IllegalStateException
 
void setBGMVolume (int volume) throws IllegalStateException, IllegalArgumentException
 
void setCaptureVolume (int volume) throws IllegalStateException, IllegalArgumentException
 
void setAudioDenoise (boolean on)
 
int startIntelligentDenoise ()
 
int stopIntelligentDenoise ()
 
void setQualityMode (AlivcQualityModeEnum mode) throws IllegalStateException
 
void setPreviewMode (AlivcPreviewDisplayMode mode) throws IllegalStateException
 
void pauseScreenCapture () throws IllegalStateException
 
void resumeScreenCapture () throws IllegalStateException
 
AlivcLivePushError getLastError ()
 
void changeResolution (AlivcResolutionEnum resolution)
 
void addWaterMark (String path, float x, float y, float width)
 
void setWatermarkVisible (boolean visible)
 
int startCamera (SurfaceView surfaceView) throws IllegalStateException
 
void stopCamera ()
 
void setScreenOrientation (int orientation)
 
int startCameraMix (float x, float y, float w, float h)
 
void stopCameraMix ()
 
void snapshot (int count, int interval, AlivcSnapshotListener listener)
 
void inputStreamVideoPtr (long dataPtr, int width, int height, int stride, int size, long pts, int rotation)
 
void inputStreamVideoData (byte[] data, int width, int height, int stride, int size, long pts, int rotation)
 
void inputStreamAudioPtr (long dataPtr, int size, int sampleRate, int channels, long pts)
 
void inputStreamAudioData (byte[] data, int size, int sampleRate, int channels, long pts)
 
int addDynamicsAddons (String path, float x, float y, float w, float h)
 
void removeDynamicsAddons (int id)
 
void setExposure (int exposure)
 
int getCurrentExposure ()
 
int getSupportedMinExposure ()
 
int getSupportedMaxExposure ()
 
void sendMessage (String info, int repeat, int delay, boolean isKeyFrame)
 
int setLiveMixTranscodingConfig (AlivcLiveTranscodingConfig config)
 
int muteLocalCamera (boolean mute)
 
int enableSpeakerphone (boolean enable)
 
boolean isSpeakerphoneOn ()
 
String getLiveTraceId ()
 

详细描述

成员函数说明

int com.alivc.live.pusher.AlivcLivePusher.addDynamicsAddons ( String  path,
float  x,
float  y,
float  w,
float  h 
)

添加动态贴纸

参数
path贴纸路径,带config.json
x显示起始x位置(0~1.0f)
y显示起始y位置(0~1.0f)
w显示宽度(0~1.0f)
h显示高度(0~1.0f)
返回
id 贴纸id

在文件 AlivcLivePusher.java1142 行定义.

void com.alivc.live.pusher.AlivcLivePusher.addWaterMark ( String  path,
float  x,
float  y,
float  width 
)

添加水印,起点位置坐标x[0,width) y[0,height) 宽度(0,width],最多添加3个

参数
path水印图片
x水印左上角x轴位置 相对位置 0~1
y水印右上角y轴位置 相对位置 0~1
width水印显示宽度 相对位置 0~1
注解
需在startPreview之后调用

在文件 AlivcLivePusher.java950 行定义.

void com.alivc.live.pusher.AlivcLivePusher.changeResolution ( AlivcResolutionEnum  resolution)

动态调整分辨率

参数
resolution分辨率

在文件 AlivcLivePusher.java933 行定义.

void com.alivc.live.pusher.AlivcLivePusher.destroy ( ) throws IllegalStateException

释放推流

异常
IllegalStateException如果状态不对,例如还未初始化

在文件 AlivcLivePusher.java84 行定义.

int com.alivc.live.pusher.AlivcLivePusher.enableSpeakerphone ( boolean  enable)

设置音频输出为听筒还是扬声器

参数
enabletrue:扬声器模式(默认扬声器);false:听筒模式
返回
0 -> 成功,<0 -> 失败
注解
普通模式暂不支持该API,调用无任何效果

在文件 AlivcLivePusher.java1278 行定义.

void com.alivc.live.pusher.AlivcLivePusher.focusCameraAtAdjustedPoint ( float  x,
float  y,
boolean  autoFocus 
) throws IllegalArgumentException, IllegalStateException

对焦,对焦点的坐标x[0,屏幕宽度],y[0,屏幕宽度]

参数
x对焦的点x坐标
y对焦的点y坐标y
autoFocus是否自动聚焦
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java323 行定义.

int com.alivc.live.pusher.AlivcLivePusher.getCurrentExposure ( )

获取当前采集曝光

返回
当前采集曝光

在文件 AlivcLivePusher.java1181 行定义.

AlivcLivePushStats com.alivc.live.pusher.AlivcLivePusher.getCurrentStatus ( )

获取当前状态

返回
当前状态

在文件 AlivcLivePusher.java555 行定义.

int com.alivc.live.pusher.AlivcLivePusher.getCurrentZoom ( ) throws IllegalStateException

获取当前缩放值

返回
当前缩放值
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java365 行定义.

AlivcLivePushError com.alivc.live.pusher.AlivcLivePusher.getLastError ( )

获取最近的错误值

返回
错误

在文件 AlivcLivePusher.java920 行定义.

AlivcLivePushStatsInfo com.alivc.live.pusher.AlivcLivePusher.getLivePushStatsInfo ( ) throws IllegalStateException

获取推流统计数据

返回
推流统计数据
异常
IllegalStateException如果状态不对,例如还未初始化

在文件 AlivcLivePusher.java634 行定义.

String com.alivc.live.pusher.AlivcLivePusher.getLiveTraceId ( )

获取直播trace id

返回
trace id
注解
互动模式暂不支持该API,调用返回空字符串

在文件 AlivcLivePusher.java1306 行定义.

int com.alivc.live.pusher.AlivcLivePusher.getMaxZoom ( ) throws IllegalStateException

获取摄像头支持的最大缩放值

返回
最大zoom值
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java351 行定义.

String com.alivc.live.pusher.AlivcLivePusher.getPushUrl ( )

获取推流URL

返回
推流URL

在文件 AlivcLivePusher.java647 行定义.

int com.alivc.live.pusher.AlivcLivePusher.getSupportedMaxExposure ( )

获取采集支持最大曝光

返回
采集支持最大曝光

在文件 AlivcLivePusher.java1207 行定义.

int com.alivc.live.pusher.AlivcLivePusher.getSupportedMinExposure ( )

获取采集支持最小曝光

返回
采集支持最小曝光

在文件 AlivcLivePusher.java1194 行定义.

void com.alivc.live.pusher.AlivcLivePusher.init ( Context  context,
AlivcLivePushConfig  config 
) throws IllegalArgumentException, IllegalStateException

初始化推流参数

参数
context上下文
config配置
异常
IllegalArgumentException如果 config为空,或者config的值为无效(例如码率的值超过范围)
IllegalStateException如果状态不对,例如已经初始化,但是还没有销毁

在文件 AlivcLivePusher.java46 行定义.

void com.alivc.live.pusher.AlivcLivePusher.inputStreamAudioData ( byte[]  data,
int  size,
int  sampleRate,
int  channels,
long  pts 
)

输入自定义音频数据

参数
data音频数据 byte array
size音频数据大小
sampleRate音频比特率
channels音频通道数
pts音频数据pts(US)
注解
调用前需要通配置AlivcLivePushConfig::setExternMainStream开启外置自定义输入流才会起作用
参见
com.alivc.live.pusher.AlivcLivePushConfig::setExternMainStream(boolean, com.alivc.live.pusher.AlivcImageFormat, com.alivc.live.pusher.AlivcSoundFormat)

在文件 AlivcLivePusher.java1124 行定义.

void com.alivc.live.pusher.AlivcLivePusher.inputStreamAudioPtr ( long  dataPtr,
int  size,
int  sampleRate,
int  channels,
long  pts 
)

输入自定义音频数据

参数
dataPtr音频数据native内存指针
size音频数据大小
sampleRate音频比特率
channels音频通道数
pts音频数据pts(US)
注解
调用前需要通配置AlivcLivePushConfig::setExternMainStream开启外置自定义输入流才会起作用
参见
com.alivc.live.pusher.AlivcLivePushConfig::setExternMainStream(boolean, com.alivc.live.pusher.AlivcImageFormat, com.alivc.live.pusher.AlivcSoundFormat)

在文件 AlivcLivePusher.java1105 行定义.

void com.alivc.live.pusher.AlivcLivePusher.inputStreamVideoData ( byte[]  data,
int  width,
int  height,
int  stride,
int  size,
long  pts,
int  rotation 
)

输入自定义视频流

参数
data视频图像byte array
width视频图像宽度
height视频图像高度
stride视频图像stride
size视频图像size
pts视频图像pts(us)
rotation视频图像旋转角度
注解
Before calling, it is necessary to configure AlivcLivePushConfig::setExternMainStream to enable an external custom input stream before it can take effect
参见
com.alivc.live.pusher.AlivcLivePushConfig::setExternMainStream(boolean, com.alivc.live.pusher.AlivcImageFormat, com.alivc.live.pusher.AlivcSoundFormat)

在文件 AlivcLivePusher.java1086 行定义.

void com.alivc.live.pusher.AlivcLivePusher.inputStreamVideoPtr ( long  dataPtr,
int  width,
int  height,
int  stride,
int  size,
long  pts,
int  rotation 
)

输入自定义视频流

参数
dataPtrnative内存指针
width视频图像宽度
height视频图像高度
stride视频图像高度
size视频图像size
pts视频图像pts(us)
rotation视频图像旋转角度
注解
调用前需要通配置AlivcLivePushConfig::setExternMainStream开启外置自定义输入流才会起作用

在文件 AlivcLivePusher.java1065 行定义.

boolean com.alivc.live.pusher.AlivcLivePusher.isCameraSupportAutoFocus ( )

获取是否支持自动对焦

返回
是否支持自动对焦

在文件 AlivcLivePusher.java462 行定义.

boolean com.alivc.live.pusher.AlivcLivePusher.isCameraSupportFlash ( )

获取是否支持闪光灯

返回
是否支持闪光灯

在文件 AlivcLivePusher.java475 行定义.

boolean com.alivc.live.pusher.AlivcLivePusher.isNetworkPushing ( ) throws IllegalStateException

获取当前网络推流状态

返回
当前网络推流状态
异常
IllegalStateException

在文件 AlivcLivePusher.java503 行定义.

boolean com.alivc.live.pusher.AlivcLivePusher.isPushing ( ) throws IllegalStateException

是否正在推流

返回
true:正在推流 false:未推流
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush

在文件 AlivcLivePusher.java489 行定义.

boolean com.alivc.live.pusher.AlivcLivePusher.isSpeakerphoneOn ( )

获取当前音频输出为听筒还是扬声器

返回
true->扬声器模式,false->听筒模式
注解
普通模式暂不支持该API,调用无任何效果

在文件 AlivcLivePusher.java1292 行定义.

int com.alivc.live.pusher.AlivcLivePusher.muteLocalCamera ( boolean  mute)

关闭/打开摄像头

参数
mutetrue表示不发送视频数据,false表示恢复正常
返回
0->成功,非0->失败
注解
在发送端调用,作用于订阅端
如果当前已设置AlivcLivePushConfig::setPausePushImage,采集预览正常,对端显示静态图片;
如果当前未设置AlivcLivePushConfig::setPausePushImage,采集预览正常,对端会黑屏;
普通模式暂不支持该API,调用无任何效果

在文件 AlivcLivePusher.java1263 行定义.

void com.alivc.live.pusher.AlivcLivePusher.pause ( ) throws IllegalStateException

暂停推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/已经pause

在文件 AlivcLivePusher.java254 行定义.

void com.alivc.live.pusher.AlivcLivePusher.pauseBGM ( ) throws IllegalStateException

暂停播放背景音乐

异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java732 行定义.

void com.alivc.live.pusher.AlivcLivePusher.pauseScreenCapture ( ) throws IllegalStateException

暂停录屏推流(隐私开)

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/已经pause

在文件 AlivcLivePusher.java894 行定义.

void com.alivc.live.pusher.AlivcLivePusher.reconnectPushAsync ( String  url) throws IllegalStateException

重新连接进行推流

参数
url推流URL
异常
IllegalStateException例如还未初始化/未startPreview/未startPush/已经stopPush

在文件 AlivcLivePusher.java228 行定义.

void com.alivc.live.pusher.AlivcLivePusher.removeDynamicsAddons ( int  id)

删除动态贴纸

参数
id贴纸id

在文件 AlivcLivePusher.java1155 行定义.

void com.alivc.live.pusher.AlivcLivePusher.restartPush ( ) throws IllegalStateException

重新开始推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPush

在文件 AlivcLivePusher.java201 行定义.

void com.alivc.live.pusher.AlivcLivePusher.restartPushAsync ( ) throws IllegalStateException

重新开始推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPush

在文件 AlivcLivePusher.java214 行定义.

void com.alivc.live.pusher.AlivcLivePusher.resume ( ) throws IllegalStateException

恢复推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resume

在文件 AlivcLivePusher.java267 行定义.

void com.alivc.live.pusher.AlivcLivePusher.resumeAsync ( ) throws IllegalStateException

异步恢复推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resume

在文件 AlivcLivePusher.java280 行定义.

void com.alivc.live.pusher.AlivcLivePusher.resumeBGM ( ) throws IllegalStateException

恢复播放背景音乐

异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java745 行定义.

void com.alivc.live.pusher.AlivcLivePusher.resumeScreenCapture ( ) throws IllegalStateException

恢复录屏推流(隐私关)

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/未pause/已resume

在文件 AlivcLivePusher.java907 行定义.

void com.alivc.live.pusher.AlivcLivePusher.sendMessage ( String  info,
int  repeat,
int  delay,
boolean  isKeyFrame 
)

推流端发送自定义消息

参数
info需要插入流的SEI消息体,建议是json格式
repeat发送的帧数
delay延时多少毫秒发送
isKeyFrame是否只发送关键帧

在文件 AlivcLivePusher.java1223 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setAudioDenoise ( boolean  on)

设置音频降噪

参数
ontrue:开启 false:关闭

在文件 AlivcLivePusher.java816 行定义.

int com.alivc.live.pusher.AlivcLivePusher.setAudioEffectReverbMode ( AlivcLivePushAudioEffectReverbMode  mode)

设置混响音效模式

参数
mode混响音效模式
返回
0->成功, 非0->失败
注解
推流前和推流过程中调用都生效
参见
AlivcLivePushAudioEffectReverbMode

在文件 AlivcLivePusher.java692 行定义.

int com.alivc.live.pusher.AlivcLivePusher.setAudioEffectVoiceChangeMode ( AlivcLivePushAudioEffectVoiceChangeMode  mode)

设置变声音效模式

参数
mode变声音效模式
返回
0->成功, 非0->失败
注解
推流前和推流过程中调用都生效
参见
AlivcLivePushAudioEffectVoiceChangeMode

在文件 AlivcLivePusher.java676 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setAutoFocus ( boolean  autoFocus) throws IllegalStateException

设置自动对焦

参数
autoFocus自动聚焦
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java307 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setBGMEarsBack ( boolean  isOpen) throws IllegalStateException

设置耳返开关

参数
isOpen是否开启
异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java773 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setBGMLoop ( boolean  isLoop) throws IllegalStateException

设置背景音乐是否循环播放

参数
isLoop是否循环
异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java759 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setBGMVolume ( int  volume) throws IllegalStateException, IllegalArgumentException

设置背景音乐音量

参数
volume背景音乐音量 范围:[0 ~ 100] 默认:50
异常
IllegalStateException状态错误
IllegalArgumentException参数错误

在文件 AlivcLivePusher.java788 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setCaptureVolume ( int  volume) throws IllegalStateException, IllegalArgumentException

设置人声音量

参数
volume人声音量 范围:[0 ~ 100] 默认:50
异常
IllegalStateException状态错误
IllegalArgumentException参数错误

在文件 AlivcLivePusher.java803 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setCustomAudioFilter ( AlivcLivePushCustomAudioFilter  customAudioFilter)

设置用户自定义音频处理回调

参数
customAudioFilter回调接口

在文件 AlivcLivePusher.java542 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setCustomDetect ( AlivcLivePushCustomDetect  customVideoDetect)

设置用户自定义视频人脸识别回调

参数
customVideoDetect回调接口

在文件 AlivcLivePusher.java516 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setCustomFilter ( AlivcLivePushCustomFilter  customVideoFilter)

设置用户自定义视频美颜回调

参数
customVideoFilter回调接口

在文件 AlivcLivePusher.java529 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setExposure ( int  exposure)

设置采集曝光

参数
exposure采集曝光

在文件 AlivcLivePusher.java1168 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setFlash ( boolean  flash) throws IllegalStateException

是否打开闪光灯

参数
flashtrue:打开闪光灯 false:关闭闪光灯
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java393 行定义.

int com.alivc.live.pusher.AlivcLivePusher.setLiveMixTranscodingConfig ( AlivcLiveTranscodingConfig  config)

设置云端的混流转码参数

参数
config云端混流转码参数
返回
0->成功,非0->失败
注解
普通模式暂不支持该API,调用无任何效果
一个直播间中可能有不止一位主播,而且每个主播都有自己的画面和声音,但对于 CDN 观众来说,他们只需要一路直播流
所以您需要将多路音视频流混成一路标准的直播流,这就需要混流转码
在连麦场景下,需要将主播和连麦观众音视频流混成一路标准的直播流,供CDN观众观看
在PK场景下,需要将进行PK的多个主播的音视频流混成一路标准的直播流,供CDN观众观看
若主播还在房间中但不再需要混流,请务必传入 null 进行取消,因为当发起混流后,云端混流模块就会开始工作,不及时取消混流可能会引起不必要的计费损失
参见
com.alivc.live.pusher.AlivcLiveTranscodingConfig
com.alivc.live.pusher.AlivcLivePushInfoListener::onSetLiveMixTranscodingConfig(com.alivc.live.pusher.AlivcLivePusher, boolean, String)

在文件 AlivcLivePusher.java1245 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePushBGMListener ( AlivcLivePushBGMListener  pushBGMListener)

设置背景播放通知事件

参数
pushBGMListener通知监听器

在文件 AlivcLivePusher.java607 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePusherReference ( AlivcLivePusher  livePusher)

设置直播推流实例

参数
livePusher推流实例

在文件 AlivcLivePusher.java97 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePushErrorListener ( AlivcLivePushErrorListener  errorListener)

设置推流错误事件

参数
errorListener错误监听器

在文件 AlivcLivePusher.java568 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePushInfoListener ( AlivcLivePushInfoListener  infoListener)

设置推流通知事件

参数
infoListener通知监听器

在文件 AlivcLivePusher.java581 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePushNetworkListener ( AlivcLivePushNetworkListener  networkListener)

设置网络通知事件

参数
networkListener通知监听器

在文件 AlivcLivePusher.java594 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setLivePushRenderContextListener ( AlivcLivePusherRenderContextListener  renderCtxListener)

设置render的context监听

参数
renderCtxListenerrender的context监听

在文件 AlivcLivePusher.java620 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setMinVideoBitrate ( int  minVideoBitrate) throws IllegalArgumentException, IllegalStateException

设置最小视频码率(Kbps)

参数
minVideoBitrate最小视频编码码率
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush

在文件 AlivcLivePusher.java449 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setMute ( boolean  mute) throws IllegalStateException

是否静音

参数
mutetrue:静音推流 false:正常推流
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush

在文件 AlivcLivePusher.java379 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setPreviewMirror ( boolean  mirror) throws IllegalStateException

预览镜像开关

参数
mirrortrue:打开预览镜像 false:关闭预览镜像
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java421 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setPreviewMode ( AlivcPreviewDisplayMode  mode) throws IllegalStateException

设置预览显示模式

参数
mode预览显示模式
异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java881 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setPreviewOrientation ( AlivcPreviewOrientationEnum  orientation)

设置预览方向,默认竖屏

参数
orientation推流方向

在文件 AlivcLivePusher.java660 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setPushMirror ( boolean  mirror) throws IllegalStateException

推流端是否水平镜像

参数
mirrortrue:打开推流镜像 false:关闭推流镜像
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush

在文件 AlivcLivePusher.java407 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setQualityMode ( AlivcQualityModeEnum  mode) throws IllegalStateException

设置视频质量模式

参数
mode视频质量模式
异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java867 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setScreenOrientation ( int  orientation)

录屏模式下,设置感应的屏幕旋转角度

参数
orientation屏幕旋转角度

在文件 AlivcLivePusher.java1002 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setTargetVideoBitrate ( int  targetVideoBitrate) throws IllegalArgumentException, IllegalStateException

设置目标视频码率[100,5000](Kbps)

参数
targetVideoBitrate目标视频编码码率
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush

在文件 AlivcLivePusher.java435 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setWatermarkVisible ( boolean  visible)

设置水印可见

参数
visible是否可见

在文件 AlivcLivePusher.java963 行定义.

void com.alivc.live.pusher.AlivcLivePusher.setZoom ( int  zoom) throws IllegalArgumentException, IllegalStateException

设置缩放

参数
zoom0~getMaxZoom()
异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java337 行定义.

void com.alivc.live.pusher.AlivcLivePusher.snapshot ( int  count,
int  interval,
AlivcSnapshotListener  listener 
)

视频流截图

参数
count截取图片的个数,该参数仅在普通模式下生效
interval每张图片的间隔,该参数仅在普通模式下生效
listener截图回调

在文件 AlivcLivePusher.java1045 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startBGMAsync ( String  path) throws IllegalStateException

播放背景音

参数
path背景音乐路径
异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java706 行定义.

int com.alivc.live.pusher.AlivcLivePusher.startCamera ( SurfaceView  surfaceView) throws IllegalStateException

录屏模式下,开启摄像头预览 如果不需要预览,则surfaceView填为null

参数
surfaceViewsurfaceView
返回
0->成功, 非0->失败

在文件 AlivcLivePusher.java978 行定义.

int com.alivc.live.pusher.AlivcLivePusher.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)
返回
0->成功, 非0->失败

在文件 AlivcLivePusher.java1019 行定义.

int com.alivc.live.pusher.AlivcLivePusher.startIntelligentDenoise ( )

开启音频智能降噪

返回
0->成功, 非0->失败
注解
1、使用智能降噪,请关闭普通降噪;两者功能互斥使用
2、智能降噪功能以插件形式提供,调用该接口前,请确保已集成了libpluginAliDenoise.so;插件获取方式请参考官网文档;
3、此接口可以通话过程中控制打开智能降噪功能,通话过程中可以支持开启和关闭智能降噪
4、默认关闭,开启后可能导致功耗增加,智能降噪适合于会议,教育等语音通讯为主的场景,不适合有背景音乐的场景
注意事项
注解
如遇libMNN相关的so冲突,请检查当前工程中是否使用到了视频云的其它产品,如美颜SDK/Animoji SDK
美颜SDK/Animoji SDK中,包含libMNN相关的so,因此外部无需再导入一份,只保留libpluginAliDenoise.so,
全局MNN相关的库,统一留一份即可;
具体请查看官网文档或API文档,或者您可以咨询技术同学协助解决问题;
参见
推流SDK(新版)官网文档

在文件 AlivcLivePusher.java839 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startPreview ( SurfaceView  surfaceView) throws IllegalArgumentException, IllegalStateException

开始预览

参数
surfaceViewsurfaceView
异常
IllegalArgumentException如果surfaceView为空,或者surfaceView的surface未创建/已销毁
IllegalStateException如果状态不对,例如还未初始化

在文件 AlivcLivePusher.java112 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startPreview ( Context  context,
FrameLayout  frameLayout,
boolean  isAnchor 
) throws IllegalArgumentException, IllegalStateException

开始预览

参数
contextandroid context
frameLayoutFrameLayout Container
isAnchor是否主播
异常
IllegalArgumentException参数错误
IllegalStateException状态错误
注解
仅用于互动模式

在文件 AlivcLivePusher.java145 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startPreviewAsync ( SurfaceView  surfaceView) throws IllegalArgumentException, IllegalStateException

异步开始预览

参数
surfaceViewsurfaceView
异常
IllegalArgumentException如果surfaceView为空,或者surfaceView的surface未创建/已销毁
IllegalStateException如果状态不对,例如还未初始化

在文件 AlivcLivePusher.java127 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startPush ( String  url) throws IllegalArgumentException, IllegalStateException

开始推流

参数
url推流Url
异常
IllegalArgumentException如果url为空,或者不是有效的url格式
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java173 行定义.

void com.alivc.live.pusher.AlivcLivePusher.startPushAsync ( String  url) throws IllegalArgumentException, IllegalStateException

开始异步推流

参数
url推流Url
异常
IllegalArgumentException如果url为空,或者不是有效的url格式
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java188 行定义.

void com.alivc.live.pusher.AlivcLivePusher.stopBGMAsync ( ) throws IllegalStateException

停止播放背景音乐

异常
IllegalStateException状态错误

在文件 AlivcLivePusher.java719 行定义.

void com.alivc.live.pusher.AlivcLivePusher.stopCamera ( )

录屏模式下,关闭摄像头预览

在文件 AlivcLivePusher.java989 行定义.

void com.alivc.live.pusher.AlivcLivePusher.stopCameraMix ( )

录屏模式下,停止摄像头混流

在文件 AlivcLivePusher.java1030 行定义.

int com.alivc.live.pusher.AlivcLivePusher.stopIntelligentDenoise ( )

关闭音频智能降噪

返回
0->成功, 非0->失败
注解
此接口可以通话过程中控制关闭智能降噪功能

在文件 AlivcLivePusher.java853 行定义.

void com.alivc.live.pusher.AlivcLivePusher.stopPreview ( ) throws IllegalStateException

结束预览

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java158 行定义.

void com.alivc.live.pusher.AlivcLivePusher.stopPush ( ) throws IllegalStateException

结束推流

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview/未startPush/已经stopPush

在文件 AlivcLivePusher.java241 行定义.

void com.alivc.live.pusher.AlivcLivePusher.switchCamera ( ) throws IllegalStateException

切换摄像头

异常
IllegalStateException如果状态不对,例如还未初始化/未startPreview

在文件 AlivcLivePusher.java293 行定义.