use of net.iGap.realm.RealmIceServer in project iGap-Android by KianIranian-STDG.
the class WebRTC method peerConnectionInstance.
public PeerConnection peerConnectionInstance() {
if (peerConnection == null) {
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
DbManager.getInstance().doRealmTask(realm -> {
RealmCallConfig realmCallConfig = realm.where(RealmCallConfig.class).findFirst();
for (RealmIceServer ice : realmCallConfig.getIceServer()) {
iceServers.add(new PeerConnection.IceServer(ice.getUrl(), ice.getUsername(), ice.getCredential()));
}
});
PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers);
configuration.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
configuration.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
configuration.iceTransportsType = PeerConnection.IceTransportsType.RELAY;
PeerConnection.Observer observer = new PeerConnectionObserver();
MediaConstraints mediaConstraints = mediaConstraintsGetInstance();
peerConnection = peerConnectionFactoryInstance().createPeerConnection(iceServers, mediaConstraints, observer);
mediaStream = peerConnectionFactoryInstance().createLocalMediaStream("ARDAMS");
addAudioTrack(mediaStream);
addVideoTrack(mediaStream);
peerConnection.addStream(mediaStream);
}
return peerConnection;
}
Aggregations