Example #1
0
  /**
   * Makes sure that conference is allocated for given <tt>room</tt>.
   *
   * @param room name of the MUC room of Jitsi Meet conference.
   * @param properties configuration properties, see {@link JitsiMeetConfig} for the list of valid
   *     properties.
   * @throws Exception if any error occurs.
   */
  private void createConference(String room, Map<String, String> properties) throws Exception {
    JitsiMeetConfig config = new JitsiMeetConfig(properties);

    JitsiMeetConference conference =
        new JitsiMeetConference(room, focusUserName, protocolProviderHandler, this, config);

    conferences.put(room, conference);

    StringBuilder options = new StringBuilder();
    for (Map.Entry<String, String> option : properties.entrySet()) {
      options.append("\n    ").append(option.getKey()).append(": ").append(option.getValue());
    }

    logger.info(
        "Created new focus for "
            + room
            + "@"
            + focusUserDomain
            + " conferences count: "
            + conferences.size()
            + " options:"
            + options.toString());

    // Send focus created event
    EventAdmin eventAdmin = FocusBundleActivator.getEventAdmin();
    if (eventAdmin != null) {
      eventAdmin.sendEvent(EventFactory.focusCreated(conference.getId(), conference.getRoomName()));
    }

    try {
      conference.start();
    } catch (Exception e) {
      logger.info("Exception while trying to start the conference", e);

      // stop() method is called by the conference automatically in order
      // to not release the lock on JitsiMeetConference instance and avoid
      // a deadlock. It may happen when this thread is about to call
      // conference.stop() and another thread has entered the method
      // before us. That other thread will try to call
      // FocusManager.conferenceEnded, but we're still holding the lock
      // on FocusManager instance.

      // conference.stop();

      throw e;
    }
  }
Example #2
0
  /** {@inheritDoc} */
  @Override
  public synchronized void conferenceEnded(JitsiMeetConference conference) {
    String roomName = conference.getRoomName();

    conferences.remove(roomName);

    logger.info(
        "Disposed conference for room: " + roomName + " conference count: " + conferences.size());

    if (focusAllocListener != null) {
      focusAllocListener.onFocusDestroyed(roomName);
    }

    // Send focus destroyed event
    FocusBundleActivator.getEventAdmin()
        .sendEvent(EventFactory.focusDestroyed(conference.getId(), conference.getRoomName()));

    maybeDoShutdown();
  }
Example #3
0
  /**
   * Makes sure that conference is allocated for given <tt>room</tt>.
   *
   * @param room name of the MUC room of Jitsi Meet conference.
   * @param properties configuration properties, see {@link JitsiMeetConfig} for the list of valid
   *     properties.
   * @throws Exception if any error occurs.
   */
  private void createConference(String room, Map<String, String> properties) throws Exception {
    JitsiMeetConfig config = new JitsiMeetConfig(properties);

    JitsiMeetConference conference =
        new JitsiMeetConference(room, focusUserName, protocolProviderHandler, this, config);

    conferences.put(room, conference);

    StringBuilder options = new StringBuilder();
    for (Map.Entry<String, String> option : properties.entrySet()) {
      options.append("\n    ").append(option.getKey()).append(": ").append(option.getValue());
    }

    logger.info(
        "Created new focus for "
            + room
            + "@"
            + focusUserDomain
            + " conferences count: "
            + conferences.size()
            + " options:"
            + options.toString());

    // Send focus created event
    EventAdmin eventAdmin = FocusBundleActivator.getEventAdmin();
    if (eventAdmin != null) {
      eventAdmin.sendEvent(EventFactory.focusCreated(conference.getId(), conference.getRoomName()));
    }

    try {
      conference.start();
    } catch (Exception e) {
      logger.info("Exception while trying to start the conference", e);

      conference.stop();

      throw e;
    }
  }
  /** Handles XEP-0337 "log" extensions. */
  private void handleLogRequest(LogPacketExtension log, String jid) {
    JitsiMeetConference conference = getConferenceForMucJid(jid);

    if (conference == null) {
      logger.debug("Room not found for JID: " + jid);
      return;
    }

    Participant participant = conference.findParticipantForRoomJid(jid);

    if (participant == null) {
      logger.info("Ignoring log request from an unknown JID: " + jid);
      return;
    }

    EventAdmin eventAdmin = FocusBundleActivator.getEventAdmin();

    if (eventAdmin == null) return;

    if (LogUtil.LOG_ID_PC_STATS.equals(log.getID())) {
      String content = LogUtil.getContent(log);

      if (content != null) {
        ColibriConference colibriConference = conference.getColibriConference();

        if (colibriConference != null) {
          Event event =
              EventFactory.peerConnectionStats(
                  colibriConference.getConferenceId(), participant.getEndpointId(), content);

          if (event != null) eventAdmin.sendEvent(event);
        } else {
          logger.warn("Unhandled log request" + " - no valid Colibri conference");
        }
      }
    } else if (logger.isInfoEnabled()) {
      logger.info("Ignoring log request with an unknown ID:" + log.getID());
    }
  }
  /**
   * Handles presence stanzas
   *
   * @param presence
   */
  private void handlePresence(Presence presence) {
    // unavailable is sent when user leaves the room
    if (!presence.isAvailable()) {
      return;
    }

    String from = presence.getFrom();
    JitsiMeetConference conference = getConferenceForMucJid(from);

    if (conference == null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Room not found for JID: " + from);
      }
      return;
    }

    ChatRoomMemberRole role = conference.getRoleForMucJid(from);

    if (role != null && role.compareTo(ChatRoomMemberRole.MODERATOR) < 0) {
      StartMutedPacketExtension ext =
          (StartMutedPacketExtension)
              presence.getExtension(
                  StartMutedPacketExtension.ELEMENT_NAME, StartMutedPacketExtension.NAMESPACE);

      if (ext != null) {
        boolean[] startMuted = {ext.getAudioMuted(), ext.getVideoMuted()};

        conference.setStartMuted(startMuted);
      }
    }

    Participant participant = conference.findParticipantForRoomJid(from);
    ColibriConference colibriConference = conference.getColibriConference();

    if (participant != null && colibriConference != null) {
      // Check if this conference is valid
      String conferenceId = colibriConference.getConferenceId();
      if (StringUtils.isNullOrEmpty(conferenceId)) {
        logger.error("Unable to send DisplayNameChanged event" + " - no conference id");
        return;
      }

      // Check for changes to the display name
      String oldDisplayName = participant.getDisplayName();
      String newDisplayName = null;
      for (PacketExtension pe : presence.getExtensions()) {
        if (pe instanceof Nick) {
          newDisplayName = ((Nick) pe).getName();
          break;
        }
      }

      if (!Objects.equals(oldDisplayName, newDisplayName)) {
        participant.setDisplayName(newDisplayName);

        EventAdmin eventAdmin = FocusBundleActivator.getEventAdmin();
        if (eventAdmin != null) {
          // Prevent NPE when adding to event hashtable
          if (newDisplayName == null) {
            newDisplayName = "";
          }
          eventAdmin.sendEvent(
              EventFactory.endpointDisplayNameChanged(
                  conferenceId, participant.getEndpointId(), newDisplayName));
        }
      }
    }
  }