Search in sources :

Example 1 with RealmIceServer

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;
}
Also used : PeerConnection(org.webrtc.PeerConnection) MediaConstraints(org.webrtc.MediaConstraints) RealmCallConfig(net.iGap.realm.RealmCallConfig) ArrayList(java.util.ArrayList) RealmIceServer(net.iGap.realm.RealmIceServer) RealmIceServer(net.iGap.realm.RealmIceServer)

Aggregations

ArrayList (java.util.ArrayList)1 RealmCallConfig (net.iGap.realm.RealmCallConfig)1 RealmIceServer (net.iGap.realm.RealmIceServer)1 MediaConstraints (org.webrtc.MediaConstraints)1 PeerConnection (org.webrtc.PeerConnection)1