Java Code Examples for org.kurento.client.KurentoClient#createMediaPipeline()

The following examples show how to use org.kurento.client.KurentoClient#createMediaPipeline() . 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: 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 2
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 3
Source File: CallMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 6 votes vote down vote up
public CallMediaPipeline(KurentoClient kurento, String from, String to) {

    // Media pipeline
    pipeline = kurento.createMediaPipeline();

    // Media Elements (WebRtcEndpoint, RecorderEndpoint)
    webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build();
    webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build();

    recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT)
        .build();
    recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT)
        .build();

    // Connections
    webRtcCaller.connect(webRtcCallee);
    webRtcCaller.connect(recorderCaller);

    webRtcCallee.connect(webRtcCaller);
    webRtcCallee.connect(recorderCallee);
  }
 
Example 4
Source File: KurentoClientKmsConnectionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void errorSendingClosedKmsTest() throws Exception {

  String kmsUrl = kms.getWsUri();

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

    @Override
    public void reconnected(boolean sameServer) {
    }

    @Override
    public void disconnected() {
      log.debug("Disconnected");
    }

    @Override
    public void connectionFailed() {
    }

    @Override
    public void connected() {
    }
  });

  kurento.createMediaPipeline();

  kms.stopKms();

  try {
    kurento.createMediaPipeline();
    fail("KurentoException should be thrown");
  } catch (KurentoException e) {
    assertThat(e.getMessage(), containsString("Exception connecting to WebSocket"));
  }
}
 
Example 5
Source File: CallMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 5 votes vote down vote up
public CallMediaPipeline(KurentoClient kurento, String from, String to) {

    // Media pipeline
    pipeline = kurento.createMediaPipeline();

    // Media Elements (WebRtcEndpoint, RecorderEndpoint, FaceOverlayFilter)
    webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build();
    webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build();

    recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT)
        .build();
    recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT)
        .build();

    // String appServerUrl = System.getProperty("app.server.url",
    //    One2OneCallAdvApp.DEFAULT_APP_SERVER_URL);
    String appServerUrl = "http://files.openvidu.io";
    FaceOverlayFilter faceOverlayFilterCaller = new FaceOverlayFilter.Builder(pipeline).build();
    faceOverlayFilterCaller.setOverlayedImage(appServerUrl + "/img/mario-wings.png", -0.35F, -1.2F,
        1.6F, 1.6F);

    FaceOverlayFilter faceOverlayFilterCallee = new FaceOverlayFilter.Builder(pipeline).build();
    faceOverlayFilterCallee.setOverlayedImage(appServerUrl + "/img/Hat.png", -0.2F, -1.35F, 1.5F,
        1.5F);

    // Connections
    webRtcCaller.connect(faceOverlayFilterCaller);
    faceOverlayFilterCaller.connect(webRtcCallee);
    faceOverlayFilterCaller.connect(recorderCaller);

    webRtcCallee.connect(faceOverlayFilterCallee);
    faceOverlayFilterCallee.connect(webRtcCaller);
    faceOverlayFilterCallee.connect(recorderCallee);
  }
 
Example 6
Source File: CallMediaPipeline.java    From kurento-tutorial-java with Apache License 2.0 5 votes vote down vote up
public CallMediaPipeline(KurentoClient kurento) {
  try {
    this.pipeline = kurento.createMediaPipeline();
    this.callerWebRtcEp = new WebRtcEndpoint.Builder(pipeline).build();
    this.calleeWebRtcEp = new WebRtcEndpoint.Builder(pipeline).build();

    this.callerWebRtcEp.connect(this.calleeWebRtcEp);
    this.calleeWebRtcEp.connect(this.callerWebRtcEp);
  } catch (Throwable t) {
    if (this.pipeline != null) {
      pipeline.release();
    }
  }
}
 
Example 7
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 8
Source File: ConnectionListenerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void reconnectTest() throws InterruptedException, IOException {

  String kmsUrl = kms.getWsUri();

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

  KurentoClient kurentoClient = KurentoClient.create(kmsUrl);

  kurentoClient.createMediaPipeline();

  kms.stopKms();

  Thread.sleep(3000);

  kms.start();

  kurentoClient.createMediaPipeline();

  kms.stopKms();
}