org.kurento.client.HubPort Java Examples

The following examples show how to use org.kurento.client.HubPort. 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: CompositeWrapper.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public void connectPublisherEndpoint(PublisherEndpoint endpoint) throws OpenViduException {
	HubPort hubPort = new HubPort.Builder(composite).build();
	endpoint.connect(hubPort);
	String streamId = endpoint.getOwner().getPublisherStreamId();
	this.hubPorts.put(streamId, hubPort);
	this.publisherEndpoints.put(streamId, endpoint);

	if (isRecording.compareAndSet(false, true)) {
		// First user publishing. Starting RecorderEndpoint

		log.info("First stream ({}) joined to Composite in session {}. Starting RecorderEndpoint for Composite",
				streamId, session.getSessionId());

		final CountDownLatch startLatch = new CountDownLatch(1);
		this.startCompositeRecording(startLatch);
		try {
			if (!startLatch.await(5, TimeUnit.SECONDS)) {
				log.error("Error waiting for RecorderEndpoint of Composite to start in session {}",
						session.getSessionId());
				throw new OpenViduException(Code.RECORDING_START_ERROR_CODE,
						"Couldn't initialize RecorderEndpoint of Composite");
			}
			log.info("RecorderEnpoint of Composite is now recording for session {}", session.getSessionId());
		} catch (InterruptedException e) {
			log.error("Exception while waiting for state change", e);
		}
	}

	log.info("Composite for session {} has now {} connected publishers", this.session.getSessionId(),
			this.composite.getChildren().size() - 1);
}
 
Example #2
Source File: CompositeWrapper.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public void disconnectPublisherEndpoint(String streamId) {
	HubPort hubPort = this.hubPorts.remove(streamId);
	PublisherEndpoint publisherEndpoint = this.publisherEndpoints.remove(streamId);
	publisherEndpoint.disconnectFrom(hubPort);
	hubPort.release();
	log.info("Composite for session {} has now {} connected publishers", this.session.getSessionId(),
			this.composite.getChildren().size() - 1);
}
 
Example #3
Source File: CompositeWrapper.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public void disconnectAllPublisherEndpoints() {
	this.publisherEndpoints.keySet().forEach(streamId -> {
		PublisherEndpoint endpoint = this.publisherEndpoints.get(streamId);
		HubPort hubPort = this.hubPorts.get(streamId);
		endpoint.disconnectFrom(hubPort);
		hubPort.release();
	});
	this.hubPorts.clear();
	this.publisherEndpoints.clear();
	this.composite.release();
}
 
Example #4
Source File: CompositeWrapper.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public CompositeWrapper(KurentoSession session, String path) {
	this.session = session;
	this.composite = new Composite.Builder(session.getPipeline()).build();
	this.recorderEndpoint = new RecorderEndpoint.Builder(composite.getMediaPipeline(), path)
			.withMediaProfile(MediaProfileSpecType.WEBM_AUDIO_ONLY).build();
	this.compositeToRecorderHubPort = new HubPort.Builder(composite).build();
	this.compositeToRecorderHubPort.connect(recorderEndpoint);
}
 
Example #5
Source File: CompositeWebRtcRecorderTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompositeRecorder() throws Exception {

  // MediaPipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  Composite composite = new Composite.Builder(mp).build();

  HubPort hubPort1 = new HubPort.Builder(composite).build();
  WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
  webRtcEpRed.connect(hubPort1);

  HubPort hubPort2 = new HubPort.Builder(composite).build();
  WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build();
  webRtcEpGreen.connect(hubPort2, MediaType.AUDIO);

  HubPort hubPort3 = new HubPort.Builder(composite).build();
  WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build();
  webRtcEpBlue.connect(hubPort3, MediaType.AUDIO);

  HubPort hubPort4 = new HubPort.Builder(composite).build();
  WebRtcEndpoint webRtcEpWhite = new WebRtcEndpoint.Builder(mp).build();
  webRtcEpWhite.connect(hubPort4, MediaType.AUDIO);

  String recordingFile = getDefaultOutputFile(EXTENSION_WEBM);
  RecorderEndpoint recorderEp =
      new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build();
  HubPort hubPort5 = new HubPort.Builder(composite).build();
  hubPort5.connect(recorderEp);

  // WebRTC browsers
  getPage(BROWSER2).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER3).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);
  getPage(BROWSER4).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER5).initWebRtc(webRtcEpWhite, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);

  recorderEp.record();

  Thread.sleep(PLAYTIME * 1000);

  final CountDownLatch recorderLatch = new CountDownLatch(1);
  recorderEp.stopAndWait(new Continuation<Void>() {

    @Override
    public void onSuccess(Void result) throws Exception {
      recorderLatch.countDown();
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      recorderLatch.countDown();
    }
  });

  Assert.assertTrue("Not stop properly",
      recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS));

  mp.release();

  // Media Pipeline #2
  MediaPipeline mp2 = kurentoClient.createMediaPipeline();
  PlayerEndpoint playerEp2 =
      new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build();
  playerEp2.connect(webRtcEp2);

  // Playing the recorded file
  launchBrowser(mp2, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM,
      EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME);

  // Release Media Pipeline #2
  mp2.release();

  success = true;
}
 
Example #6
Source File: DispatcherOneToManyPlayerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testDispatcherOneToManyPlayer() throws Exception {
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerEp =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm")
          .build();
  PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build();
  WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp3 = new WebRtcEndpoint.Builder(mp).build();

  DispatcherOneToMany dispatcherOneToMany = new DispatcherOneToMany.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort2 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort3 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort4 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort5 = new HubPort.Builder(dispatcherOneToMany).build();

  playerEp.connect(hubPort1);
  playerEp2.connect(hubPort2);
  hubPort3.connect(webRtcEp1);
  hubPort4.connect(webRtcEp2);
  hubPort5.connect(webRtcEp3);
  dispatcherOneToMany.setSource(hubPort1);

  final CountDownLatch eosLatch = new CountDownLatch(1);
  playerEp2.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() {
    @Override
    public void onEvent(EndOfStreamEvent event) {
      eosLatch.countDown();
    }
  });

  // Test execution
  getPage(BROWSER1).subscribeEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEp2, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);

  getPage(BROWSER2).subscribeEvents("playing");
  getPage(BROWSER2).initWebRtc(webRtcEp1, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);

  getPage(BROWSER3).subscribeEvents("playing");
  getPage(BROWSER3).initWebRtc(webRtcEp3, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);

  playerEp.play();

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER1).waitForEvent("playing"));
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER2).waitForEvent("playing"));
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER3).waitForEvent("playing"));

  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER1).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER2).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER3).similarColor(Color.RED));

  Thread.sleep(3000);
  playerEp2.play();
  dispatcherOneToMany.setSource(hubPort2);

  Assert.assertTrue("The color of the video should be blue",
      getPage(BROWSER1).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be blue",
      getPage(BROWSER2).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be blue",
      getPage(BROWSER3).similarColor(Color.BLUE));

  Thread.sleep(3000);
  dispatcherOneToMany.setSource(hubPort1);

  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER1).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER2).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER3).similarColor(Color.RED));

  Thread.sleep(3000);

  dispatcherOneToMany.setSource(hubPort2);

  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER1).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER2).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be red",
      getPage(BROWSER3).similarColor(Color.BLUE));

  Thread.sleep(3000);

  Assert.assertTrue("Not received EOS event in player",
      eosLatch.await(TIMEOUT_EOS, TimeUnit.SECONDS));
}
 
Example #7
Source File: DispatcherOneToManyWebRtcTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testDispatcherOneToManyWebRtc() throws Exception {

  MediaPipeline mp = kurentoClient.createMediaPipeline();
  WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp3 = new WebRtcEndpoint.Builder(mp).build();

  DispatcherOneToMany dispatcherOneToMany = new DispatcherOneToMany.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort2 = new HubPort.Builder(dispatcherOneToMany).build();
  HubPort hubPort3 = new HubPort.Builder(dispatcherOneToMany).build();

  webRtcEp1.connect(hubPort1);
  webRtcEp2.connect(hubPort2);
  webRtcEp3.connect(hubPort3);
  hubPort1.connect(webRtcEp1);
  hubPort2.connect(webRtcEp2);
  hubPort3.connect(webRtcEp3);

  dispatcherOneToMany.setSource(hubPort1);

  getPage(BROWSER1).subscribeEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEp1, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_RCV);

  getPage(BROWSER2).subscribeEvents("playing");
  getPage(BROWSER2).initWebRtc(webRtcEp2, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_RCV);

  getPage(BROWSER3).subscribeEvents("playing");
  getPage(BROWSER3).initWebRtc(webRtcEp3, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_RCV);

  Thread.sleep(PLAYTIME * 1000);

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER1).waitForEvent("playing"));
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER2).waitForEvent("playing"));
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER3).waitForEvent("playing"));

  Assert.assertTrue("The color of the video should be green (GREEN)",
      getPage(BROWSER1).similarColor(Color.GREEN));
  Assert.assertTrue("The color of the video should be green (GREEN)",
      getPage(BROWSER2).similarColor(Color.GREEN));
  Assert.assertTrue("The color of the video should be green (GREEN)",
      getPage(BROWSER3).similarColor(Color.GREEN));

  Thread.sleep(3000);
  dispatcherOneToMany.setSource(hubPort2);

  Assert.assertTrue("The color of the video should be blue (BLUE)",
      getPage(BROWSER1).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be blue (BLUE)",
      getPage(BROWSER2).similarColor(Color.BLUE));
  Assert.assertTrue("The color of the video should be blue (BLUE)",
      getPage(BROWSER3).similarColor(Color.BLUE));

  Thread.sleep(3000);
  dispatcherOneToMany.setSource(hubPort3);

  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER1).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER2).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER3).similarColor(Color.RED));

  Thread.sleep(3000);
  dispatcherOneToMany.removeSource();
  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER1).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER2).similarColor(Color.RED));
  Assert.assertTrue("The color of the video should be red (RED)",
      getPage(BROWSER3).similarColor(Color.RED));

  Thread.sleep(2000);
}
 
Example #8
Source File: CompositeAudioRecorderTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testCompositeRecorder() throws Exception {
  // MediaPipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerRed =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm")
          .build();
  PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build();
  PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build();

  Composite composite = new Composite.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(composite).build();
  HubPort hubPort2 = new HubPort.Builder(composite).build();
  HubPort hubPort3 = new HubPort.Builder(composite).build();

  playerRed.connect(hubPort1);
  playerGreen.connect(hubPort2, MediaType.AUDIO);
  playerBlue.connect(hubPort3, MediaType.AUDIO);

  PlayerEndpoint playerWhite = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/white.webm").build();
  HubPort hubPort4 = new HubPort.Builder(composite).build();
  playerWhite.connect(hubPort4, MediaType.AUDIO);

  HubPort hubPort5 = new HubPort.Builder(composite).build();
  String recordingFile = getDefaultOutputFile(EXTENSION_WEBM);
  RecorderEndpoint recorderEp =
      new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build();
  hubPort5.connect(recorderEp);

  playerRed.play();
  playerGreen.play();
  playerBlue.play();
  playerWhite.play();

  recorderEp.record();

  Thread.sleep(RECORDTIME * 1000);

  final CountDownLatch recorderLatch = new CountDownLatch(1);
  recorderEp.stopAndWait(new Continuation<Void>() {

    @Override
    public void onSuccess(Void result) throws Exception {
      recorderLatch.countDown();
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      recorderLatch.countDown();
    }
  });

  Assert.assertTrue("Not stop properly",
      recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS));

  playerRed.stop();
  playerGreen.stop();
  playerBlue.stop();
  playerWhite.stop();

  mp.release();

  // Media Pipeline #2
  MediaPipeline mp2 = kurentoClient.createMediaPipeline();
  PlayerEndpoint playerEp2 =
      new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build();
  playerEp2.connect(webRtcEp2);

  // Playing the recording
  launchBrowser(mp, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM,
      EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME);

  // Release Media Pipeline #2
  mp2.release();

  success = true;
}
 
Example #9
Source File: CompositeWebRtcTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testCompositeWebRtc() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build();

  Composite composite = new Composite.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(composite).build();
  HubPort hubPort2 = new HubPort.Builder(composite).build();
  HubPort hubPort3 = new HubPort.Builder(composite).build();

  webRtcEpRed.connect(hubPort1);
  webRtcEpGreen.connect(hubPort2);
  webRtcEpBlue.connect(hubPort3);

  WebRtcEndpoint webRtcEpWhite = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort4 = new HubPort.Builder(composite).build();
  webRtcEpWhite.connect(hubPort4);

  WebRtcEndpoint webRtcEpComposite = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort5 = new HubPort.Builder(composite).build();
  hubPort5.connect(webRtcEpComposite);

  // WebRTC browsers
  getPage(BROWSER2).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER3).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);
  getPage(BROWSER4).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER5).initWebRtc(webRtcEpWhite, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);

  getPage(BROWSER1).subscribeEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEpComposite, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.RCV_ONLY);

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER1).waitForEvent("playing"));
  Assert.assertTrue("Upper left part of the video must be red",
      getPage(BROWSER1).similarColorAt(Color.RED, 0, 0));
  Assert.assertTrue("Upper right part of the video must be green",
      getPage(BROWSER1).similarColorAt(Color.GREEN, 450, 0));
  Assert.assertTrue("Lower left part of the video must be blue",
      getPage(BROWSER1).similarColorAt(Color.BLUE, 0, 450));
  Assert.assertTrue("Lower right part of the video must be white",
      getPage(BROWSER1).similarColorAt(Color.WHITE, 450, 450));

  // Finally, a black & white filter is connected to one WebRTC
  GStreamerFilter bwFilter =
      new GStreamerFilter.Builder(mp, "videobalance saturation=0.0").build();
  webRtcEpRed.connect(bwFilter);
  bwFilter.connect(hubPort1);
  Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME));
  Assert.assertTrue("When connecting the filter, the upper left part of the video must be gray",
      getPage(BROWSER1).similarColorAt(new Color(75, 75, 75), 0, 0));

  // Release Media Pipeline
  mp.release();
}
 
Example #10
Source File: CompositeWebRtcUsersTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testCompositeWebRtcUsers() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  Composite composite = new Composite.Builder(mp).build();
  WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(composite).build();
  webRtcEpRed.connect(hubPort1);

  WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort2 = new HubPort.Builder(composite).build();
  webRtcEpGreen.connect(hubPort2);

  WebRtcEndpoint webRtcEpComposite = new WebRtcEndpoint.Builder(mp).build();

  HubPort hubPort5 = new HubPort.Builder(composite).build();
  hubPort5.connect(webRtcEpComposite);

  WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEpWhite = new WebRtcEndpoint.Builder(mp).build();

  // Test execution
  getPage(BROWSER2).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER3).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);
  getPage(BROWSER4).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
  getPage(BROWSER5).initWebRtc(webRtcEpWhite, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);

  getPage(BROWSER1).subscribeEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEpComposite, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.RCV_ONLY);

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER1).waitForEvent("playing"));
  Assert.assertTrue("Left part of the video must be red",
      getPage(BROWSER1).similarColorAt(Color.RED, 0, 200));
  Assert.assertTrue("Upper right part of the video must be green",
      getPage(BROWSER1).similarColorAt(Color.GREEN, 450, 300));

  hubPort2.release();
  Thread.sleep(3000);

  Assert.assertTrue("All the video must be red",
      getPage(BROWSER1).similarColorAt(Color.RED, 300, 200));

  HubPort hubPort4 = new HubPort.Builder(composite).build();
  webRtcEpWhite.connect(hubPort4);
  Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME));

  Assert.assertTrue("Left part of the video must be red",
      getPage(BROWSER1).similarColorAt(Color.RED, 0, 300));
  Assert.assertTrue("Left part of the video must be white",
      getPage(BROWSER1).similarColorAt(Color.WHITE, 450, 300));

  hubPort4.release();
  hubPort2 = new HubPort.Builder(composite).build();
  hubPort4 = new HubPort.Builder(composite).build();

  webRtcEpGreen.connect(hubPort2);

  HubPort hubPort3 = new HubPort.Builder(composite).build();
  webRtcEpBlue.connect(hubPort3);
  webRtcEpWhite.connect(hubPort4);
  Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME));

  Assert.assertTrue("The red color must be in some position",
      (getPage(BROWSER1).similarColorAt(Color.RED, 0, 0)
          || getPage(BROWSER1).similarColorAt(Color.RED, 450, 0)
          || getPage(BROWSER1).similarColorAt(Color.RED, 0, 450)
          || getPage(BROWSER1).similarColorAt(Color.RED, 450, 450)));
  Assert.assertTrue("The blue color must be in some position",
      (getPage(BROWSER1).similarColorAt(Color.BLUE, 450, 450)
          || getPage(BROWSER1).similarColorAt(Color.BLUE, 0, 450)
          || getPage(BROWSER1).similarColorAt(Color.BLUE, 450, 0)
          || getPage(BROWSER1).similarColorAt(Color.BLUE, 0, 0)));
  Assert.assertTrue("The green color must be in some position",
      (getPage(BROWSER1).similarColorAt(Color.GREEN, 450, 0)
          || getPage(BROWSER1).similarColorAt(Color.GREEN, 0, 450)
          || getPage(BROWSER1).similarColorAt(Color.GREEN, 0, 0)
          || getPage(BROWSER1).similarColorAt(Color.GREEN, 450, 450)));
  Assert.assertTrue("The white color must be in some position",
      (getPage(BROWSER1).similarColorAt(Color.WHITE, 0, 450)
          || getPage(BROWSER1).similarColorAt(Color.WHITE, 450, 0)
          || getPage(BROWSER1).similarColorAt(Color.WHITE, 0, 0)
          || getPage(BROWSER1).similarColorAt(Color.WHITE, 450, 450)));

  // Release Media Pipeline
  mp.release();
}
 
Example #11
Source File: CompositeRecorderTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testCompositeRecorder() throws Exception {
  // MediaPipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerRed =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm")
          .build();
  PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build();
  PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build();

  Composite composite = new Composite.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(composite).build();
  HubPort hubPort2 = new HubPort.Builder(composite).build();
  HubPort hubPort3 = new HubPort.Builder(composite).build();

  playerRed.connect(hubPort1);
  playerGreen.connect(hubPort2);
  playerBlue.connect(hubPort3);

  PlayerEndpoint playerWhite = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/white.webm").build();
  HubPort hubPort4 = new HubPort.Builder(composite).build();
  playerWhite.connect(hubPort4);

  HubPort hubPort5 = new HubPort.Builder(composite).build();
  String recordingFile = getDefaultOutputFile(EXTENSION_WEBM);
  RecorderEndpoint recorderEp =
      new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build();
  hubPort5.connect(recorderEp);

  playerRed.play();
  playerGreen.play();
  playerBlue.play();
  playerWhite.play();

  recorderEp.record();

  Thread.sleep(RECORDTIME * 1000);

  final CountDownLatch recorderLatch = new CountDownLatch(1);
  recorderEp.stopAndWait(new Continuation<Void>() {

    @Override
    public void onSuccess(Void result) throws Exception {
      recorderLatch.countDown();
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      recorderLatch.countDown();
    }
  });

  Assert.assertTrue("Not stop properly",
      recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS));

  playerRed.stop();
  playerGreen.stop();
  playerBlue.stop();
  playerWhite.stop();

  mp.release();

  // Media Pipeline #2
  MediaPipeline mp2 = kurentoClient.createMediaPipeline();
  PlayerEndpoint playerEp2 =
      new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build();
  playerEp2.connect(webRtcEp2);

  // Playing the recording
  launchBrowser(mp, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM,
      EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME);

  // Assertions
  Assert.assertTrue("Upper left part of the video must be red",
      getPage().similarColorAt(Color.RED, 0, 0));
  Assert.assertTrue("Upper right part of the video must be green",
      getPage().similarColorAt(Color.GREEN, 450, 0));
  Assert.assertTrue("Lower left part of the video must be blue",
      getPage().similarColorAt(Color.BLUE, 0, 450));
  Assert.assertTrue("Lower right part of the video must be white",
      getPage().similarColorAt(Color.WHITE, 450, 450));

  // Release Media Pipeline #2
  mp2.release();

  success = true;
}
 
Example #12
Source File: CompositePlayerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testCompositePlayer() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerRed =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm")
          .build();
  PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build();
  PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build();

  Composite composite = new Composite.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(composite).build();
  HubPort hubPort2 = new HubPort.Builder(composite).build();
  HubPort hubPort3 = new HubPort.Builder(composite).build();

  playerRed.connect(hubPort1);
  playerGreen.connect(hubPort2);
  playerBlue.connect(hubPort3);

  PlayerEndpoint playerWhite = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/white.webm").build();
  HubPort hubPort4 = new HubPort.Builder(composite).build();
  playerWhite.connect(hubPort4);

  WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort5 = new HubPort.Builder(composite).build();
  hubPort5.connect(webRtcEp);

  // Test execution
  getPage().subscribeEvents("playing");
  getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);

  playerRed.play();
  playerGreen.play();
  playerBlue.play();
  playerWhite.play();

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage().waitForEvent("playing"));
  Assert.assertTrue("Upper left part of the video must be red",
      getPage().similarColorAt(Color.RED, 0, 0));
  Assert.assertTrue("Upper right part of the video must be green",
      getPage().similarColorAt(Color.GREEN, 450, 0));
  Assert.assertTrue("Lower left part of the video must be blue",
      getPage().similarColorAt(Color.BLUE, 0, 450));
  Assert.assertTrue("Lower right part of the video must be white",
      getPage().similarColorAt(Color.WHITE, 450, 450));

  // Guard time to see the composite result
  Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME));

  // Release Media Pipeline
  mp.release();
}
 
Example #13
Source File: AlphaBlendingPlayerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testAlphaBlendingPlayer() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerRed =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm")
          .build();
  PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build();
  PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build();

  AlphaBlending alphaBlending = new AlphaBlending.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(alphaBlending).build();
  HubPort hubPort2 = new HubPort.Builder(alphaBlending).build();
  HubPort hubPort3 = new HubPort.Builder(alphaBlending).build();

  playerRed.connect(hubPort1);
  playerGreen.connect(hubPort2);
  playerBlue.connect(hubPort3);

  HubPort hubPort4 = new HubPort.Builder(alphaBlending).build();
  WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build();
  hubPort4.connect(webRtcEp);

  alphaBlending.setMaster(hubPort1, 1);

  alphaBlending.setPortProperties(0F, 0F, 8, 0.2F, 0.2F, hubPort2);
  alphaBlending.setPortProperties(0.4F, 0.4F, 7, 0.2F, 0.2F, hubPort3);

  getPage().subscribeEvents("playing");
  getPage().initWebRtc(webRtcEp, WebRtcChannel.VIDEO_ONLY, WebRtcMode.RCV_ONLY);

  playerRed.play();
  playerGreen.play();
  playerBlue.play();

  Thread.sleep(2000);
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage().waitForEvent("playing"));

  Thread.sleep(2000);

  // Assertions
  Assert.assertTrue("Upper left part of the video must be blue",
      getPage().similarColorAt(Color.GREEN, 0, 0));
  Assert.assertTrue("Lower right part of the video must be red",
      getPage().similarColorAt(Color.RED, 315, 235));
  Assert.assertTrue("Center of the video must be blue",
      getPage().similarColorAt(Color.BLUE, 160, 120));

  // alphaBlending.setMaster(hubPort3, 1);
  alphaBlending.setPortProperties(0.8F, 0.8F, 7, 0.2F, 0.2F, hubPort3);

  Assert.assertTrue("Lower right part of the video must be blue",
      getPage().similarColorAt(Color.BLUE, 315, 235));
  Assert.assertTrue("Center of the video must be red",
      getPage().similarColorAt(Color.RED, 160, 120));

  Thread.sleep(PLAYTIME * 1000);
}
 
Example #14
Source File: AlphaBlendingWebRtcTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testAlphaBlendingWebRtc() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build();

  AlphaBlending alphaBlending = new AlphaBlending.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(alphaBlending).build();
  HubPort hubPort2 = new HubPort.Builder(alphaBlending).build();
  HubPort hubPort3 = new HubPort.Builder(alphaBlending).build();

  webRtcEpRed.connect(hubPort1);
  webRtcEpGreen.connect(hubPort2);
  webRtcEpBlue.connect(hubPort3);

  WebRtcEndpoint webRtcEpAlphabaBlending = new WebRtcEndpoint.Builder(mp).build();
  HubPort hubPort4 = new HubPort.Builder(alphaBlending).build();
  hubPort4.connect(webRtcEpAlphabaBlending);

  alphaBlending.setMaster(hubPort1, 1);

  alphaBlending.setPortProperties(0F, 0F, 8, 0.2F, 0.2F, hubPort2);
  alphaBlending.setPortProperties(0.4F, 0.4F, 7, 0.2F, 0.2F, hubPort3);

  getPage(BROWSER1).subscribeLocalEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);

  getPage(BROWSER2).subscribeLocalEvents("playing");
  getPage(BROWSER2).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.SEND_ONLY);

  getPage(BROWSER3).subscribeLocalEvents("playing");
  getPage(BROWSER3).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);

  getPage(BROWSER4).subscribeEvents("playing");
  getPage(BROWSER4).initWebRtc(webRtcEpAlphabaBlending, WebRtcChannel.AUDIO_AND_VIDEO,
      WebRtcMode.RCV_ONLY);

  // Assertions
  Assert.assertTrue("Upper left part of the video must be blue",
      getPage(BROWSER4).similarColorAt(Color.GREEN, 0, 0));
  Assert.assertTrue("Lower right part of the video must be red",
      getPage(BROWSER4).similarColorAt(Color.RED, 315, 235));
  Assert.assertTrue("Center of the video must be blue",
      getPage(BROWSER4).similarColorAt(Color.BLUE, 160, 120));

  // alphaBlending.setMaster(hubPort3, 1);
  alphaBlending.setPortProperties(0.8F, 0.8F, 7, 0.2F, 0.2F, hubPort3);

  Assert.assertTrue("Lower right part of the video must be blue",
      getPage(BROWSER4).similarColorAt(Color.BLUE, 315, 235));
  Assert.assertTrue("Center of the video must be red",
      getPage(BROWSER4).similarColorAt(Color.RED, 160, 120));
  Thread.sleep(PLAYTIME * 1000);
}
 
Example #15
Source File: DispatcherPlayerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testDispatcherPlayer() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();

  PlayerEndpoint playerEp =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/10sec/red.webm")
          .build();
  PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp,
      "http://" + getTestFilesHttpPath() + "/video/10sec/blue.webm").build();
  WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build();

  Dispatcher dispatcher = new Dispatcher.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(dispatcher).build();
  HubPort hubPort2 = new HubPort.Builder(dispatcher).build();
  HubPort hubPort3 = new HubPort.Builder(dispatcher).build();

  playerEp.connect(hubPort1);
  playerEp2.connect(hubPort3);
  hubPort2.connect(webRtcEp);
  dispatcher.connect(hubPort1, hubPort2);

  final CountDownLatch eosLatch = new CountDownLatch(1);
  playerEp2.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() {
    @Override
    public void onEvent(EndOfStreamEvent event) {
      eosLatch.countDown();
    }
  });

  // Test execution
  getPage().subscribeEvents("playing");
  getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);
  playerEp.play();

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage().waitForEvent("playing"));
  Assert.assertTrue("The color of the video should be red", getPage().similarColor(Color.RED));

  Thread.sleep(5000);
  playerEp2.play();
  dispatcher.connect(hubPort3, hubPort2);
  Assert.assertTrue("The color of the video should be blue", getPage().similarColor(Color.BLUE));

  Assert.assertTrue("Not received EOS event in player",
      eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS));
  double currentTime = getPage().getCurrentTime();
  Assert.assertTrue(
      "Error in play time (expected: " + PLAYTIME + " sec, real: " + currentTime + " sec)",
      getPage().compare(PLAYTIME, currentTime));

  // Release Media Pipeline
  mp.release();
}
 
Example #16
Source File: DispatcherWebRtcTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testDispatcherWebRtc() throws Exception {
  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp).build();
  WebRtcEndpoint webRtcEp3 = new WebRtcEndpoint.Builder(mp).build();

  Dispatcher dispatcher = new Dispatcher.Builder(mp).build();
  HubPort hubPort1 = new HubPort.Builder(dispatcher).build();
  HubPort hubPort2 = new HubPort.Builder(dispatcher).build();
  HubPort hubPort3 = new HubPort.Builder(dispatcher).build();

  webRtcEp1.connect(hubPort1);
  webRtcEp3.connect(hubPort3);
  hubPort2.connect(webRtcEp2);

  dispatcher.connect(hubPort1, hubPort2);

  // Test execution
  getPage(BROWSER2).initWebRtc(webRtcEp1, WebRtcChannel.VIDEO_ONLY, WebRtcMode.SEND_ONLY);
  getPage(BROWSER3).initWebRtc(webRtcEp3, WebRtcChannel.VIDEO_ONLY, WebRtcMode.SEND_ONLY);

  getPage(BROWSER1).subscribeEvents("playing");
  getPage(BROWSER1).initWebRtc(webRtcEp2, WebRtcChannel.VIDEO_ONLY, WebRtcMode.RCV_ONLY);

  Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME));

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage(BROWSER1).waitForEvent("playing"));

  Assert.assertTrue("The color of the video should be green",
      getPage(BROWSER1).similarColor(Color.GREEN));

  Thread.sleep(5000);
  dispatcher.connect(hubPort3, hubPort2);

  Assert.assertTrue("The color of the video should be blue (BLUE)",
      getPage(BROWSER1).similarColor(Color.BLUE));

  Thread.sleep(2000);

  // Release Media Pipeline
  mp.release();
}
 
Example #17
Source File: RoomManagerTest.java    From kurento-room with Apache License 2.0 4 votes vote down vote up
@Test
public void publishWithAlternativeLoopbackSrcAudioType() {
  joinManyUsersOneRoom();

  Mixer m = new Mixer.Builder(pipeline).build();
  assertThat("Mixer returned by the builder is not the same as the mocked one", m, is(mixer));

  HubPort hb = new HubPort.Builder(m).build();
  assertThat("HubPort returned by the builder is not the same as the mocked one", hb, is(hubPort));

  String participantId0 = usersParticipantIds.get(users[0]);

  assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
      manager.publishMedia(participantId0, true, SDP_WEB_OFFER, hb, MediaType.AUDIO, true));

  assertThat(manager.getPublishers(roomx).size(), is(1));

  // connected with loopback, so the internal connection is performed
  // right away
  verify(endpoint).connect(any(MediaElement.class), webRtcConnectCaptor.capture());
  // the loopback is not done using the passThru elem
  verify(passThru, never()).connect(any(MediaElement.class), passThruConnectCaptor.capture());
  // the hubPort is connected to the webrtc endpoint
  verify(hubPort).connect(any(MediaElement.class), hubPortConnectTypeCaptor.capture(),
      hubPortConnectCaptor.capture());
  assertThat("Connection type is not audio", hubPortConnectTypeCaptor.getValue(),
      is(MediaType.AUDIO));

  for (String pid : usersParticipantIds.values()) {
    if (!pid.equals(participantId0)) {
      assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
          manager.subscribe(users[0], SDP_WEB_OFFER, pid));
    }
  }
  assertThat(manager.getSubscribers(roomx).size(), is(users.length - 1));

  // using same endpoint, subscribers connections only
  verify(passThru, times(users.length - 1)).connect(any(MediaElement.class),
      passThruConnectCaptor.capture());

  Set<UserParticipant> remainingUsers = manager.leaveRoom(participantId0);
  Set<UserParticipant> roomParticipants = manager.getParticipants(roomx);
  assertEquals(roomParticipants, remainingUsers);
  assertThat(roomParticipants, not(hasItem(usersParticipants.get(users[0]))));
  assertThat(manager.getPublishers(roomx).size(), is(0));

  // peers are automatically unsubscribed
  assertThat(manager.getSubscribers(roomx).size(), is(0));
}
 
Example #18
Source File: RoomManagerTest.java    From kurento-room with Apache License 2.0 4 votes vote down vote up
@Test
public void publishWithAlternativeLoopbackSrc() {
  joinManyUsersOneRoom();

  Mixer m = new Mixer.Builder(pipeline).build();
  assertThat("Mixer returned by the builder is not the same as the mocked one", m, is(mixer));

  HubPort hb = new HubPort.Builder(m).build();
  assertThat("HubPort returned by the builder is not the same as the mocked one", hb, is(hubPort));

  String participantId0 = usersParticipantIds.get(users[0]);

  assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
      manager.publishMedia(participantId0, true, SDP_WEB_OFFER, hb, null, true));

  assertThat(manager.getPublishers(roomx).size(), is(1));

  // connected with loopback, so the internal connection is performed
  // right away
  verify(endpoint).connect(any(MediaElement.class), webRtcConnectCaptor.capture());
  // the loopback is not done using the passThru elem
  verify(passThru, never()).connect(any(MediaElement.class), passThruConnectCaptor.capture());
  // the hubPort is connected to the webrtc endpoint
  verify(hubPort).connect(any(MediaElement.class), hubPortConnectCaptor.capture());

  for (String pid : usersParticipantIds.values()) {
    if (!pid.equals(participantId0)) {
      assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
          manager.subscribe(users[0], SDP_WEB_OFFER, pid));
    }
  }
  assertThat(manager.getSubscribers(roomx).size(), is(users.length - 1));

  // using same endpoint, subscribers connections only
  verify(passThru, times(users.length - 1)).connect(any(MediaElement.class),
      passThruConnectCaptor.capture());

  Set<UserParticipant> remainingUsers = manager.leaveRoom(participantId0);
  Set<UserParticipant> roomParticipants = manager.getParticipants(roomx);
  assertEquals(roomParticipants, remainingUsers);
  assertThat(roomParticipants, not(hasItem(usersParticipants.get(users[0]))));
  assertThat(manager.getPublishers(roomx).size(), is(0));

  // peers are automatically unsubscribed
  assertThat(manager.getSubscribers(roomx).size(), is(0));
}