org.webrtc.PeerConnection Java Examples

The following examples show how to use org.webrtc.PeerConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LicodeConnector.java    From licodeAndroidClient with MIT License 6 votes vote down vote up
void doSubscribe(final StreamDescription stream) {
	if (stream.isLocal()) {
		return;
	}

	if (stream.getMedia() != null) {
		// already subscribed!
		triggerMediaAvailable(stream);
		return;
	}

	// Uncomment to get ALL WebRTC tracing and SENSITIVE libjingle logging.
	// NOTE: this _must_ happen while |factory| is alive!
	// Logging.enableTracing("logcat:",
	// EnumSet.of(Logging.TraceLevel.TRACE_ALL),
	// Logging.Severity.LS_SENSITIVE);

	MyPcObserver pcObs = new MyPcObserver(new LicodeSdpObserver(stream,
			false), stream);
	PeerConnection pc = sFactory.createPeerConnection(mIceServers,
			makePcConstraints(), pcObs);

	stream.initRemote(pc, pcObs.getSdpObserver());
}
 
Example #2
Source File: AppRTCClient.java    From WebRTCDemo with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(
    String pcConfig) {
  try {
    JSONObject json = new JSONObject(pcConfig);
    JSONArray servers = json.getJSONArray("iceServers");
    LinkedList<PeerConnection.IceServer> ret =
        new LinkedList<PeerConnection.IceServer>();
    for (int i = 0; i < servers.length(); ++i) {
      JSONObject server = servers.getJSONObject(i);
      String url = server.getString("urls");
      String credential =
          server.has("credential") ? server.getString("credential") : "";
      ret.add(new PeerConnection.IceServer(url, "", credential));
    }
    return ret;
  } catch (JSONException e) {
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: PeerConnectionClient.java    From voip_android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
    executor.execute(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "IceConnectionState: " + newState);
            if (newState == IceConnectionState.CONNECTED) {
                events.onIceConnected();
            } else if (newState == IceConnectionState.DISCONNECTED) {
                events.onIceDisconnected();
            } else if (newState == IceConnectionState.FAILED) {
                reportError("ICE connection failed.");
            }
        }
    });
}
 
Example #4
Source File: PeerConnectionClient.java    From sample-videoRTC with Apache License 2.0 6 votes vote down vote up
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
  executor.execute(new Runnable() {
    @Override
    public void run() {
      Log.d(TAG, "IceConnectionState: " + newState);
      if (newState == IceConnectionState.CONNECTED) {
        events.onIceConnected();
      } else if (newState == IceConnectionState.DISCONNECTED) {
        events.onIceDisconnected();
      } else if (newState == IceConnectionState.FAILED) {
        reportError("ICE connection failed.");
      }
    }
  });
}
 
Example #5
Source File: WebRTCEngine.java    From webrtc_android with MIT License 6 votes vote down vote up
private void initIceServer() {
    // 初始化一些stun和turn的地址
    PeerConnection.IceServer var1 = PeerConnection.IceServer.builder("stun:stun.l.google.com:19302")
            .createIceServer();
    iceServers.add(var1);


    PeerConnection.IceServer var11 = PeerConnection.IceServer.builder("stun:47.93.186.97:3478?transport=udp")
            .createIceServer();
    PeerConnection.IceServer var12 = PeerConnection.IceServer.builder("turn:47.93.186.97:3478?transport=udp")
            .setUsername("ddssingsong")
            .setPassword("123456")
            .createIceServer();
    PeerConnection.IceServer var13 = PeerConnection.IceServer.builder("turn:47.93.186.97:3478?transport=tcp")
            .setUsername("ddssingsong")
            .setPassword("123456")
            .createIceServer();
    iceServers.add(var11);
    iceServers.add(var12);
    iceServers.add(var13);
}
 
Example #6
Source File: PeerConnectionClient.java    From janus-gateway-android with MIT License 6 votes vote down vote up
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
  executor.execute(new Runnable() {
    @Override
    public void run() {
      Log.d(TAG, "IceConnectionState: " + newState);
      if (newState == IceConnectionState.CONNECTED) {
        events.onIceConnected();
      } else if (newState == IceConnectionState.DISCONNECTED) {
        events.onIceDisconnected();
      } else if (newState == IceConnectionState.FAILED) {
        reportError("ICE connection failed.");
      }
    }
  });
}
 
Example #7
Source File: PeersManager.java    From WebRTCapp with Apache License 2.0 6 votes vote down vote up
private void createLocalPeerConnection(MediaConstraints sdpConstraints) {
    final List<PeerConnection.IceServer> iceServers = new ArrayList<>();
    PeerConnection.IceServer iceServer = new PeerConnection.IceServer("stun:stun.l.google.com:19302");
    iceServers.add(iceServer);

    localPeer = peerConnectionFactory.createPeerConnection(iceServers, sdpConstraints, new CustomPeerConnectionObserver("localPeerCreation") {
        @Override
        public void onIceCandidate(IceCandidate iceCandidate) {
            super.onIceCandidate(iceCandidate);
            Map<String, String> iceCandidateParams = new HashMap<>();
            iceCandidateParams.put("sdpMid", iceCandidate.sdpMid);
            iceCandidateParams.put("sdpMLineIndex", Integer.toString(iceCandidate.sdpMLineIndex));
            iceCandidateParams.put("candidate", iceCandidate.sdp);
            if (webSocketAdapter.getUserId() != null) {
                iceCandidateParams.put("endpointName", webSocketAdapter.getUserId());
                webSocketAdapter.sendJson(webSocket, "onIceCandidate", iceCandidateParams);
            } else {
                webSocketAdapter.addIceCandidate(iceCandidateParams);
            }
        }
    });
}
 
Example #8
Source File: MainActivity.java    From webrtc-android-tutorial with Apache License 2.0 6 votes vote down vote up
@Override
public void onOfferReceived(JSONObject data) {
    runOnUiThread(() -> {
        final String socketId = data.optString("from");
        PeerConnection peerConnection = getOrCreatePeerConnection(socketId);
        peerConnection.setRemoteDescription(new SdpAdapter("setRemoteSdp:" + socketId),
                new SessionDescription(SessionDescription.Type.OFFER, data.optString("sdp")));
        peerConnection.createAnswer(new SdpAdapter("localAnswerSdp") {
            @Override
            public void onCreateSuccess(SessionDescription sdp) {
                super.onCreateSuccess(sdp);
                peerConnectionMap.get(socketId).setLocalDescription(new SdpAdapter("setLocalSdp:" + socketId), sdp);
                SignalingClient.get().sendSessionDescription(sdp, socketId);
            }
        }, new MediaConstraints());

    });
}
 
Example #9
Source File: PeerConnectionClient.java    From janus-gateway-android with MIT License 6 votes vote down vote up
private void createPeerConnectionInternal(EglBase.Context renderEGLContext, BigInteger handleId) {
  if (factory == null || isError) {
    Log.e(TAG, "Peerconnection factory is not created");
    return;
  }

  Log.d(TAG, "PCConstraints: " + pcConstraints.toString());

  Log.d(TAG, "EGLContext: " + renderEGLContext);
  factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext);

  PeerConnection peerConnection = createPeerConnection(handleId, true);

  mediaStream = factory.createLocalMediaStream("ARDAMS");
  mediaStream.addTrack(createVideoTrack(videoCapturer));

  mediaStream.addTrack(createAudioTrack());
  peerConnection.addStream(mediaStream);
  findVideoSender(handleId);
}
 
Example #10
Source File: SignalingParameters.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
public SignalingParameters(
      List<PeerConnection.IceServer> iceServers,
      boolean initiator,
      String clientId,
      String sipUrl,
      String wssPostUrl,
      SessionDescription offerSdp,
      List<IceCandidate> iceCandidates,
      HashMap<String, String> sipHeaders,
      boolean videoEnabled)
{
   this.iceServers = iceServers;
   this.initiator = initiator;
   this.clientId = clientId;
   this.sipUrl = sipUrl;
   this.wssPostUrl = wssPostUrl;
   this.offerSdp = offerSdp;
   this.answerSdp = null;
   this.iceCandidates = iceCandidates;
   this.sipHeaders = sipHeaders;
   this.videoEnabled = videoEnabled;
   //this.answerIceCandidates = null;
}
 
Example #11
Source File: PeerConnectionChannel.java    From owt-client-android with Apache License 2.0 6 votes vote down vote up
private void addOrQueueCandidate(final IceCandidate iceCandidate) {
    if (disposed()) {
        return;
    }
    DCHECK(pcExecutor);
    DCHECK(iceCandidate);
    pcExecutor.execute(() -> {
        if (disposed()) {
            return;
        }
        if (peerConnection.signalingState() == PeerConnection.SignalingState.STABLE) {
            Log.d(LOG_TAG, "add ice candidate");
            peerConnection.addIceCandidate(iceCandidate);
        } else {
            synchronized (remoteIceLock) {
                Log.d(LOG_TAG, "queue ice candidate");
                queuedRemoteCandidates.add(iceCandidate);
            }
        }
    });
}
 
Example #12
Source File: AppRTCClient.java    From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(
    String pcConfig) {
  try {
    JSONObject json = new JSONObject(pcConfig);
    JSONArray servers = json.getJSONArray("iceServers");
    LinkedList<PeerConnection.IceServer> ret =
        new LinkedList<PeerConnection.IceServer>();
    for (int i = 0; i < servers.length(); ++i) {
      JSONObject server = servers.getJSONObject(i);
      String url = server.getString("urls");
      String credential =
          server.has("credential") ? server.getString("credential") : "";
      ret.add(new PeerConnection.IceServer(url, "", credential));
    }
    return ret;
  } catch (JSONException e) {
    throw new RuntimeException(e);
  }
}
 
Example #13
Source File: PeerConnectionClient.java    From janus-gateway-android with MIT License 6 votes vote down vote up
private PeerConnection createPeerConnection(BigInteger handleId, boolean type) {
  Log.d(TAG, "Create peer connection.");
  PeerConnection.IceServer iceServer = new PeerConnection.IceServer("turn:xxx.xxx.xx.xx:xxx", "ling", "ling1234");
  List<PeerConnection.IceServer> iceServers = new ArrayList<>();
  iceServers.add(iceServer);
  PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers);
  rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.RELAY;

  PCObserver pcObserver = new PCObserver();
  SDPObserver sdpObserver = new SDPObserver();
  PeerConnection peerConnection = factory.createPeerConnection(rtcConfig, pcConstraints, pcObserver);

  JanusConnection janusConnection = new JanusConnection();
  janusConnection.handleId = handleId;
  janusConnection.sdpObserver = sdpObserver;
  janusConnection.peerConnection = peerConnection;
  janusConnection.type = type;

  peerConnectionMap.put(handleId, janusConnection);
  pcObserver.setConnection(janusConnection);
  sdpObserver.setConnection(janusConnection);
  Log.d(TAG, "Peer connection created.");
  return peerConnection;
}
 
Example #14
Source File: JingleRtpConnection.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
    Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed to " + newState);
    if (newState == PeerConnection.PeerConnectionState.CONNECTED && this.rtpConnectionStarted == 0) {
        this.rtpConnectionStarted = SystemClock.elapsedRealtime();
    }
    if (newState == PeerConnection.PeerConnectionState.CLOSED && this.rtpConnectionEnded == 0) {
        this.rtpConnectionEnded = SystemClock.elapsedRealtime();
    }
    //TODO 'DISCONNECTED' might be an opportunity to renew the offer and send a transport-replace
    //TODO exact syntax is yet to be determined but transport-replace sounds like the most reasonable
    //as there is no content-replace
    if (Arrays.asList(PeerConnection.PeerConnectionState.FAILED, PeerConnection.PeerConnectionState.DISCONNECTED).contains(newState)) {
        if (isTerminated()) {
            Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not sending session-terminate after connectivity error because session is already in state " + this.state);
            return;
        }
        new Thread(this::closeWebRTCSessionAfterFailedConnection).start();
    } else {
        updateEndUserState();
    }
}
 
Example #15
Source File: PeerConnectionChannel.java    From owt-client-android with Apache License 2.0 6 votes vote down vote up
protected PeerConnectionChannel(String key, PeerConnection.RTCConfiguration configuration,
        boolean receiveVideo, boolean receiveAudio, PeerConnectionChannelObserver observer) {
    this.key = key;
    this.observer = observer;

    videoRtpSenders = new ConcurrentHashMap<>();
    audioRtpSenders = new ConcurrentHashMap<>();
    queuedRemoteCandidates = new LinkedList<>();
    queuedMessage = new ArrayList<>();
    sdpConstraints = new MediaConstraints();
    sdpConstraints.mandatory.add(
            new KeyValuePair("OfferToReceiveAudio", String.valueOf(receiveAudio)));
    sdpConstraints.mandatory.add(
            new KeyValuePair("OfferToReceiveVideo", String.valueOf(receiveVideo)));
    peerConnection = PCFactoryProxy.instance().createPeerConnection(configuration, this);
    RCHECK(peerConnection);
    signalingState = peerConnection.signalingState();
}
 
Example #16
Source File: WebRTCWrapper.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
private PeerConnection requirePeerConnection() {
    final PeerConnection peerConnection = this.peerConnection;
    if (peerConnection == null) {
        throw new IllegalStateException("initialize PeerConnection first");
    }
    return peerConnection;
}
 
Example #17
Source File: JingleRtpConnection.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
private void setupWebRTC(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException {
    this.jingleConnectionManager.ensureConnectionIsRegistered(this);
    final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference;
    if (media.contains(Media.VIDEO)) {
        speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.SPEAKER;
    } else {
        speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.EARPIECE;
    }
    this.webRTCWrapper.setup(this.xmppConnectionService, speakerPhonePreference);
    this.webRTCWrapper.initializePeerConnection(media, iceServers);
}
 
Example #18
Source File: PnSignalingParams.java    From AndroidRTC with MIT License 5 votes vote down vote up
/**
 * Append default servers to the end of given list and set as iceServers instance variable
 * @param iceServers List of iceServers
 */
public void addIceServers(List<PeerConnection.IceServer> iceServers){
    if(this.iceServers!=null) {
        iceServers.addAll(this.iceServers);
    }
    this.iceServers = iceServers;
}
 
Example #19
Source File: PnPeerConnectionClient.java    From AndroidRTC with MIT License 5 votes vote down vote up
public void execute(String peerId, JSONObject payload) throws JSONException {
    Log.d("AICAction","AddIceCandidateAction");
    PeerConnection pc = peers.get(peerId).pc;
    if (pc.getRemoteDescription() != null) {
        IceCandidate candidate = new IceCandidate(
                payload.getString("sdpMid"),
                payload.getInt("sdpMLineIndex"),
                payload.getString("candidate")
        );
        pc.addIceCandidate(candidate);
    }
}
 
Example #20
Source File: RespokeDirectConnection.java    From respoke-sdk-android with MIT License 5 votes vote down vote up
/**
 *  Establish a new direct connection instance with the peer connection for the call. This is used internally to the SDK and should not be called directly by your client application.
 */
public void createDataChannel() {
    if (null != callReference) {
        RespokeCall call = callReference.get();
        if (null != call) {
            PeerConnection peerConnection = call.getPeerConnection();
            dataChannel = peerConnection.createDataChannel("respokeDataChannel", new DataChannel.Init());
            dataChannel.registerObserver(this);
        }
    }
}
 
Example #21
Source File: AppRTCDemoActivity.java    From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void createDataChannelToRegressionTestBug2302(
    PeerConnection pc) {
  DataChannel dc = pc.createDataChannel("dcLabel", new DataChannel.Init());
  abortUnless("dcLabel".equals(dc.label()), "Unexpected label corruption?");
  dc.close();
  dc.dispose();
}
 
Example #22
Source File: PeerConnectionResourceManager.java    From webrtcpeer-android with Apache License 2.0 5 votes vote down vote up
NBMPeerConnection createPeerConnection( SignalingParameters signalingParameters,
                                        MediaConstraints pcConstraints,
                                        String connectionId) {

    Log.d(TAG, "Create peer connection.");
    Log.d(TAG, "PCConstraints: " + pcConstraints.toString());

    // TCP candidates are only useful when connecting to a server that supports ICE-TCP.
    PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(signalingParameters.iceServers);
    rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED;
    rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
    rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
    rtcConfig.keyType = PeerConnection.KeyType.ECDSA;
    //rtcConfig.iceServers IceServer
    NBMPeerConnection connectionWrapper = new NBMPeerConnection(connectionId, preferIsac, videoCallEnabled, preferH264, executor, peerConnectionParameters);
    PeerConnection peerConnection = factory.createPeerConnection(rtcConfig, pcConstraints, connectionWrapper);

    connectionWrapper.setPc(peerConnection);
    connections.put(connectionId, connectionWrapper);

    // Set default WebRTC tracing and INFO libjingle logging.
    // NOTE: this _must_ happen while |factory| is alive!
    Logging.enableTracing("logcat:", EnumSet.of(Logging.TraceLevel.TRACE_DEFAULT), Logging.Severity.LS_INFO);

    Log.d(TAG, "Peer connection created.");
    return connectionWrapper;
}
 
Example #23
Source File: WebRtcCallService.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private ListenableFutureTask<List<PeerConnection.IceServer>> retrieveTurnServers() {
    Callable<List<PeerConnection.IceServer>> callable = () -> {
        LinkedList<PeerConnection.IceServer> results = new LinkedList<>();

        try {
            TurnServerInfo turnServerInfo = ChatHttp.INSTANCE.get(WebRtcCallService.accountContext).getTurnServerInfo();

            for (String url : turnServerInfo.getUrls()) {
                if (url.startsWith("turn")) {
                    results.add(new PeerConnection.IceServer(url, turnServerInfo.getUsername(), turnServerInfo.getPassword()));
                } else {
                    results.add(new PeerConnection.IceServer(url));
                }
            }

        } catch (Exception e) {
            ALog.logForSecret(TAG, "retrieveTurnServers error", e);
        }

        return results;
    };

    ListenableFutureTask<List<PeerConnection.IceServer>> futureTask = new ListenableFutureTask<>(callable, null, serviceExecutor);
    networkExecutor.execute(futureTask);

    return futureTask;
}
 
Example #24
Source File: VideoChatHelper.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
private void addStream() {

        for (Map.Entry<String, Peer> entry : peers.entrySet()) {

            Peer peer = entry.getValue();
            PeerConnection connection = peer.pc;

            if (localMediaStream == null) {
                FLLog.i("添加本地流时,本地流为空");
            } else {

                connection.addStream(localMediaStream);
            }
        }
    }
 
Example #25
Source File: CallActivity.java    From RTCStartupDemo with GNU General Public License v3.0 5 votes vote down vote up
public PeerConnection createPeerConnection() {
    Log.i(TAG, "Create PeerConnection ...");
    PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(new ArrayList<>());
    PeerConnection connection = mPeerConnectionFactory.createPeerConnection(configuration, mPeerConnectionObserver);
    if (connection == null) {
        Log.e(TAG, "Failed to createPeerConnection !");
        return null;
    }
    connection.addTrack(mVideoTrack);
    connection.addTrack(mAudioTrack);
    return connection;
}
 
Example #26
Source File: PnSignalingParams.java    From AndroidRTC with MIT License 5 votes vote down vote up
/**
     * Default media params, but specified Ice Servers
     * @param iceServers
     */
    public PnSignalingParams(List<PeerConnection.IceServer> iceServers) {
        this.iceServers       = iceServers; //defaultIceServers();
        this.pcConstraints    = defaultPcConstraints();
        this.videoConstraints = defaultVideoConstraints();
        this.audioConstraints = defaultAudioConstraints();
//        addIceServers(iceServers);
    }
 
Example #27
Source File: PnSignalingParams.java    From AndroidRTC with MIT License 5 votes vote down vote up
public static List<PeerConnection.IceServer> defaultIceServers(){
    List<PeerConnection.IceServer> iceServers = new ArrayList<PeerConnection.IceServer>(25);
    iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.services.mozilla.com"));
    iceServers.add(new PeerConnection.IceServer("turn:turn.bistri.com:80", "homeo", "homeo"));
    iceServers.add(new PeerConnection.IceServer("turn:turn.anyfirewall.com:443?transport=tcp", "webrtc", "webrtc"));

    // Extra Defaults - 19 STUN servers + 4 initial = 23 severs (+2 padding) = Array cap 25
    iceServers.add(new PeerConnection.IceServer("stun:stun1.l.google.com:19302"));
    iceServers.add(new PeerConnection.IceServer("stun:stun2.l.google.com:19302"));
    iceServers.add(new PeerConnection.IceServer("stun:stun3.l.google.com:19302"));
    iceServers.add(new PeerConnection.IceServer("stun:stun4.l.google.com:19302"));
    iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
    iceServers.add(new PeerConnection.IceServer("stun:stun01.sipphone.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.ekiga.net"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.fwdnet.net"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.ideasip.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.iptel.org"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.rixtelecom.se"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.schlund.de"));
    iceServers.add(new PeerConnection.IceServer("stun:stunserver.org"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.softjoys.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.voiparound.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.voipbuster.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.voipstunt.com"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.voxgratia.org"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.xten.com"));

    return iceServers;
}
 
Example #28
Source File: VideoChatHelper.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
/**
 * 关闭peerConnection
 *
 * @param connectionId 连接id
 */
private void closePeerConnection(String connectionId) {

    Peer peer = peers.get(connectionId);
    PeerConnection connection = peer.pc;
    if (connection != null) {
        connection.close();
    }
    peers.remove(connectionId);

    callBack.onCloseWithUserId(connectionId);

}
 
Example #29
Source File: WebRTCWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Nonnull
private ListenableFuture<PeerConnection> getPeerConnectionFuture() {
    final PeerConnection peerConnection = this.peerConnection;
    if (peerConnection == null) {
        return Futures.immediateFailedFuture(new IllegalStateException("initialize PeerConnection first"));
    } else {
        return Futures.immediateFuture(peerConnection);
    }
}
 
Example #30
Source File: StreamDescription.java    From licodeAndroidClient with MIT License 5 votes vote down vote up
public void initRemote(PeerConnection pc, SdpObserver sdpObserver) {
	mLocal = false;
	mState = StreamState.OPENING;
	this.pc = pc;
	mSdpConstraints = new MediaConstraints();
	mSdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
			"OfferToReceiveAudio", "true"));
	mSdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
			"OfferToReceiveVideo", "true"));
	pc.createOffer(sdpObserver, mSdpConstraints);
}