ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.23k stars 618 forks source link

Intergrate Deep AR into Ant Media Server (AMS) #4171

Open rainbowdrg opened 2 years ago

rainbowdrg commented 2 years ago

Hi,

I'm new in Android and JAVA and want to build a live streaming app with beauty & background segmentation & so on features by using Deep AR and add into Ant Media Server (AMS) by SDK here.

My thinking is Deep AR process the frames that captured by mobile's camera first then send to AMS. I refer Deep AR sample code here and here. If only Deep AR, it work well but got error when integrate with AMS.

App is opened and live is started but there is no effect on live streaming and crash within few seconds. I try found problem at logcat section but no clue because too many messages. Below are the code i tried but failed:

// code within MainActivity.onCreate()
// first initialise deep AR
deepar = new DeepAR(this);
deepar.setLicenseKey("xxxxxx"); // please get from Deep AR
deepar.initialize(this, this); // second param please implements AREventListener

setupCamera(); // just copy from Deep AR sample code

arView = findViewById(R.id.surface); // using SurfaceViewRenderer ready by AMS
arView.getHolder().addCallback(this); // 'this' must implements 'SurfaceHolder.Callback'

// here setup AMS webRTC, it won't work with Deep AR
// or Deep AR will work if remove these part
webRTCClient = new WebRTCClient(this, this); // please implements IWebRTCListener
webRTCClient.setOpenFrontCamera(lensFacing == CameraSelector.LENS_FACING_FRONT);
webRTCClient.setVideoRenderers(null, arView);
Intent intent = getIntent(); // please refer sample code to add putExtra()
webRTCClient.init("ws://AMS IP", "RandomString", IWebRTCClient.MODE_PUBLISH, "tokenId", intent);
webRTCClient.setDataChannelObserver(this);
new Handler(Looper.myLooper()).postDelayed(new Runnable() {
    @Override
    public void run() {
        attempt2Reconnect(); // please copy from AMS sample code
    }
}, 500);

Others important parts only, please copy all @Override method from sample code

@Override
public void initialized() {
    deepar.switchEffect("background", "file:///android_asset/background_segmentation"); // please download sample from Deep AR
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    deepar.setRenderSurface(holder.getSurface(), width, height);
}

Did anyone success to integrate AMS with Deep AR? Or any other recommended SDK which have same features and work with AMS also can(depends on price).

Thanks.

SelimEmre commented 1 year ago

Hi @rainbowdrg,

I'm trying to integrate DeepAR too. Let's check it together. When are you available?

Best Regards, Selim

SelimEmre commented 1 year ago

Hi @rainbowdrg,

I just wanted to follow up with you. Did you see my message?

Best Regards, Selim

rainbowdrg commented 1 year ago

Hi @SelimEmre

Sorry for the late reply. I'm looking for another solutions now because Ant Media Server for Android cannot receive external frames from third part SDK now. You may see here and here. For now, I'm start trying the Agora which has built in the features we need.

Thanks.