Beauty function
Some users have proposed to access the beauty function when using the SDK, so we have added the interface of this beauty function.
We provide the captured video fata to the user by the delegate function.
The user can take the video data to do the beauty, and then backfill the data into the SDK after the beauty.
Firstly we need to create a new class DemoVideoSourceCallback, which inherits from com.starrtc.starrtcsdk.core.videosrc.XHVideoSourceCallback, and override the onVideoFrame and onAudioFrame methods.
Secondly, “onVideoFram” function will receive the video data captured by the camera. “onAudioFrame” function will receive the audio data captured by the SDK. And the user can take the data for processing, then return the processed data through the “backfillData” function.
Note: The video data format obtained from the “onFrame” method is NV12., the Processed data returned to the SDK also need to be the NV12 format. The important thing is said three times!
Note: The video data format obtained from the “onFrame” method is NV12., the Processed data returned to the SDK is also in NV12 format. The important thing is said three times!
Note: The video data format obtained from the “onFrame” method is NV12., the Processed data returned to the SDK also need to be the NV12 format. The important thing is said three times!public class DemoVideoSourceCallback extends XHVideoSourceCallback {
public StarVideoData onVideoFrame(StarVideoData videoData){
MLOC.d("DemoVideoSourceCallback","The video source data has been received, not processed, and then thrown back directly"+videoData.getDataLength());
//The data in videoData can be processed directly, and the videoData object can be returned after processing.
return videoData;
}
public StarAudioData onAudioFrame(StarAudioData audioData){
MLOC.d("DemoVideoSourceCallback","The audio source data has been received, not processed, and then thrown back directly"+audioData.getDataLength());
//The data in the audioData can be processed directly, and the audioData object can be returned after processing.
return audioData;
}
}
How to use this DemoVideoSourceCallback?
It’s easy! Just execute the following code after initializing the sdk.XHBeautyManager.getInstance().setVideoSourceCallback(new DemoVideoSourceCallback());