public class AlivcLivePusher extends java.lang.Object implements ILivePusher
The AlivcLivePusher class is used for the following features:
The ingest of audio and video streams is managed by using a state machine. The following state diagram shows the complete lifecycle and status changes of an AlivcLivePusher object.
Method name | Valid state | Invalid state | Remarks |
init | {Idle, Initialized} | {Previewed, Pushed, Paused, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
destroy | any | {} | After you call this method, the status changes to {Idle}. |
startPreview | {Initialized, Previewed} | {Idle, Pushed, Paused, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Previewed. |
startPreviewAysnc | {Initialized, Previewed} | {Idle, Pushed, Paused, Error,} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Previewed. |
stopPreview | {Initialized, Previewed} | {Idle, Pushed, Paused, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
startPush | {Initialized, Previewed, Pushed} | {Idle,Paused, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Pushed. |
startPushAysnc | {Initialized, Previewed, Pushed} | {Idle, Paused, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Pushed. |
restartPush | {Pushed, Error} | {Idle, Initialized, Previewed, Paused} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Pushed. |
restartPushAync | {Pushed, Error} | {Idle, Initialized, Previewed, Paused,} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Pushed. |
reconnectPushAsync | {Pushed, Paused} | {Idle, Initialized, Previewed, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
stopPush | {Previewed, Pushed,Error} | {Idle, Initialized, Previewed, Pushed, Paused} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
pause | {Pushed,Paused,Previewed} | {Idle, Initialized, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
resume | {Paused,Pushed,Previewed,Initialized} | {Idle, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
resumeAsync | {Paused,Pushed,Previewed,Initialized} | {Idle, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status changes to Initialized. |
setBeautyOn | {Previewed, Pushed, Paused,} | {Idle, Initialized, Error} | If you call this method in an invalid state, the status does not change. If you call this method in a valid state, the status does not change. |
The {android.permission.CAMERA} and {android.permission.RECORD_AUDIO} permissions must be obtained to call this class.
When you pause or resume an activity, you must call the pause or resume function to deal with different scenarios, such as switching between the foreground and background, locking the screen, redirecting to another page, and answering a phone call.
When you use AliLive SDK for Android, the call of the following interfaces takes a long time due to hardware encoding and the network. Therefore, the SDK provides asynchronous interfaces for you to use. In addition, the SDK provides an asynchronous interface that is used for reconnections to help you deal with network errors.
After you call an interface, IllegalArgumentException or IllegalStateException may be thrown.
Modifier and Type | Class and Description |
---|---|
protected static class |
AlivcLivePusher.ScreenRecordStatus |
Constructor and Description |
---|
AlivcLivePusher() |
Modifier and Type | Method and Description |
---|---|
int |
addDynamicsAddons(java.lang.String path,
float x,
float y,
float w,
float h)
Add an animated sticker.
|
int |
addMixAudio(int channels,
AlivcSoundFormat format,
int audioSample)
Add an audio stream for mixing, and set the audio format and sample rate for the audio stream.
|
int |
addMixVideo(AlivcImageFormat format,
int width,
int height,
int rotation,
float displayX,
float displayY,
float displayW,
float displayH,
boolean adjustHeight)
Add a stream for stream mixing, set the width and height of the stream, and set the relative position for the stream in the main stream.
|
private void |
addWaterMark() |
void |
changeResolution(AlivcResolutionEnum resolutionEnum)
Set the resolution.
|
private void |
checkConfig(AlivcLivePushConfig livePushConfig) |
void |
destroy()
Stop the stream ingest.
|
void |
focusCameraAtAdjustedPoint(float x,
float y,
boolean autoFocus)
The coordinates of the focus point is ([0,Screen width],[0,Screen width]).
|
private int |
getBGMVolume() |
private boolean |
getBlueToothHeadSetOn() |
private int |
getCaptureVolume() |
int |
getCurrentExposure()
Query the exposure value of the camera.
|
AlivcLivePushStats |
getCurrentStatus()
Query the current status of stream ingest.
|
int |
getCurrentZoom()
Query the current zoom factor.
|
private java.lang.String |
getFormatString(java.lang.String string) |
private boolean |
getHeadSetPlugOn() |
private java.lang.String |
getHeartBeatInfo() |
private int[] |
getImageWidthHeight(java.lang.String path) |
AlivcLivePushError |
getLastError()
Query the recently returned error codes.
|
AlivcLivePushStatsInfo |
getLivePushStatsInfo()
Query the statistics on stream ingest.
|
java.lang.String |
getLiveTraceId() |
int |
getMaxZoom()
Query the maximum zoom factor supported by the camera.
|
private void |
getNetworkTime() |
private java.util.Map<java.lang.String,java.lang.String> |
getPerformanceMap() |
java.lang.String |
getPushUrl()
Query the ingest URL.
|
static java.lang.String |
getSDKVersion()
Query the version number of AliLive SDK for Android.
|
int |
getSupportedMaxExposure()
Query the maximum exposure value supported by the camera.
|
int |
getSupportedMinExposure()
Query the minimum exposure value supported by the camera.
|
private long |
getTimeFromNtpServer(java.lang.String ntpHost) |
private int |
getTimestamp(java.lang.String string) |
void |
init(android.content.Context context,
AlivcLivePushConfig config)
Initialize the stream ingest parameters.
|
boolean |
inputMixAudioData(int handler,
byte[] data,
int size,
long pts)
Specify the data for audio stream mixing.
|
boolean |
inputMixAudioPtr(int handler,
long dataptr,
int size,
long pts)
Specify the data for audio stream mixing.
|
void |
inputMixTexture(int handler,
int texture,
int width,
int height,
long pts,
int rotation)
Specify the data for video stream mixing.
|
void |
inputMixVideoData(int handler,
byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
Specify the data for video stream mixing.
|
void |
inputMixVideoPtr(int handler,
long dataptr,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
Specify the data for video stream mixing.
|
void |
inputStreamAudioData(byte[] data,
int size,
int sampleRate,
int channels,
long pts)
Customize audio data.
|
void |
inputStreamAudioPtr(long dataPtr,
int size,
int sampleRate,
int channels,
long pts)
Customize audio data.
|
void |
inputStreamTexture(int textureId,
int width,
int height,
int stride,
long pts,
int rotation,
long extra)
Specify the data for custom video streams.
|
void |
inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
Specify the data for custom video streams.
|
void |
inputStreamVideoPtr(long dataptr,
int width,
int height,
int stride,
int size,
long pts,
int rotation)
Specify the data for custom video streams.
|
boolean |
isCameraSupportAutoFocus()
Query whether autofocus is supported.
|
boolean |
isCameraSupportFlash()
Query whether the flash is supported.
|
boolean |
isNetworkPushing()
Query whether a stream is being ingested over the Internet.
|
boolean |
isPushing()
Query whether a stream being ingested by using the SDK.
|
int |
mixStreamChangePosition(int vid,
float x,
float y,
float w,
float h) |
void |
mixStreamMirror(int vid,
boolean mirror) |
int |
mixStreamRequireMain(int vid,
boolean require) |
void |
pause()
Pause the stream ingest.
|
void |
pauseBGM()
Pause the playback of background music.
|
void |
pauseScreenCapture()
Pause the stream ingest.
|
void |
reconnectPushAsync(java.lang.String url)
Reconnect and start the stream ingest.
|
private void |
registerHeadsetPlugReceiver() |
void |
removeDynamicsAddons(int id)
Remove an animated sticker.
|
void |
removeMixAudio(int handler)
Remove a mixed audio stream.
|
void |
removeMixVideo(int handler)
Remove a mixed video stream.
|
private void |
reportStartPushEvent(boolean isRestart,
boolean isSync) |
void |
restartPush()
Restart the stream ingest.
|
void |
restartPushAync()
Restart the stream ingest.
|
void |
resume()
Resume the stream ingest.
|
void |
resumeAsync()
Asynchronously resume the stream ingest.
|
void |
resumeBGM()
Resume the playback of background music.
|
void |
resumeScreenCapture()
Resume the stream ingest.
|
void |
sendMessage(java.lang.String info,
int repeat,
int delay,
boolean isKeyFrame)
Send custom messages on the stream ingest client.
|
private void |
sendMessageInternal(java.lang.String info,
int repeat,
int delay,
boolean isKeyFrame,
boolean isGDelayInfo) |
void |
setAudioDenoise(boolean on)
Specify whether to enable noise reduction for audio.
|
void |
setAutoFocus(boolean autoFocus)
Configure the autofocus feature.
|
void |
setBeautyOn(boolean beautyOn)
Specify whether to enable beautification.
|
void |
setBGMEarsBack(boolean isOpen)
Specify whether to enable in-ear monitoring.
|
void |
setBGMLoop(boolean isLoop)
Specify whether to enable loop playback for background music.
|
void |
setBGMVolume(int volume)
Set the volume of vocals in the mixed background music.
|
void |
setCaptureVolume(int volume)
Set the volume of music in the mixed background music.
|
void |
setCustomDetect(AlivcLivePushCustomDetect customDetect)
setCustomDetect
|
void |
setCustomFilter(AlivcLivePushCustomFilter customFilter) |
void |
setExposure(int exposure)
Set the exposure value for the camera.
|
void |
setFlash(boolean flash)
Specify whether to enable the flash.
|
void |
setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener)
Set the listener for notifications about the playback of background music.
|
void |
setLivePushErrorListener(AlivcLivePushErrorListener errorListener)
Set the listener for errors related to stream ingest.
|
void |
setLivePushInfoListener(AlivcLivePushInfoListener infoListener)
Set the listener for notifications about stream ingest.
|
void |
setLivePushNetworkListener(AlivcLivePushNetworkListener networkListner)
Set the listener for notifications about the network.
|
void |
setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
Set the listener for the rendering context.
|
void |
setLogDirPath(java.lang.String logDirPath)
Set the path for storing log files.
|
void |
setLogLevel(AlivcLivePushLogLevel level)
Set the log level.
|
void |
setMainStreamPosition(float startX,
float startY,
float w,
float h) |
void |
setMinVideoBitrate(int minVideoBitrate)
Set the minimum bitrate of the video after encoding in the range from 100 to 5000.
|
void |
setMute(boolean mute)
Specify whether to mute the audio during stream ingest.
|
void |
setPreviewMirror(boolean mirror)
Specify whether to enable preview mirroring.
|
void |
setPreviewMode(AlivcPreviewDisplayMode mode)
Set the preview mode.
|
void |
setPreviewOrientation(AlivcPreviewOrientationEnum orientation)
Set the stream ingest mode.
|
void |
setPushMirror(boolean mirror)
Specify whether to enable horizontal mirroring on the stream ingest client.
|
void |
setQualityMode(AlivcQualityModeEnum mode)
Set the video resolution.
|
void |
setScreenOrientation(int orientation)
Set the rotation angle for the screen during recording.
|
void |
setTargetVideoBitrate(int targetVideoBitrate)
Set the bitrate to be used after video encoding in the range from 100 to 5000.
|
void |
setWaterMarkVisible(boolean visible)
Specify whether to make watermarks visible.
|
void |
setZoom(int zoom)
Set the zoom factor.
|
void |
snapshot(int count,
int interval,
AlivcSnapshotListener listener)
Capture snapshots of the video stream.
|
void |
startBGMAsync(java.lang.String path)
Play background music.
|
int |
startCamera(android.view.SurfaceView surfaceView)
Enable the camera preview during recording.
|
int |
startCameraMix(float x,
float y,
float w,
float h)
Enable the camera mixing during recording.
|
void |
startPreview(android.view.SurfaceView surfaceView)
Start the preview.
|
void |
startPreviewAysnc(android.view.SurfaceView surfaceView)
Asynchronously start the preview.
|
void |
startPush(java.lang.String url)
Start the stream ingest.
|
void |
startPushAysnc(java.lang.String url)
Start the stream ingest.
|
private void |
startScheduleExecutor() |
private void |
stop5Interval() |
void |
stopBGMAsync()
Stop the playback of background music.
|
void |
stopCamera()
Disable the camera preview during recording.
|
void |
stopCameraMix()
Disable the camera mixing during recording.
|
void |
stopPreview()
Stop the preview.
|
void |
stopPush()
Stop the stream ingest.
|
void |
switchCamera()
Switch between the front and rear cameras.
|
private static LivePusherJNI mNativeAlivcLivePusher
private AlivcLivePushStats mPushStatus
private AlivcLivePlayStats mPlayStats
private AlivcLivePushError mLastError
private AlivcLivePushInfoListener mPushInfoListener
private AlivcLivePushErrorListener mPushErrorListener
private AlivcLivePushNetworkListener mPushNetworkListener
private AlivcLivePushBGMListener mPushBGMListener
private AlivcLivePusherRenderContextListener mRenderContextListener
private SurfaceStatus mSurfaceStatus
private android.view.SurfaceView mPreviewView
private android.media.AudioManager mAudioManager
private android.content.Context mContext
private AlivcLivePushConfig mAlivcLivePushConfig
private static AlivcResolutionEnum res
private static final int NTP_TIME_OUT_MILLISECOND
private static final java.lang.String AUTH_KEY
private static final int TIMESTAMP_LENGTH
private static final int MAX_CHATS
private static final float TEXTURE_RANGE_MIN
private static final float TEXTURE_RANGE_MAX
private static final int MAX_DYNAMIC_ADDSON_COUNT
private static final int AlivcLivePushPublishType_RTMP
private static final int AlivcLivePushPublishType_RTP
private java.util.Map<java.lang.Integer,AlivcLivePushError> mErrorMap
private int mSkinSmooth
private int mWhiten
private int mBright
private int mCheekPink
private int mWholePink
private int mSlimFace
private int mShortenFace
private int mBigEye
private static java.lang.String mPushUrl
private int mBGMVolume
private int mCaptureVolume
private boolean mMute
private android.telephony.TelephonyManager manager
private AlivcLivePushLogLevel mLogLevel
private static final int SECOND
private static final int MESSAGE_RECONNECT_SUCCESS
private boolean registeredCallback
protected BluetoothHeadsetUtils mBluetoothHelper
private boolean isReconnect
private LiveEventReporter mLiveEventReporter
private static boolean isDebugView
private long mTimeStamp
private int mExpiryTime
private boolean mixRequireMain
private int mDynamicAddsonCount
private AlivcSnapshotListener mSnapshotListener
private AlivcLivePusher.ScreenRecordStatus mScreenStatus
private java.util.concurrent.ThreadPoolExecutor mThreadPoolExecutor
private java.lang.String mDebugFunctionText
private android.os.Handler mHandler
private android.view.SurfaceHolder.Callback mPreviewCallback
private java.util.concurrent.ScheduledExecutorService scheduleExecutor
private android.content.BroadcastReceiver mHeadsetPlugReceiver
private android.content.BroadcastReceiver mTelephoneReceiver
private AlivcSnapshotListener mInnerSnapshotListener
public void init(android.content.Context context, AlivcLivePushConfig config) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
init
in interface ILivePusher
context
- The context.config
- The configurations.java.lang.IllegalArgumentException
- The exception is thrown if the config class is unspecified or invalid. For example, the bitrate exceeds the upper limit.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is initialized but not destroyed.public void setCustomDetect(AlivcLivePushCustomDetect customDetect)
customDetect
- public void destroy() throws java.lang.IllegalStateException
destroy
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized.public void startPreview(android.view.SurfaceView surfaceView) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
startPreview
in interface ILivePusher
surfaceView
- surfaceviewjava.lang.IllegalArgumentException
- The exception is thrown if the surfaceView parameter is unspecified, or the surface is destroyed or is not created.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized.public void startPreviewAysnc(android.view.SurfaceView surfaceView) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
startPreviewAysnc
in interface ILivePusher
surfaceView
- surfaceviewjava.lang.IllegalArgumentException
- The exception is thrown if the surfaceView parameter is unspecified, or the surface is destroyed or is not created.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized.public void stopPreview() throws java.lang.IllegalStateException
stopPreview
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void startPush(java.lang.String url) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
startPush
in interface ILivePusher
url
- The ingest URL.java.lang.IllegalArgumentException
- The exception is thrown if no ingest URL is specified or the format of the ingest URL is invalid.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void startPushAysnc(java.lang.String url) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
startPushAysnc
in interface ILivePusher
url
- The ingest URL.java.lang.IllegalArgumentException
- The exception is thrown if no ingest URL is specified or the format of the ingest URL is invalid.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void restartPush() throws java.lang.IllegalStateException
restartPush
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is stopped.public void restartPushAync() throws java.lang.IllegalStateException
restartPushAync
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is stopped.public void reconnectPushAsync(java.lang.String url) throws java.lang.IllegalStateException
reconnectPushAsync
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is stopped.public void stopPush() throws java.lang.IllegalStateException
stopPush
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is stopped.public void pause() throws java.lang.IllegalStateException
pause
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is paused.public void resume() throws java.lang.IllegalStateException
resume
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, the stream ingest is not paused, or the stream ingest is resumed.public void resumeAsync() throws java.lang.IllegalStateException
resumeAsync
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, the stream ingest is not paused, or the stream ingest is resumed.public void pauseScreenCapture() throws java.lang.IllegalStateException
pauseScreenCapture
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, or the stream ingest is paused.public void resumeScreenCapture() throws java.lang.IllegalStateException
resumeScreenCapture
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, the stream ingest is not started, the stream ingest is not paused, or the stream ingest is resumed.public void setBeautyOn(boolean beautyOn) throws java.lang.IllegalStateException
setBeautyOn
in interface ILivePusher
beautyOn
- true: enables beautification. false: disables beautification.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void switchCamera() throws java.lang.IllegalStateException
switchCamera
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void setAutoFocus(boolean autoFocus) throws java.lang.IllegalStateException
setAutoFocus
in interface ILivePusher
autoFocus
- The autofocus feature.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void focusCameraAtAdjustedPoint(float x, float y, boolean autoFocus) throws java.lang.IllegalStateException
focusCameraAtAdjustedPoint
in interface ILivePusher
x
- The x-coordinate of the focus point.y
- The y-coordinate of the focus point.autoFocus
- Specify whether to enable autofocus.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void setExposure(int exposure)
setExposure
in interface ILivePusher
public int getCurrentExposure()
getCurrentExposure
in interface ILivePusher
public int getSupportedMinExposure()
getSupportedMinExposure
in interface ILivePusher
public int getSupportedMaxExposure()
getSupportedMaxExposure
in interface ILivePusher
public void setZoom(int zoom) throws java.lang.IllegalStateException
setZoom
in interface ILivePusher
zoom
- 0~getMaxZoom()java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public int getMaxZoom() throws java.lang.IllegalStateException
getMaxZoom
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public int getCurrentZoom() throws java.lang.IllegalStateException
getCurrentZoom
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void setMute(boolean mute) throws java.lang.IllegalStateException
setMute
in interface ILivePusher
mute
- true: muted stream ingest. false: normal stream ingest.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.public void setFlash(boolean flash) throws java.lang.IllegalStateException
setFlash
in interface ILivePusher
flash
- true: enables the flash. false: disables the flash.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void setPushMirror(boolean mirror) throws java.lang.IllegalStateException
setPushMirror
in interface ILivePusher
mirror
- true: enables horizontal mirroring. false: disables horizontal mirroring.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.public void setPreviewMirror(boolean mirror) throws java.lang.IllegalStateException
setPreviewMirror
in interface ILivePusher
mirror
- true: enables preview mirroring. false: disables preview mirroring.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized or the preview is not started.public void setTargetVideoBitrate(int targetVideoBitrate) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
setTargetVideoBitrate
in interface ILivePusher
targetVideoBitrate
- The bitrate to be used after video encoding.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.java.lang.IllegalArgumentException
public void setMinVideoBitrate(int minVideoBitrate) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
setMinVideoBitrate
in interface ILivePusher
minVideoBitrate
- The minimum bitrate of the video after encoding.java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.java.lang.IllegalArgumentException
public boolean isCameraSupportAutoFocus()
isCameraSupportAutoFocus
in interface ILivePusher
public boolean isCameraSupportFlash()
isCameraSupportFlash
in interface ILivePusher
public boolean isPushing() throws java.lang.IllegalStateException
isPushing
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.public AlivcLivePushStats getCurrentStatus()
getCurrentStatus
in interface ILivePusher
public AlivcLivePushError getLastError()
getLastError
in interface ILivePusher
public void snapshot(int count, int interval, AlivcSnapshotListener listener)
snapshot
in interface ILivePusher
count
- The number of captured snapshots.interval
- The interval for capturing snapshots.listener
- The callback for snapshot capture.public boolean isNetworkPushing() throws java.lang.IllegalStateException
isNetworkPushing
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.public void setLivePushErrorListener(AlivcLivePushErrorListener errorListener)
setLivePushErrorListener
in interface ILivePusher
errorListener
- The listener for errors.public void setLivePushInfoListener(AlivcLivePushInfoListener infoListener)
setLivePushInfoListener
in interface ILivePusher
infoListener
- The listener for notifications.public void setLivePushNetworkListener(AlivcLivePushNetworkListener networkListner)
setLivePushNetworkListener
in interface ILivePusher
networkListner
- The listener for notifications.public void setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener)
setLivePushBGMListener
in interface ILivePusher
pushBGMListener
- The listener for notifications.public void setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
setLivePushRenderContextListener
in interface ILivePusher
renderCtxListener
- The listener for the rendering context.public static java.lang.String getSDKVersion()
public AlivcLivePushStatsInfo getLivePushStatsInfo() throws java.lang.IllegalStateException
getLivePushStatsInfo
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized.public java.lang.String getPushUrl() throws java.lang.IllegalStateException
getPushUrl
in interface ILivePusher
java.lang.IllegalStateException
- The exception is thrown if the AlivcLivePusher object is in an invalid state. For example, the AlivcLivePusher object is not initialized, the preview is not started, or the stream ingest is not started.private void checkConfig(AlivcLivePushConfig livePushConfig) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public void setPreviewOrientation(AlivcPreviewOrientationEnum orientation)
setPreviewOrientation
in interface ILivePusher
orientation
- The stream ingest mode.private java.util.Map<java.lang.String,java.lang.String> getPerformanceMap()
private java.lang.String getHeartBeatInfo()
public java.lang.String getLiveTraceId()
public void setLogLevel(AlivcLivePushLogLevel level)
setLogLevel
in interface ILivePusher
level
- java.lang.IllegalStateException
public void setLogDirPath(java.lang.String logDirPath)
setLogDirPath
in interface ILivePusher
logDirPath
- java.lang.IllegalStateException
public void sendMessage(java.lang.String info, int repeat, int delay, boolean isKeyFrame) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
info
- The supplemental enhancement information (SEI) message that needs to be inserted into streams. We recommend that format the message in JSON.repeat
- The number of frames for which the SEI message is sent.delay
- The latency of sending messages. Unit: milliseconds.isKeyFrame
- Specify whether to send the SEI message for only keyframes.java.lang.IllegalStateException
java.lang.IllegalArgumentException
private void sendMessageInternal(java.lang.String info, int repeat, int delay, boolean isKeyFrame, boolean isGDelayInfo) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
private int getBGMVolume()
private int getCaptureVolume()
private boolean getHeadSetPlugOn()
private boolean getBlueToothHeadSetOn()
public void startBGMAsync(java.lang.String path) throws java.lang.IllegalStateException
startBGMAsync
in interface ILivePusher
path
- The path for storing background music.java.lang.IllegalStateException
public void stopBGMAsync() throws java.lang.IllegalStateException
stopBGMAsync
in interface ILivePusher
java.lang.IllegalStateException
public void pauseBGM() throws java.lang.IllegalStateException
pauseBGM
in interface ILivePusher
java.lang.IllegalStateException
public void resumeBGM() throws java.lang.IllegalStateException
resumeBGM
in interface ILivePusher
java.lang.IllegalStateException
public void setBGMLoop(boolean isLoop) throws java.lang.IllegalStateException
setBGMLoop
in interface ILivePusher
isLoop
- true: enables loop playback. false: disables loop playback.java.lang.IllegalStateException
public void setBGMEarsBack(boolean isOpen) throws java.lang.IllegalStateException
setBGMEarsBack
in interface ILivePusher
isOpen
- true: enables in-ear monitoring. false: disables in-ear monitoring.java.lang.IllegalStateException
public void setBGMVolume(int volume) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
setBGMVolume
in interface ILivePusher
volume
- The volume of vocals. Valid values: [0,100]. Default value: 50.IllegalStateException,IllegalArgumentException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
public void setCaptureVolume(int volume) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
setCaptureVolume
in interface ILivePusher
volume
- The volume of music. Valid values: [0,100]. Default value: 50.IllegalStateException,IllegalArgumentException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
public void setAudioDenoise(boolean on) throws java.lang.IllegalStateException
setAudioDenoise
in interface ILivePusher
on
- true: enables noise reduction. false: disables noise reduction.java.lang.IllegalStateException
public void setQualityMode(AlivcQualityModeEnum mode) throws java.lang.IllegalStateException
setQualityMode
in interface ILivePusher
mode
- The video resolution.java.lang.IllegalStateException
public void setPreviewMode(AlivcPreviewDisplayMode mode) throws java.lang.IllegalStateException
setPreviewMode
in interface ILivePusher
mode
- The preview mode.java.lang.IllegalStateException
private void startScheduleExecutor()
private int[] getImageWidthHeight(java.lang.String path)
private void addWaterMark()
private void stop5Interval()
private void reportStartPushEvent(boolean isRestart, boolean isSync)
private void registerHeadsetPlugReceiver()
public void setCustomFilter(AlivcLivePushCustomFilter customFilter)
private void getNetworkTime()
private long getTimeFromNtpServer(java.lang.String ntpHost)
public void setWaterMarkVisible(boolean visible)
setWaterMarkVisible
in interface ILivePusher
visible
- Specify whether to make watermarks visible.public int startCamera(android.view.SurfaceView surfaceView) throws java.lang.IllegalStateException
startCamera
in interface ILivePusher
surfaceView
- surfaceViewjava.lang.IllegalStateException
public void setScreenOrientation(int orientation)
setScreenOrientation
in interface ILivePusher
orientation
- The rotation angle.public void stopCamera()
stopCamera
in interface ILivePusher
public int startCameraMix(float x, float y, float w, float h)
startCameraMix
in interface ILivePusher
x
- The initial position of the mixed stream on the x-axis. The parameter value is a floating-point number between 0 and 1.y
- The initial position of the mixed stream on the y-axis. The parameter value is a floating-point number between 0 and 1.w
- The screen width of the mixed stream. The parameter value is a floating-point number between 0 and 1.h
- The screen height of the mixed stream. The parameter value is a floating-point number between 0 and 1.public void stopCameraMix()
stopCameraMix
in interface ILivePusher
public void changeResolution(AlivcResolutionEnum resolutionEnum)
changeResolution
in interface ILivePusher
resolutionEnum
- Enumerate resolutions.public int mixStreamRequireMain(int vid, boolean require)
public int mixStreamChangePosition(int vid, float x, float y, float w, float h)
public void mixStreamMirror(int vid, boolean mirror)
public int addMixVideo(AlivcImageFormat format, int width, int height, int rotation, float displayX, float displayY, float displayW, float displayH, boolean adjustHeight)
format
- The format of the current input video image.width
- The width of the current input video image.height
- The height of the current input video image.rotation
- The rotation angle of the current input video image.displayX
- The initial position of the current mixed stream on the x-axis.displayY
- The initial position of the current mixed stream on the y-axis.displayW
- The screen width of the current mixed stream.displayH
- The screen height of the current mixed stream.public void removeMixVideo(int handler)
handler
- The video handler of the mixed video stream that you want to remove.public void inputMixTexture(int handler, int texture, int width, int height, long pts, int rotation)
handler
- The video handler of existing mixed streams.texture
- The ID of the texture of video images.width
- The width of video images.height
- The height of video images.pts
- The presentation timestamp (PTS) of video images. Unit: microseconds.rotation
- The rotation angle of video images.
Note: This interface does not control timestamps. You must control the timestamps of input video frames.public void inputMixVideoPtr(int handler, long dataptr, int width, int height, int stride, int size, long pts, int rotation)
handler
- The video handler of existing mixed streams.dataptr
- The pointer of the native memory for video images.width
- The width of video images.height
- The height of video images.size
- The size of video images.pts
- The PTS of video images. Unit: microseconds.rotation
- The rotation angle of video images.
Note: This interface does not control timestamps. You must control the timestamps of input video frames.public void inputMixVideoData(int handler, byte[] data, int width, int height, int stride, int size, long pts, int rotation)
handler
- The video handler of existing mixed streams.data
- The byte array of video images.width
- The width of video images.height
- The height of video images.size
- The size of video images.pts
- The PTS of video images. Unit: microseconds.rotation
- The rotation angle of video images.
Note: This interface does not control timestamps. You must control the timestamps of input video frames.public int addMixAudio(int channels, AlivcSoundFormat format, int audioSample)
channels
- The number of sound channels of the current audio stream.format
- The format of the current audio stream.audioSample
- The audio sample rate of the current audio stream.public void removeMixAudio(int handler)
handler
- The audio handler of the existing mixed audio streams.public boolean inputMixAudioPtr(int handler, long dataptr, int size, long pts)
handler
- The audio handler of existing mixed streams.dataptr
- The pointer of the native memory for audio.size
- The size of audio.pts
- The PTS of audio. Unit: microseconds.
Note: This interface does not control timestamps. The caller must control the timestamps of input audio frames.public boolean inputMixAudioData(int handler, byte[] data, int size, long pts)
handler
- The audio handler of existing mixed streams.data
- The byte array of audio.size
- The size of audio.pts
- The PTS of audio. Unit: microseconds.
Note: This interface does not control timestamps. The caller must control the timestamps of input audio frames.public void inputStreamVideoPtr(long dataptr, int width, int height, int stride, int size, long pts, int rotation)
inputStreamVideoPtr
in interface ILivePusher
dataptr
- The pointer of the native memory for video images.width
- The width of video images.height
- The height of video images.size
- The size of video images.pts
- The PTS of video images. Unit: microseconds.rotation
- The rotation angle of video images.public void inputStreamTexture(int textureId, int width, int height, int stride, long pts, int rotation, long extra)
textureId
- The ID of the texture of video images.width
- The width of video images.height
- The height of video images.pts
- The PTS of video images. Unit: microseconds.rotation
- The rotation angle of video images.extra
- Reserved.
Note: This interface does not control timestamps. The caller must control the timestamps of input video frames.public void inputStreamVideoData(byte[] data, int width, int height, int stride, int size, long pts, int rotation)
inputStreamVideoData
in interface ILivePusher
data
- The byte array of video images.width
- The width of video images.height
- The height of video images.size
- The size of video images.pts
- The PTS of video images. Unit: microseconds.rotation
- The rotation angle of video images.public void inputStreamAudioPtr(long dataPtr, int size, int sampleRate, int channels, long pts)
inputStreamAudioPtr
in interface ILivePusher
dataPtr
- The pointer of the native memory for audio.size
- pts
- The PTS of audio. Unit: microseconds.public void inputStreamAudioData(byte[] data, int size, int sampleRate, int channels, long pts)
inputStreamAudioData
in interface ILivePusher
data
- The byte array of audio.size
- pts
- The PTS of audio. Unit: microseconds.public int addDynamicsAddons(java.lang.String path, float x, float y, float w, float h) throws java.lang.IllegalArgumentException
addDynamicsAddons
in interface ILivePusher
path
- The path of the animated sticker. The config.json file must be stored in the path.x
- The initial position of the animated sticker on the x-axis. The parameter value is a floating-point number between 0 and 1.y
- The initial position of the animated sticker on the y-axis. The parameter value is a floating-point number between 0 and 1.w
- The screen width of the animated sticker. The parameter value is a floating-point number between 0 and 1.h
- The screen height of the animated sticker. The parameter value is a floating-point number between 0 and 1.java.lang.IllegalArgumentException
public void removeDynamicsAddons(int id)
removeDynamicsAddons
in interface ILivePusher
id
- The ID of the animated sticker.public void setMainStreamPosition(float startX, float startY, float w, float h)
private java.lang.String getFormatString(java.lang.String string)
private int getTimestamp(java.lang.String string)