I am using the below dependency of webrtc in my Android App
implementation 'org.webrtc:google-webrtc:1.0.+'
How to Initialize PeerConnectionFactory, I am doing it in below manner but it is giving compilation error.
private void initializePeerConnectionFactory() {
PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);
factory = new PeerConnectionFactory(null);
factory.setVideoHwAccelerationOptions(rootEglBase.getEglBaseContext(), rootEglBase.getEglBaseContext());
}
I tried it with below fashion:
private void initializePeerConnectionFactory() {
PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);
factory = new PeerConnectionFactory(null);
factory.setVideoHwAccelerationOptions(rootEglBase.getEglBaseContext(), rootEglBase.getEglBaseContext());
}
But it’s not working
2
Answers
As of today (25 Jan 2023), use the latest version of the dependency.
As the older ones had security vulnerabilities and google play does not accept them.
You can initialize PeerConnectionFactory like this:
https://webrtc.googlesource.com/src/+/refs/heads/main/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java?autodive=0%2F%2F
Using
which I believe to be the latest version of webrtc available
you initialise the peer connection factory using the following code
Hope this helps!