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

The following examples show how to use org.kurento.client.KurentoClient#getServerManager() . 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: RoomManager.java    From kurento-room with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a room if it doesn't already exist. The room's name will be indicated by the session
 * info bean.
 *
 * @param kcSessionInfo bean that will be passed to the {@link KurentoClientProvider} in order
 *                      to obtain the
 *                      {@link KurentoClient} that will be used by the room
 * @throws RoomException in case of error while creating the room
 */
public void createRoom(KurentoClientSessionInfo kcSessionInfo) throws RoomException {
  String roomName = kcSessionInfo.getRoomName();
  Room room = rooms.get(kcSessionInfo);
  if (room != null) {
    throw new RoomException(Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE,
        "Room '" + roomName + "' already exists");
  }
  KurentoClient kurentoClient = kcProvider.getKurentoClient(kcSessionInfo);

  room = new Room(roomName, kurentoClient, roomHandler, kcProvider.destroyWhenUnused());

  Room oldRoom = rooms.putIfAbsent(roomName, room);
  if (oldRoom != null) {
    log.warn("Room '{}' has just been created by another thread", roomName);
    return;
    // throw new RoomException(
    // Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE,
    // "Room '"
    // + roomName
    // + "' already exists (has just been created by another thread)");
  }
  String kcName = "[NAME NOT AVAILABLE]";
  if (kurentoClient.getServerManager() != null) {
    kcName = kurentoClient.getServerManager().getName();
  }
  log.warn("No room '{}' exists yet. Created one " + "using KurentoClient '{}'.", roomName,
      kcName);
}
 
Example 2
Source File: ServerManagerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void readPipelineElements() throws IOException {

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  new WebRtcEndpoint.Builder(pipeline).build();

  KurentoClient otherKurentoClient = kms.createKurentoClient();

  ServerManager serverManager = otherKurentoClient.getServerManager();

  List<MediaPipeline> mediaPipelines = serverManager.getPipelines();

  for (MediaObject o : mediaPipelines.get(0).getChildren()) {
    if (o.getId().indexOf("WebRtcEndpoint") >= 0) {
      WebRtcEndpoint webRtc = (WebRtcEndpoint) o;

      assertThat(pipeline, is(webRtc.getParent()));
    }
  }
}