Use Push SDK for Android
Learn how to register, configure, and use the Push SDK for Android for live stream ingest, with examples for camera capture, screen sharing, retouching, and more.
Features
Supports stream ingest over Real-Time Messaging Protocol (RTMP).
Supports RTS stream ingest and pulling based on Real-Time Communication (RTC).
Supports co-streaming and battles.
Adopts H.264 for video encoding and AAC for audio encoding.
Supports custom configurations for features such as bitrate control, resolution, and display mode.
Supports various camera operations.
Supports real-time retouching and custom retouching effects.
Allows you to add and remove animated stickers as watermarks.
Allows you to stream screen recordings.
Supports external audio and video inputs in different formats such as YUV and pulse-code modulation (PCM).
Supports mixing of multiple streams.
Supports ingest of audio-only and video-only streams and stream ingest in the background.
Supports background music.
Supports video snapshot capture.
Supports automatic reconnection and error handling.
Supports Automatic Gain Control (AGC), Automatic Noise Reduction (ANR), and Acoustic Echo Cancellation (AEC) algorithms.
Allows you to switch between the software and hardware encoding modes for video files. This improves the stability of the encoding module.
Limitations
Take note of the following limits before you use Push SDK for Android:
You must configure screen orientation before stream ingest. You cannot rotate the screen during live streaming.
You must disable auto screen rotation for stream ingest in landscape mode.
In hardware encoding mode, the value of the output resolution must be a multiple of 16 to be compatible with the encoder. For example, if you set the resolution to 540p, the output resolution is 544 × 960. You must scale the screen size of the player based on the output resolution to prevent black bars.
API reference
Procedure
Feature usage
Register the SDK
To obtain and configure a license, integrate a Push SDK license.
You must register the SDK before you can use its stream ingest features.
Call the license registration API early in your application's lifecycle, before using the Push SDK for Android.
AlivcLiveBase.setListener(new AlivcLiveBaseListener() {
@Override
public void onLicenceCheck(AlivcLivePushConstants.AlivcLiveLicenseCheckResultCode result, String reason) {
Log.e(TAG, "onLicenceCheck: " + result + ", " + reason);
}
});
AlivcLiveBase.registerSDK();
-
Use the
AlivcLiveBaseclass to set log levels, specify local log paths, and get the SDK version. -
You must call the
registerSDKmethod in AlivcLiveBase to register the SDK license. -
Implement the
onLicenceCheckcallback in theAlivcLiveBase#setListenerinterface to asynchronously verify the license configuration.NoteThis callback is triggered only after you initialize the pusher instance.
Configure stream ingest parameters
Stream ingest parameters have default values that require no extra configuration.
// Initialize the stream ingest configuration class.
AlivcLivePushConfig mAlivcLivePushConfig = new AlivcLivePushConfig();
// Set the stream ingest mode. The default is the basic mode.
mAlivcLivePushConfig.setLivePushMode(AlivcLiveMode.AlivcLiveBasicMode);
// Set the resolution. The default is 540p.
mAlivcLivePushConfig.setResolution(AlivcResolutionEnum.RESOLUTION_540P);
// Set the frame rate. The default is 25 fps.
mAlivcLivePushConfig.setFps(AlivcFpsEnum.FPS_25);
// Set the video encoding GOP size in seconds. The default is 2 seconds.
mAlivcLivePushConfig.setVideoEncodeGop(AlivcVideoEncodeGopEnum.GOP_TWO);
// Enable bitrate control. This is enabled by default.
mAlivcLivePushConfig.setEnableBitrateControl(true);
// Set the screen orientation. The default is portrait. You can also set it to landscape with the home button on the left or right.
mAlivcLivePushConfig.setPreviewOrientation(AlivcPreviewOrientationEnum.ORIENTATION_PORTRAIT);
// Set the audio encoding profile. The default is AAC-LC.
mAlivcLivePushConfig.setAudioProfile(AlivcAudioAACProfileEnum.AAC_LC);
// Set the video encoding mode. The default is hardware encoding.
mAlivcLivePushConfig.setVideoEncodeMode(AlivcEncodeModeEnum.Encode_MODE_HARD);
// Set the audio encoding mode. The default is software encoding.
mAlivcLivePushConfig.setAudioEncodeMode(AlivcEncodeModeEnum.Encode_MODE_SOFT);
// Set the camera type. The default is the front camera.
mAlivcLivePushConfig.setCameraType(AlivcLivePushCameraTypeEnum.CAMERA_TYPE_FRONT);
// Set the image to display when the app is in the background or stream ingest is paused.
mAlivcLivePushConfig.setPausePushImage("TODO: Image Path");
// Set the image to display in poor network conditions.
mAlivcLivePushConfig.setNetworkPoorPushImage("TODO: Image Path");
-
Set the resolution to 540p for optimal balance between device performance and bandwidth.
-
Disabling bitrate control fixes the bitrate at the initial value without adapting to network conditions, which may cause playback stuttering.
Ingest camera stream
-
Initialize.
Call the
initmethod after configuring stream ingest parameters:AlivcLivePusher mAlivcLivePusher = new AlivcLivePusher(); mAlivcLivePusher.init(mContext, mAlivcLivePushConfig);NoteAlivcLivePusherdoes not support multiple instances. Eachinitcall must be paired with adestroycall. -
Register preview callbacks.
Call the
setLivePushInfoListenermethod to register preview callbacks:/** * Set a listener for stream ingest event notifications. * * @param infoListener The notification listener. */ mAlivcLivePusher.setLivePushInfoListener(new AlivcLivePushInfoListener() { @Override public void onPreviewStarted(AlivcLivePusher pusher) { // Notification that the preview has started. } // Other override methods //.... //.... }); -
Start the preview.
Start the preview by passing the
SurfaceViewfor the camera preview:mAlivcLivePusher.startPreview(mSurfaceView); // Starts the preview. You can also call the asynchronous startPreviewAsync method based on your needs. -
Start stream ingest.
Add the following code inside the onPreviewStarted callback method.
mAlivcLivePusher.startPush(mPushUrl);Note-
Ingest URLs for RTMP and RTS (artc://) are supported. To get URLs, see Generate ingest and streaming URLs.
-
ApsaraVideo Live rejects concurrent stream ingest requests to the same URL.
-
Common stream ingest methods
The SDK provides methods to control stream lifecycle: start, stop, pause, resume, restart, reconnect, and dispose.
/* Call to pause a stream that is being ingested. After pausing, the video preview and video stream ingest are held on the last frame, while audio stream ingest continues. */
mAlivcLivePusher.pause();
/* Call to resume a paused stream. After resuming, the audio and video preview and stream ingest return to normal. */
mAlivcLivePusher.resume();
/* Call to stop a stream that is being ingested. After completion, stream ingest stops. */
mAlivcLivePusher.stopPush();
/* Call to stop the preview only when in the previewing state. Calling this while ingesting a stream has no effect. After the preview stops, the preview frame freezes on the last frame. */
mAlivcLivePusher.stopPreview();
/* Call to restart stream ingest when a stream is being ingested or after receiving any error-related callback. In an error state, you can only call this API, reconnectPushAsync, or destroy. Restarting reinitializes all internal resources of AlivcLivePusher, including preview and stream ingest. */
mAlivcLivePusher.restartPush();
/* Call to reconnect a stream when it is being ingested or after receiving an error callback related to AlivcLivePusherNetworkDelegate. In an error state, you can only call this API, restartPush, or destroy. Reconnecting re-establishes the RTMP connection for stream ingest. */
mAlivcLivePusher.reconnectPushAsync();
/* Call to dispose of the stream ingest instance. After disposal, stream ingest and preview stop, and the preview surface is removed. All resources related to AlivcLivePusher are released. */
mAlivcLivePusher.destroy();
Camera operations
Switch cameras, toggle the flash, and adjust focus, zoom, and mirroring during stream ingest, pause, or reconnection:
/* Switch between the front and rear cameras. */
mAlivcLivePusher.switchCamera();
/* Turn the flash on or off. Turning on the flash has no effect when the front camera is active. */
mAlivcLivePusher.setFlash(true);
/* Adjust the focal length to zoom the captured image. The zoom range is [0, getMaxZoom()]. */
mAlivcLivePusher.setZoom(5);
/* Manually focus the camera. This requires two parameters: 1. `point` (the coordinates of the point to focus on) and 2. `autoFocus` (whether to enable autofocus for this specific operation). Subsequent autofocus behavior follows the value set by the setAutoFocus API. */
mAlivcLivePusher.focusCameraAtAdjustedPoint(x, y, true);
/* Set whether to enable autofocus. */
mAlivcLivePusher.setAutoFocus(true);
/* Configure mirroring. There are two mirroring APIs: PushMirror for the ingested stream and PreviewMirror for the local preview. PushMirror affects only the playback display, while PreviewMirror affects only the preview display. They do not affect each other. */
mAlivcLivePusher.setPreviewMirror(false);
mAlivcLivePusher.setPushMirror(false);
Camera APIs are available only after the preview starts.
Ingest screen sharing stream
Screen sharing uses MediaProjection and requires user permission. Pass the permission result data to the SDK. The camera is disabled by default during screen sharing.
Configure screen sharing
// resultData is the screen sharing system intent.
mAlivcLivePushConfig.setMediaProjectionPermissionResultData(resultData);
Configure screen rotation
Set the screen rotation angle to support landscape and portrait recording during screen sharing:
mAlivcLivePusher.setScreenOrientation(0);
You need to listen for the OrientationEventListener event at the application layer and set the rotation angle through this API when the screen orientation changes.
Configure privacy protection
Enable privacy protection during screen sharing to hide sensitive input such as passwords:
mAlivcLivePusher.pauseScreenCapture(); // Enable privacy protection.
mAlivcLivePusher.resumeScreenCapture(); // Disable privacy protection.
This pauses screen sharing. If setPausePushImage is set in the config, viewers see the specified image. Otherwise, viewers see the last frame before the pause.
Ingest camera and screen sharing streams
You can enable camera ingest during screen sharing. Two approaches are available:
-
The streamer has a camera preview.
Both the streamer and viewers can see the camera feed.
-
The streamer does not have a camera preview.
For example, during a gaming stream, the streamer may not want the camera view to obstruct the game. However, viewers can still see the streamer's camera feed in the final stream.
Streamer can see the camera preview
After screen sharing starts, call the API to start or stop the camera preview.
mAlivcLivePusher.startCamera(surfaceView); // Start the camera preview.
mAlivcLivePusher.stopCamera(); // Stop the camera preview.
-
Set the camera preview
surfaceViewaspect ratio to 1:1 to avoid adjustments on screen rotation. -
If the aspect ratio is not 1:1, you must adjust the
surfaceViewratio when the screen rotates, and then callstopCamerafollowed bystartCamera. -
If the streamer does not need a preview, set
surfaceviewto null.
Streamer cannot see the camera preview
Enable camera stream mixing to include the camera feed in the stream without a local preview.
mAlivcLivePusher.startCameraMix(x, y, w, h); // Enable camera stream mixing and set the x, y, w, and h layout for the mixed stream.
mAlivcLivePusher.stopCameraMix(); // Stop camera stream mixing.
Preview display mode
Three preview display modes are available. The display mode does not affect stream ingest.
-
ALIVC_LIVE_PUSHER_PREVIEW_SCALE_FILL: The video fills the preview window. If the aspect ratios of the video and window are different, the preview appears distorted.
-
ALIVC_LIVE_PUSHER_PREVIEW_ASPECT_FIT: The video's aspect ratio is preserved. If the video and window aspect ratios are different, black bars appear in the preview.
-
ALIVC_LIVE_PUSHER_PREVIEW_ASPECT_FILL: The video is cropped to fit the window's aspect ratio. If the aspect ratios are different, the video is cropped.
The following code provides an example:
mAlivcLivePushConfig.setPreviewDisplayMode(AlivcPreviewDisplayMode.ALIVC_LIVE_PUSHER_PREVIEW_ASPECT_FIT);
Image stream ingest
The SDK can ingest a placeholder image when the app is in the background or the network is poor.
When the app enters the background, video ingest pauses while audio continues. Display a placeholder image to inform viewers:
mAlivcLivePushConfig.setPausePushImage("path/to/background.png"); // Set the image for background stream ingest.
The SDK ingests this image when it detects a low bitrate, reducing video stuttering:
mAlivcLivePushConfig.setNetworkPoorPushImage("path/to/network_poor.png"); // Set the image to ingest in poor network conditions.
Audio-only stream ingest
mAlivcLivePushConfig.setAudioOnly(true);
Ingest external audio and video streams
The SDK supports ingesting audio and video from external sources such as video files.
Enable custom audio and video input first:
/**
* Other parameters such as output resolution, audio sample rate, and number of channels are set in the config object
* using setResolution, setAudioSampleRate, and setAudioChannels.
*/
mAlivcLivePushConfig.setExternMainStream(true,AlivcImageFormat.IMAGE_FORMAT_YUVNV12,AlivcSoundFormat.SOUND_FORMAT_S16);
After enabling custom audio and video input, you can ingest external streams.
Ingest external audio stream
/**
* This API does not control timing. The caller must control the timing of the input audio frames.
*/
mAlivcLivePusher.inputStreamAudioData(byte[] data, int size, int sampleRate, int channels, long pts);
Ingest external video stream
/**
* This API does not control timing. The caller must control the timing of the input video frames.
*/
mAlivcLivePusher.inputStreamVideoData(byte[] data, int width, int height, int stride, int size, long pts, int rotation);
Configure watermarks
Add one or more watermarks in PNG format:
mAlivcLivePushConfig.addWaterMark(waterPath,0.1,0.2,0.3); // Add a watermark.
-
The x, y, and width parameters are relative values. For example, x=0.1 means the watermark's x-coordinate is at 10% of the stream's width. If the stream resolution is 540x960, the watermark's x-coordinate will be 54.
-
The height of the watermark image is scaled proportionally based on its original aspect ratio and the provided width value.
-
To implement a text watermark, first convert the text into an image, then use this API to add it as a watermark.
Configure video quality
Three video quality modes are supported: Resolution Priority mode, Fluency Priority mode, and Custom mode.
To set the video quality, you must enable bitrate control: mAlivcLivePushConfig.setEnableBitrateControl(true);
Resolution Priority mode (default)
The SDK prioritizes video clarity by automatically configuring bitrate parameters.
mAlivcLivePushConfig.setQualityMode(AlivcQualityModeEnum.QM_RESOLUTION_FIRST); // Prioritize resolution.
Fluency Priority mode
The SDK prioritizes video smoothness by automatically configuring bitrate parameters.
mAlivcLivePushConfig.setQualityMode(AlivcQualityModeEnum.QM_FLUENCY_FIRST); // Prioritize fluency.
Custom mode
The SDK uses your bitrate settings. Define the initial, minimum, and target bitrate values.
-
Target bitrate: In good network conditions, the bitrate gradually increases to the target bitrate to improve video clarity.
-
Minimum bitrate: In poor network conditions, the bitrate gradually decreases to the minimum bitrate to reduce video stuttering.
-
Initial bitrate: The bitrate when the live stream begins.
mAlivcLivePushConfig.setQualityMode(AlivcQualityModeEnum.QM_CUSTOM); // Custom mode
mAlivcLivePushConfig.setTargetVideoBitrate(1000); // Target bitrate: 1,000 kbit/s
mAlivcLivePushConfig.setMinVideoBitrate(300); // Minimum bitrate: 300 kbit/s
mAlivcLivePushConfig.setInitialVideoBitrate(800); // Initial bitrate: 800 kbit/s
Refer to the following recommended bitrate settings:
Table 1. Recommended settings for Resolution Priority mode
Resolution | initialVideoBitrate | minVideoBitrate | targetVideoBitrate |
360p | 600 | 300 | 1000 |
480p | 800 | 300 | 1200 |
540p | 1000 | 600 | 1400 |
720p | 1500 | 600 | 2000 |
1080p | 1800 | 1200 | 2500 |
Table 1. Recommended settings for Resolution Priority mode
Resolution | initialVideoBitrate | minVideoBitrate | targetVideoBitrate |
360p | 400 | 200 | 600 |
480p | 600 | 300 | 800 |
540p | 800 | 300 | 1000 |
720p | 1000 | 300 | 1200 |
1080p | 1500 | 1200 | 2200 |
Adaptive resolution
Adaptive resolution automatically lowers the resolution in poor network conditions to improve smoothness:
mAlivcLivePushConfig.setEnableAutoResolution(true); // Enable adaptive resolution. Default is false.
-
Adaptive resolution works only in Resolution Priority or Fluency Priority mode, not in Custom mode.
-
Some players do not support dynamic resolution changes. Use an Alibaba Cloud player for compatibility.
Background music
The SDK supports background music playback, mixing, denoising, in-ear monitoring, and muting:
/* Start playing background music. */
mAlivcLivePusher.startBGMAsync(mPath);
/* Stop playing background music. If BGM is already playing and you need to switch songs, just call the start background music API again. You do not need to stop the current BGM. */
mAlivcLivePusher.stopBGMAsync();
/* Pause background music. This can only be called after BGM has started playing. */
mAlivcLivePusher.pauseBGM();
/* Resume background music. This can only be called when BGM is paused. */
mAlivcLivePusher.resumeBGM();
/* Enable looping for background music. */
mAlivcLivePusher.setBGMLoop(true);
/* Set the denoise switch. When enabled, non-human sounds in the captured audio are filtered. This may slightly suppress human voices. We recommend letting users choose whether to enable this feature. It is disabled by default. */
mAlivcLivePusher.setAudioDenoise(true);
/* Set the in-ear monitoring switch. This feature is mainly used in karaoke scenarios. When enabled with headphones plugged in, the streamer will hear their own voice. When disabled, they will not. This has no effect if headphones are not plugged in. */
mAlivcLivePusher.setBGMEarsBack(true);
/* Configure mixing to adjust the volume of background music and captured voice. */
mAlivcLivePusher.setBGMVolume(50); // Set background music volume.
mAlivcLivePusher.setCaptureVolume(50); // Set captured voice volume.
/* Mute the audio. This mutes both music and voice input. To mute only music or voice, use the mixing volume adjustment APIs. */
mAlivcLivePusher.setMute(true);
Background music APIs are available only after the preview starts.
Stream snapshot
Take a snapshot of the local video stream:
// Take a snapshot of the video stream. Parameters: number of images to capture, interval between each capture in seconds, and a callback listener.
pusher.snapshot(1, 1, new AlivcSnapshotListener() {
@Override
public void onSnapshot(Bitmap bmp) {
// You can save the snapshot to a local PNG file. The following code is an example.
String dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-SS").format(new Date());
File f = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "snapshot-" + dateFormat + ".png");
if (f.exists()) {
f.delete();
}
try {
FileOutputStream out = new FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Background running and screen lock
-
When your app is moved to the background or the screen is locked, you can call the
pause()orresume()methods ofAlivcLivePusherto pause or resume stream ingest. -
For non-system audio and video calls, the SDK captures and ingests sound. Based on your business needs, you can call the
mAlivcLivePusher.setMute(true or false)API to determine whether to capture audio when the app is in the background or the screen is locked.
Callbacks
|
Callback type |
Callback class name |
Setup method |
|
AlivcLivePushInfoListener |
|
|
|
AlivcLivePushNetworkListener |
|
|
|
AlivcLivePushErrorListener |
|
|
|
AlivcLivePushBGMListener |
|
Stream ingest callbacks
Stream ingest callbacks notify the app of SDK status changes: preview start, first frame rendered, first frame sent, ingest start, and ingest stop.
-
onPushStarted: Indicates a successful connection to the server. -
onFirstFramePushed: Indicates that the first audio or video frame was sent successfully. -
onPushStartedandonFirstFramePushedcallbacks indicate that the SDK has successfully started stream ingest.
Network-related callbacks
Network callbacks report connection status. The SDK auto-reconnects on brief network fluctuations within the timeout and retry limits set in AlivcLivePushConfig.
-
onConnectFail: Stream ingest failed. Check the ingest URL for validity, authentication issues, concurrent stream limits, or blocklist status. Error codes: 0x30020901–0x30020905, 0x30010900–0x30010901. -
onConnectionLost: Connection lost. The SDK auto-reconnects, triggeringonReconnectStart. If retries exceedconfig.connectRetryCount,onReconnectFailfires. -
onNetworkPoor: Network is insufficient for stable ingest but the stream is not interrupted. Use this to display a UI notification. -
onNetworkRecovery: Network has recovered. -
onReconnectFail: Auto-reconnection failed after exceeding the timeout and retry limits in AlivcLivePushConfig. CallmAlivcLivePusher.reconnectPushAsyncto reconnect manually after the network recovers. -
onSendDataTimeout: Data send timed out. Check the network, then stop and restart stream ingest. -
onPushURLAuthenticationOverdue: Ingest URL authentication expired. Provide a new URL to the SDK.
Error callbacks
-
onSystemError: System or device error. Dispose the engine and retry. -
onSDKError: Handle based on the error code:-
Error 805438211: Poor device performance with low encoding frame rate. Notify the streamer and stop resource-intensive operations such as advanced retouching.
-
Handle missing permission errors: 268455940 (microphone) and 268455939 (camera).
-
Log all other errors.
-
Background music callbacks
-
onOpenFailed: Background music failed to start. Verify the file path and format, then callstartBGMAsyncagain. -
onDownloadTimeout: Music playback timed out, typically when streaming from a URL. Check the network and callstartBGMAsyncagain.
Common methods and APIs
Common methods
/* In Custom mode, you can adjust the minimum and target bitrates in real time. */
mAlivcLivePusher.setTargetVideoBitrate(800);
mAlivcLivePusher.setMinVideoBitrate(400);
/* Check if the camera supports autofocus. */
mAlivcLivePusher.isCameraSupportAutoFocus();
/* Check if the camera supports flash. */
mAlivcLivePusher.isCameraSupportFlash();
/* Get the current stream ingest status. */
mAlivcLivePusher.isPushing();
/* Get the ingest URL. */
mAlivcLivePusher.getPushUrl();
/* Get stream ingest performance and debugging information. For details on performance parameters, see the API reference or interface comments. */
mAlivcLivePusher.getLivePushStatsInfo();
/* Get the SDK version number. */
mAlivcLivePusher.getSDKVersion();
/* Set the log level to filter debugging information as needed. */
mAlivcLivePusher.setLogLevel(AlivcLivePushLogLevelAll);
/* Get the current status of the SDK. */
mAlivcLivePusher.getCurrentStatus();
/* Get the last error code. Returns ALIVC_COMMON_RETURN_SUCCESS if there are no errors. */
mAlivcLivePusher.getLastError();
Common APIs
|
Class |
Description |
|
AlivcLivePushConfig |
Initial configuration for stream ingest. |
|
AlivcLivePusher |
Class for stream ingest features. |
|
AlivcLivePusherErrorListener |
Callback for errors. |
|
AlivcLivePusherNetworkListener |
Callback for network-related notifications. |
|
AlivcLivePusherInfoListener |
Callback for stream ingest information. |
|
AlivcLivePusherBGMListener |
Callback for background music. |
|
AlivcLivePushCustomFilter |
Callback for custom filters. |
|
AlivcLivePushCustomDetect |
Callback for custom facial recognition. |
|
AlivcSnapshotListener |
Callback for snapshots. |
Integrate retouching
Import the retouching library and configure callbacks to enable retouching.
Retouching requires a license for the retouching SDK. Obtain a license for Queen SDK.
-
Import the retouching library via Maven. Add the following to your
build.gradlefile. Check the latest Demo for the SDK version.implementation "com.aliyun.maliang.android:queen:2.5.0-official-full" implementation("com.aliyun.maliang.android:queen_menu:2.5.0-official-full") { exclude group: 'com.aliyun.maliang.android', module: 'queen' }You can also integrate the LiveBeauty module from the demo:
File or folder
Description
live_beauty
The base abstract class for retouching.
queen_beauty
Base UI controls for retouching.
-
Get the LiveBeauty retouching plug-in library.
-
Use the
clonecommand to download the related plugin library code from the LiveBeauty path to your local machine.git clone https://github.com/MediaBox-Demos/amdemos-android-live.git -
Open the command line in the root directory of your Android Studio project. Run the following code and then use
File > New > Import Moduleto import theLiveBeautymodule into your Android project.git submodule add https://github.com/MediaBox-Demos/amdemos-android-live.git ***/***/***NoteIn the example code, /*** is a placeholder for the path to the
LiveBeautymodule. -
In the project's
settings.gradlefile, add the module's path:include ':app', ':LiveBeauty', ':LiveBeauty:live_queenbeauty'NoteIn the example code, "app" is the main module.
-
Also, in the
build.gradlefile of the project's main module, add a dependency on theLiveBeautymodule:dependencies { implementation project(':LiveBeauty') implementation project(':LiveBeauty:live_queenbeauty') } -
Click
File > Sync Project with Gradle Files. After the Gradle sync is complete, you can use theLiveBeautymodule.
-
-
Configure the UI module of the retouching plug-in.
-
Add the
QueenBeautyMenucontrol to the layout XML file of your project. For example:<com.aliyunsdk.queen.menu.QueenBeautyMenu android:id="@+id/beauty_beauty_menuPanel" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> -
Initialize
QueenBeautyMenuin the Activity. For example:// Initialize the retouching menu panel. QueenMenuPanel beautyMenuPanel = QueenBeautyMenu.getPanel(context); beautyMenuPanel.onHideMenu(); beautyMenuPanel.onHideValidFeatures(); beautyMenuPanel.onHideCopyright(); // Add the retouching menu to the layout. QueenBeautyMenu beautyBeautyContainerView = findViewById(R.id.beauty_beauty_menuPanel); beautyBeautyContainerView.addView(beautyMenuPanel);
-
-
Set facial recognition and retouching callbacks.
If you need to integrate a third-party retouching library, set the
setCustomDetectandsetCustomFiltercallbacks.-
In
customDetectProcess, thedataparameter is a pointer to captured data for third-party processing. -
In
customFilterProcess, theinputTextureparameter is the image texture for processing. Return the processed texture ID, or the originalinputTextureif unmodified.
-
Usage notes
|
Item |
Description |
|
Obfuscation rules |
Add the SDK's package name to your ProGuard exclusion list to prevent obfuscation issues.
|
|
API call sequence |
|
FAQ
Why does stream ingest fail?
Use the troubleshooting tool to validate your ingest URL.
How can I get information about active streams?
View and manage active streams on the stream management page.
How do I test stream playback?
Test playback with an Alibaba Cloud player, FFplay, or VLC after starting ingest. Generate ingest and streaming URLs.