Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with Ant Media Server (AMS) #37

Closed
rainbowdrg opened this issue May 5, 2022 · 1 comment
Closed

Integrate with Ant Media Server (AMS) #37

rainbowdrg opened this issue May 5, 2022 · 1 comment

Comments

@rainbowdrg
Copy link

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. I already subscribe Ant Media Server(AMS) as live streaming server and it work by refer their sample code and sdk here without Deep AR.

Now, I wish to integrate Deep AR into AMS. I has also refer another sample code here but doesn't work.

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); // first param 'this' must 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); // 'this' must implements IDataChannelObserver
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 Deep AR into AMS? Please help. Another sample code got using Agora as media server but it is too expensive and I wish to self host server.

Thanks.

@JelenaKB
Copy link
Contributor

JelenaKB commented Aug 9, 2022

DeepAR can be integrated with video call APIs, you can use the Agora example as a reference for how the workflow goes.

The idea is to use DeepAR's output as an input to the video call stream, instead of the regular live camera feed.

We don't have a tutorial for your specific API but this approach should work

@JelenaKB JelenaKB closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants