예제 #1
0
 @Override
 public void teardownBrowserTest() {
   super.teardownBrowserTest();
   if (testExtraFakeKurento != null) {
     testExtraFakeKurento.destroy();
     testExtraFakeKurento = null;
   }
 }
예제 #2
0
  private void start(final WebSocketSession session, JsonObject jsonMessage) {
    try {
      // Media Logic (Media Pipeline and Elements)
      UserSession user = new UserSession();
      MediaPipeline pipeline = kurento.createMediaPipeline();
      user.setMediaPipeline(pipeline);
      WebRtcEndpoint webRtcEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
      user.setWebRtcEndpoint(webRtcEndpoint);
      users.put(session.getId(), user);

      webRtcEndpoint.addOnIceCandidateListener(
          new EventListener<OnIceCandidateEvent>() {

            @Override
            public void onEvent(OnIceCandidateEvent event) {
              JsonObject response = new JsonObject();
              response.addProperty("id", "iceCandidate");
              response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
              try {
                synchronized (session) {
                  session.sendMessage(new TextMessage(response.toString()));
                }
              } catch (IOException e) {
                log.debug(e.getMessage());
              }
            }
          });

      mouth = new NuboMouthDetector.Builder(pipeline).build();

      webRtcEndpoint.connect(mouth);
      mouth.connect(webRtcEndpoint);

      // SDP negotiation (offer and answer)
      String sdpOffer = jsonMessage.get("sdpOffer").getAsString();
      String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);

      // Sending response back to client
      JsonObject response = new JsonObject();
      response.addProperty("id", "startResponse");
      response.addProperty("sdpAnswer", sdpAnswer);

      synchronized (session) {
        session.sendMessage(new TextMessage(response.toString()));
      }
      webRtcEndpoint.gatherCandidates();

    } catch (Throwable t) {
      sendError(session, t.getMessage());
    }
  }
예제 #3
0
  public void createPipeline() {
    synchronized (pipelineCreateLock) {
      if (pipeline != null) {
        return;
      }
      log.info("Session '{}': Creating MediaPipeline-{}", room, description);
      try {
        pipeline = kurento.createMediaPipeline();
        pipelineLatch.countDown();
        log.debug("Session '{}': Created MediaPipeline-{}", room, description);
      } catch (Exception e) {
        log.error("Unable to create MediaPipeline-{} for Session '{}'", description, room, e);
        pipelineLatch.countDown();
      }
      if (getPipeline() == null) {
        throw new RuntimeException(
            "Unable to create MediaPipeline-" + description + " for session '" + room + "'");
      }

      pipeline.addErrorListener(
          new EventListener<ErrorEvent>() {
            @Override
            public void onEvent(ErrorEvent event) {
              String desc =
                  event.getType()
                      + ": "
                      + event.getDescription()
                      + "(errCode="
                      + event.getErrorCode()
                      + ")";
              log.warn(
                  "Session '{}': Pipeline error encountered for MediaPipeline-{}: {}",
                  room,
                  description,
                  desc);
            }
          });
    }
  }
예제 #4
0
  public RoomParticipant join(String userName, WebSocketSession session) {

    checkClosed();

    if (pipeline == null) {
      log.info("ROOM {}: Creating MediaPipeline", userName);
      pipeline = kurento.createMediaPipeline();
    }

    log.info("ROOM {}: adding participant {}", userName, userName);
    final RoomParticipant participant = new RoomParticipant(userName, this, session, this.pipeline);

    sendParticipantNames(participant);

    final JsonObject newParticipantMsg = new JsonObject();
    newParticipantMsg.addProperty("id", "newParticipantArrived");
    newParticipantMsg.addProperty("name", participant.getName());

    log.debug(
        "ROOM {}: notifying other participants {} of new participant {}",
        name,
        participants.values(),
        participant.getName());

    for (final RoomParticipant participant1 : participants.values()) {
      participant1.sendMessage(newParticipantMsg);
    }

    participants.put(participant.getName(), participant);

    log.debug(
        "ROOM {}: Notified other participants {} of new participant {}",
        name,
        participants.values(),
        participant.getName());

    return participant;
  }
예제 #5
0
  protected synchronized KurentoClient getTestExtraFakeKurento() {
    if (testExtraFakeKurento == null) {
      testExtraFakeKurento =
          KurentoClient.create(
              testExtraFakeKmsWsUri,
              new KurentoConnectionListener() {
                @Override
                public void connected() {}

                @Override
                public void connectionFailed() {}

                @Override
                public void disconnected() {
                  testExtraFakeKurento = null;
                }

                @Override
                public void reconnected(boolean sameServer) {}
              });
    }

    return testExtraFakeKurento;
  }
예제 #6
0
 @Bean
 public KurentoClient kurentoClient() {
   return KurentoClient.create(System.getProperty("kms.ws.uri", KMS_WS_URI));
 }
예제 #7
0
 @After
 public void teardownKurentoClient() throws Exception {
   if (kurentoClient != null) {
     kurentoClient.destroy();
   }
 }