private static void shutdownPC(PeerConnection pc, ObserverExpectations expectations) { if (expectations.dataChannel != null) { expectations.dataChannel.unregisterObserver(); expectations.dataChannel.dispose(); } expectations.expectStatsCallback(); assertTrue(pc.getStats(expectations, null)); assertTrue(expectations.waitForAllExpectationsToBeSatisfied(TIMEOUT_SECONDS)); expectations.expectIceConnectionChange(IceConnectionState.CLOSED); expectations.expectSignalingChange(SignalingState.CLOSED); pc.close(); assertTrue(expectations.waitForAllExpectationsToBeSatisfied(TIMEOUT_SECONDS)); expectations.expectStatsCallback(); assertTrue(pc.getStats(expectations, null)); assertTrue(expectations.waitForAllExpectationsToBeSatisfied(TIMEOUT_SECONDS)); System.out.println("FYI stats: "); int reportIndex = -1; for (StatsReport[] reports : expectations.takeStatsReports()) { System.out.println(" Report #" + (++reportIndex)); for (int i = 0; i < reports.length; ++i) { System.out.println(" " + reports[i].toString()); } } assertEquals(1, reportIndex); System.out.println("End stats."); pc.dispose(); }
public synchronized void expectSignalingChange(SignalingState newState) { expectedSignalingChanges.add(newState); }
@Override public synchronized void onSignalingChange(SignalingState newState) { assertEquals(expectedSignalingChanges.removeFirst(), newState); }
private static void negotiate(PeerConnection offeringPC, ObserverExpectations offeringExpectations, PeerConnection answeringPC, ObserverExpectations answeringExpectations) { // Create offer. SdpObserverLatch sdpLatch = new SdpObserverLatch(); offeringPC.createOffer(sdpLatch, new MediaConstraints()); assertTrue(sdpLatch.await()); SessionDescription offerSdp = sdpLatch.getSdp(); assertEquals(offerSdp.type, SessionDescription.Type.OFFER); assertFalse(offerSdp.description.isEmpty()); // Set local description for offerer. sdpLatch = new SdpObserverLatch(); offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER); offeringPC.setLocalDescription(sdpLatch, offerSdp); assertTrue(sdpLatch.await()); assertNull(sdpLatch.getSdp()); // Set remote description for answerer. sdpLatch = new SdpObserverLatch(); answeringExpectations.expectSignalingChange(SignalingState.HAVE_REMOTE_OFFER); answeringPC.setRemoteDescription(sdpLatch, offerSdp); assertTrue(sdpLatch.await()); assertNull(sdpLatch.getSdp()); // Create answer. sdpLatch = new SdpObserverLatch(); answeringPC.createAnswer(sdpLatch, new MediaConstraints()); assertTrue(sdpLatch.await()); SessionDescription answerSdp = sdpLatch.getSdp(); assertEquals(answerSdp.type, SessionDescription.Type.ANSWER); assertFalse(answerSdp.description.isEmpty()); // Set local description for answerer. sdpLatch = new SdpObserverLatch(); answeringExpectations.expectSignalingChange(SignalingState.STABLE); answeringPC.setLocalDescription(sdpLatch, answerSdp); assertTrue(sdpLatch.await()); assertNull(sdpLatch.getSdp()); // Set remote description for offerer. sdpLatch = new SdpObserverLatch(); offeringExpectations.expectSignalingChange(SignalingState.STABLE); offeringPC.setRemoteDescription(sdpLatch, answerSdp); assertTrue(sdpLatch.await()); assertNull(sdpLatch.getSdp()); }
@Override public synchronized void onSignalingChange(SignalingState newState) { System.out.println("DEBUG: SIGNAL CHANGE"); }
@Override public void onSignalingChange(SignalingState arg0) { }
public void onSignalingChange(SignalingState signalingState) {}