org.kurento.client.PlayerEndpoint Java Examples

The following examples show how to use org.kurento.client.PlayerEndpoint. 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: RtpEndpointAsyncTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testRtpEndpointSimulatingAndroidSdp() throws InterruptedException {

  PlayerEndpoint player = new PlayerEndpoint.Builder(pipeline, URL_BARCODES).build();

  RtpEndpoint rtpEndpoint = new RtpEndpoint.Builder(pipeline).build();

  String requestSdp = "v=0\r\n" + "o=- 12345 12345 IN IP4 95.125.31.136\r\n" + "s=-\r\n"
      + "c=IN IP4 95.125.31.136\r\n" + "t=0 0\r\n" + "m=video 52126 RTP/AVP 96 97 98\r\n"
      + "a=rtpmap:96 H264/90000\r\n" + "a=rtpmap:97 MP4V-ES/90000\r\n"
      + "a=rtpmap:98 H263-1998/90000\r\n" + "a=recvonly\r\n" + "b=AS:384\r\n";

  rtpEndpoint.processOffer(requestSdp);
  player.connect(rtpEndpoint, MediaType.VIDEO);
  player.play();

  // just a little bit of time before destroying
  Thread.sleep(2000);
}
 
Example #2
Source File: SdpBaseTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testRtpEndpointSimulatingAndroidSdp() throws InterruptedException {

  PlayerEndpoint player = new PlayerEndpoint.Builder(pipeline, URL_BARCODES).build();

  String requestSdp = "v=0\r\n" + "o=- 12345 12345 IN IP4 95.125.31.136\r\n" + "s=-\r\n"
      + "c=IN IP4 95.125.31.136\r\n" + "t=0 0\r\n" + "m=video 52126 RTP/AVP 96 97 98\r\n"
      + "a=rtpmap:96 H264/90000\r\n" + "a=rtpmap:97 MP4V-ES/90000\r\n"
      + "a=rtpmap:98 H263-1998/90000\r\n" + "a=recvonly\r\n" + "b=AS:384\r\n";

  player.connect(sdp, MediaType.VIDEO);
  sdp.processOffer(requestSdp);
  player.play();

  // just a little bit of time before destroying
  Thread.sleep(2000);
}
 
Example #3
Source File: PlayMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 6 votes vote down vote up
public PlayMediaPipeline(KurentoClient kurento, String user, final WebSocketSession session) {
  // Media pipeline
  pipeline = kurento.createMediaPipeline();

  // Media Elements (WebRtcEndpoint, PlayerEndpoint)
  webRtc = new WebRtcEndpoint.Builder(pipeline).build();
  player = new PlayerEndpoint.Builder(pipeline, RECORDING_PATH + user + RECORDING_EXT).build();

  // Connection
  player.connect(webRtc);

  // Player listeners
  player.addErrorListener(new EventListener<ErrorEvent>() {
    @Override
    public void onEvent(ErrorEvent event) {
      log.info("ErrorEvent: {}", event.getDescription());
      sendPlayEnd(session);
    }
  });
}
 
Example #4
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test(expected = TransactionNotCommitedException.class)
public void usePlainMethodsInNewObjectsInsideTx() throws InterruptedException, ExecutionException {

  // Pipeline creation (no transaction)
  MediaPipeline pipeline = kurentoClient.createMediaPipeline();
  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  // Creation in explicit transaction
  Transaction tx = pipeline.beginTransaction();
  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx);

  // TransactionNotExecutedExcetion should be thrown
  httpEndpoint.connect(player);

}
 
Example #5
Source File: PlayMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 6 votes vote down vote up
public PlayMediaPipeline(KurentoClient kurento, String user, final WebSocketSession session) {
  // Media pipeline
  pipeline = kurento.createMediaPipeline();

  // Media Elements (WebRtcEndpoint, PlayerEndpoint)
  webRtc = new WebRtcEndpoint.Builder(pipeline).build();
  player = new PlayerEndpoint.Builder(pipeline, RECORDING_PATH + user + RECORDING_EXT).build();

  // Connection
  player.connect(webRtc);

  // Player listeners
  player.addErrorListener(new EventListener<ErrorEvent>() {
    @Override
    public void onEvent(ErrorEvent event) {
      log.info("ErrorEvent: {}", event.getDescription());
      sendPlayEnd(session);
    }
  });
}
 
Example #6
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Test(expected = TransactionNotCommitedException.class)
public void usePlainMethodsWithNewObjectsAsParamsInsideTx() throws InterruptedException,
    ExecutionException {

  // Pipeline creation (no transaction)
  MediaPipeline pipeline = kurentoClient.createMediaPipeline();
  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  // Creation in explicit transaction
  Transaction tx = pipeline.beginTransaction();
  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx);

  // TransactionNotExecutedExcetion should be thrown
  player.connect(httpEndpoint);

}
 
Example #7
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void creationInTransaction() throws InterruptedException, ExecutionException {

  // Pipeline creation (transaction)
  Transaction tx1 = kurentoClient.beginTransaction();

  MediaPipeline pipeline = kurentoClient.createMediaPipeline(tx1);

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").useEncodedMedia().build(tx1);

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx1);

  player.connect(tx1, httpEndpoint);
  TFuture<String> url1 = httpEndpoint.getUrl(tx1);
  tx1.commit();
  // End pipeline creation

  // Explicit transaction
  Transaction tx2 = pipeline.beginTransaction();
  player.play(tx2);
  TFuture<String> url2 = httpEndpoint.getUrl(tx2);
  pipeline.release(tx2);
  tx2.commit();
  // End explicit transaction

  assertThat(url1.get(), is(url2.get()));
}
 
Example #8
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void waitCommitedTest() throws InterruptedException, ExecutionException {

  // Pipeline creation (transaction)

  Transaction tx = kurentoClient.beginTransaction();

  MediaPipeline pipeline = kurentoClient.createMediaPipeline(tx);

  final PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build(tx);

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx);

  player.connect(tx, httpEndpoint);

  final CountDownLatch readyLatch = new CountDownLatch(1);

  new Thread() {
    @Override
    public void run() {
      try {
        player.waitCommited();
        readyLatch.countDown();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }.start();

  assertThat(readyLatch.getCount(), is(1l));

  tx.commit();

  if (!readyLatch.await(5000, TimeUnit.SECONDS)) {
    fail("waitForReady not unblocked in 5s");
  }
}
 
Example #9
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 #10
Source File: Pipeline.java    From kurento-tutorial-java with Apache License 2.0 5 votes vote down vote up
public void setFeedUrl(String feedUrl) {
  this.feedUrl = feedUrl;

  if (this.playerEndpoint != null) {
    log.debug("Releasing previous elements");
    this.crowdDetectorFilter.release();
    this.playerEndpoint.release();
  }

  log.debug("Creating new elements");

  this.crowdDetectorFilter = new CrowdDetectorFilter.Builder(this.pipe, this.rois).build();
  this.crowdDetectorFilter.setProcessingWidth(640);

  addOrionListeners();

  this.playerEndpoint = new PlayerEndpoint.Builder(this.pipe, this.feedUrl).build();
  addPlayerListeners();
  this.playing = true;

  this.playerEndpoint.connect(this.crowdDetectorFilter);
  this.playerEndpoint.play();

  log.debug("New player is now runing");
  log.debug("Connecting " + this.webRtcEndpoints.size() + " webrtcendpoints");
  // change the feed for all the webrtc clients connected.
  for (Entry<String, WebRtcEndpoint> ep : this.webRtcEndpoints.entrySet()) {
    this.crowdDetectorFilter.connect(ep.getValue());
  }
}
 
Example #11
Source File: RepositoryRecorderTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
private void launchBrowser(WebRtcEndpoint webRtcEp, PlayerEndpoint playerEp,
    RecorderEndpoint recorderEp) throws InterruptedException {

  getPage().subscribeEvents("playing");
  getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);
  playerEp.play();
  final CountDownLatch eosLatch = new CountDownLatch(1);
  playerEp.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() {
    @Override
    public void onEvent(EndOfStreamEvent event) {
      eosLatch.countDown();
    }
  });

  if (recorderEp != null) {
    recorderEp.record();
  }

  // Assertions
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage().waitForEvent("playing"));
  Assert.assertTrue("The color of the video should be black",
      getPage().similarColor(Color.BLACK));
  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));
}
 
Example #12
Source File: EventTagTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testEventWithoutTag() throws Exception {
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  final CountDownLatch eventReceived = new CountDownLatch(1);

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/10sec/red.webm")
          .build();

  player.addTag("test_1", "value_1");
  player.addTag("test_2", "value_2");
  player.addTag("test_3", "value_3");

  player.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() {
    @Override
    public void onEvent(EndOfStreamEvent event) {
      List<Tag> tags = event.getTags();

      if (tags.size() == 0) {
        eventReceived.countDown();
      }
    }
  });

  player.play();
  // Guard time to reproduce the whole video
  if (!eventReceived.await(TIMEOUT, TimeUnit.SECONDS)) {
    Assert.fail("Event not received");
  }
}
 
Example #13
Source File: PlayerMultiplePauseTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testPlayerMultiplePause() throws Exception {
  // Test data
  final String mediaUrl = "http://" + getTestFilesHttpPath() + "/video/60sec/red.webm";
  final Color expectedColor = Color.RED;
  final int playTimeSeconds = 2;
  final int pauseTimeSeconds = 2;
  final int numPauses = 30;

  // Media Pipeline
  MediaPipeline mp = kurentoClient.createMediaPipeline();
  PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrl).build();
  WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build();
  playerEp.connect(webRtcEp);

  // WebRTC in receive-only mode
  getPage().subscribeEvents("playing");
  getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);
  playerEp.play();
  Assert.assertTrue("Not received media (timeout waiting playing event)",
      getPage().waitForEvent("playing"));

  for (int i = 0; i < numPauses; i++) {
    // Assert color
    Assert.assertTrue("The color of the video should be " + expectedColor,
        getPage().similarColor(expectedColor));

    // Pause and wait
    playerEp.pause();
    Thread.sleep(TimeUnit.SECONDS.toMillis(pauseTimeSeconds));

    // Resume video
    playerEp.play();
    Thread.sleep(TimeUnit.SECONDS.toMillis(playTimeSeconds));
  }

  // Release Media Pipeline
  mp.release();
}
 
Example #14
Source File: MetaTestMountedVolumeTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws InterruptedException {

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

  String videoPath = "file://" + getTestFilesDiskPath() + "/video/filter/barcodes.webm";

  PlayerEndpoint p = new PlayerEndpoint.Builder(mp, videoPath).build();

  final CountDownLatch latch = new CountDownLatch(1);

  p.addErrorListener(new EventListener<ErrorEvent>() {
    @Override
    public void onEvent(ErrorEvent event) {
      log.warn("Error un player: " + event.getDescription());
      latch.countDown();
    }
  });

  p.play();

  if (latch.await(5, TimeUnit.SECONDS)) {
    fail("Player error");
  }

  // Release Media Pipeline
  mp.release();
}
 
Example #15
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void transactionTest() throws InterruptedException, ExecutionException {

  // Pipeline creation (no transaction)
  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").useEncodedMedia().build();

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build();

  player.connect(httpEndpoint);

  String url = httpEndpoint.getUrl();
  // End pipeline creation

  // Explicit transaction
  Transaction tx = pipeline.beginTransaction();
  player.play(tx);
  TFuture<String> fUrl = httpEndpoint.getUrl(tx);
  pipeline.release(tx);
  tx.commit();
  // End explicit transaction

  assertThat(url, is(fUrl.get()));
}
 
Example #16
Source File: TestSetupFlowMocked.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Test
public void testMsgTestRecord1() throws Exception {
	doReturn(mock(MediaPipeline.class)).when(client).createMediaPipeline(any(Transaction.class));
	WebRtcEndpoint.Builder builder = mock(WebRtcEndpoint.Builder.class);
	whenNew(WebRtcEndpoint.Builder.class).withArguments(any(MediaPipeline.class)).thenReturn(builder);
	doReturn(mock(WebRtcEndpoint.class)).when(builder).build();

	RecorderEndpoint.Builder recBuilder = mock(RecorderEndpoint.Builder.class);
	whenNew(RecorderEndpoint.Builder.class).withArguments(any(MediaPipeline.class), anyString()).thenReturn(recBuilder);
	doReturn(recBuilder).when(recBuilder).stopOnEndOfStream();
	doReturn(recBuilder).when(recBuilder).withMediaProfile(any(MediaProfileSpecType.class));
	doReturn(mock(RecorderEndpoint.class)).when(recBuilder).build();

	WsClient c = new WsClient("sessionId", 0);
	for (boolean audio : new boolean[] {true, false}) {
		for (boolean video : new boolean[] {true, false}) {
			JSONObject msg = new JSONObject(MSG_BASE.toString())
					.put("id", "record")
					.put("sdpOffer", "")
					.put("audio", audio)
					.put("video", video);
			handler.onMessage(c, msg);
		}
	}
	JSONObject iceMsg = new JSONObject(MSG_BASE.toString())
			.put("id", "iceCandidate")
			.put(PARAM_CANDIDATE, new JSONObject()
					.put(PARAM_CANDIDATE, "candidate")
					.put("sdpMid", "sdpMid")
					.put("sdpMLineIndex", 1));
	handler.onMessage(c, iceMsg);
	PlayerEndpoint.Builder playBuilder = mock(PlayerEndpoint.Builder.class);
	whenNew(PlayerEndpoint.Builder.class).withArguments(any(MediaPipeline.class), anyString()).thenReturn(playBuilder);
	doReturn(mock(PlayerEndpoint.class)).when(playBuilder).build();
	handler.onMessage(c, new JSONObject(MSG_BASE.toString())
			.put("id", "play")
			.put("sdpOffer", "sdpOffer"));
	testProcessor.destroy();
}
 
Example #17
Source File: ConnectionListenerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void disconnectionEventTest() throws InterruptedException, IOException {

  final CountDownLatch disconnectedLatch = new CountDownLatch(1);

  String kmsUrl = kms.getWsUri();

  log.debug("Connecting to KMS in " + kmsUrl);

  KurentoClient kurentoClient = KurentoClient.create(kmsUrl, new KurentoConnectionListener() {

    @Override
    public void disconnected() {
      log.debug("disconnected from KMS");
      disconnectedLatch.countDown();
    }

    @Override
    public void connectionFailed() {

    }

    @Override
    public void connected() {

    }

    @Override
    public void reconnected(boolean sameServer) {

    }
  });

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build();

  player.connect(httpEndpoint);

  try {
    kms.stopKms();
  } catch (Exception e) {
    fail("Exception thrown when destroying kms. " + e);
  }

  log.debug("Waiting for disconnection event");
  if (!disconnectedLatch.await(60, TimeUnit.SECONDS)) {
    fail("Event disconnected should be thrown when kcs is destroyed");
  }
  log.debug("Disconnection event received");
}
 
Example #18
Source File: PlayMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayer() {
  return player;
}
 
Example #19
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayer() {
  return player;
}
 
Example #20
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public void setPlayer(PlayerEndpoint player) {
  this.player = player;
}
 
Example #21
Source File: PlayMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayer() {
  return player;
}
 
Example #22
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayerEndpoint() {
  return playerEndpoint;
}
 
Example #23
Source File: MediaEndpoint.java    From openvidu with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayerEndpoint() {
	return playerEndpoint;
}
 
Example #24
Source File: Pipeline.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
public PlayerEndpoint getPlayerEndpoint() {
  return this.playerEndpoint;
}
 
Example #25
Source File: PlayerEndpointTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setupMediaElements() throws KurentoException {
  player = new PlayerEndpoint.Builder(pipeline, URL_SMALL).build();

}
 
Example #26
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void asyncCommit() throws InterruptedException, ExecutionException {

  // Pipeline creation (transaction)

  Transaction tx = kurentoClient.beginTransaction();

  MediaPipeline pipeline = kurentoClient.createMediaPipeline(tx);

  final PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build(tx);

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx);

  player.connect(tx, httpEndpoint);

  AsyncResultManager<Void> async = new AsyncResultManager<>("commit");

  tx.commit(async.getContinuation());

  async.waitForResult();

  assertThat(player.isCommited(), is(true));

}
 
Example #27
Source File: GStreamerFilterAsyncTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setupMediaElements() {
  player = new PlayerEndpoint.Builder(pipeline, URL_PLATES).build();
}
 
Example #28
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void futureTest() throws InterruptedException, ExecutionException {

  // Pipeline creation (no transaction)

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build();

  player.connect(httpEndpoint);

  // End pipeline creation

  // Atomic operation
  String url = httpEndpoint.getUrl();
  MediaPipeline rPipeline = httpEndpoint.getMediaPipeline();
  String uri = player.getUri();
  // End atomic operation

  // Explicit transaction
  Transaction tx = pipeline.beginTransaction();
  TFuture<String> fUrl = httpEndpoint.getUrl(tx);
  TFuture<MediaPipeline> fRPipeline = httpEndpoint.getMediaPipeline(tx);
  TFuture<String> fUri = player.getUri(tx);
  tx.commit();
  // End explicit transaction

  assertThat(url, is(fUrl.get()));
  assertThat(uri, is(fUri.get()));

  MediaPipeline fRPipelineGet = fRPipeline.get();

  System.out.println(rPipeline);
  System.out.println(fRPipelineGet);

  assertThat(rPipeline, is(fRPipelineGet));
}
 
Example #29
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void asyncTransaction() throws InterruptedException, ExecutionException {

  Transaction tx = kurentoClient.beginTransaction();

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build();

  player.connect(httpEndpoint);

  AsyncResultManager<Void> async = new AsyncResultManager<>("async start");

  tx.commit(async.getContinuation());

  async.waitForResult();

  assertThat(pipeline.isCommited(), is(true));
}
 
Example #30
Source File: TransactionTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void isCommitedTest() throws InterruptedException, ExecutionException {

  Transaction tx = kurentoClient.beginTransaction();

  MediaPipeline pipeline = kurentoClient.createMediaPipeline(tx);

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build(tx);

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build(tx);

  player.connect(tx, httpEndpoint);

  assertThat(player.isCommited(), is(false));

  tx.commit();

  assertThat(player.isCommited(), is(true));
}