devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

How to start a video call programmatically #19

Closed meeeee12 closed 2 years ago

meeeee12 commented 3 years ago

I am confused how to start a video call from code. It seems I need to call PeerConnectionService login(), but where do I get the peerConnectionService instance from?

devopvoid commented 2 years ago

Hi @meeeee12, it depends on what your plans are. You want to start a video call to the AppRTC video chat app? For this you can examine the demo code, e.g. starting from here: https://github.com/devopvoid/webrtc-java/blob/9bf8169b2d93c694b14a1529c1968598bf0a440c/webrtc-demo/webrtc-demo-api/src/main/java/dev/onvoid/webrtc/demo/presenter/StartPresenter.java#L63

The PeerConnectionService is a @Singleton and gets injected into the constructor.

The demo code only establishes video calls to the AppRTC video chat app. The PeerConnectionService is part of that demo code. If you are planinng to use your own WebRTC service, you need to implement your own logic around the RTCPeerConnection, though the demo code can be re-used. For this, I think it's a good start to go through the basic test cases of the core Java WebRTC API here.