Exemplo n.º 1
0
  /**
   * Processes channels allocation response from the JVB and stores info about new channels in
   * {@link #conferenceState}.
   *
   * @param allocateResponse the Colibri IQ that describes JVB response to allocate request.
   */
  public void processChannelAllocResp(ColibriConferenceIQ allocateResponse) {
    String conferenceResponseID = allocateResponse.getID();
    String colibriID = conferenceState.getID();

    if (colibriID == null) conferenceState.setID(conferenceResponseID);
    else if (!colibriID.equals(conferenceResponseID))
      throw new IllegalStateException("conference.id");

    /*
     * XXX We must remember the JID of the Jitsi Videobridge because
     * (1) we do not want to re-discover it in every method
     * invocation on this Call instance and (2) we want to use one
     * and the same for all CallPeers within this Call instance.
     */
    conferenceState.setFrom(allocateResponse.getFrom());

    for (ColibriConferenceIQ.Content contentResponse : allocateResponse.getContents()) {
      String contentName = contentResponse.getName();
      ColibriConferenceIQ.Content content = conferenceState.getOrCreateContent(contentName);

      // FIXME: we do not check if allocated channel does not clash
      // with any existing one
      for (ColibriConferenceIQ.Channel channelResponse : contentResponse.getChannels()) {
        content.addChannel(channelResponse);
      }
      for (ColibriConferenceIQ.SctpConnection sctpConnResponse :
          contentResponse.getSctpConnections()) {
        content.addSctpConnection(sctpConnResponse);
      }
    }

    for (ColibriConferenceIQ.ChannelBundle bundle : allocateResponse.getChannelBundles()) {
      conferenceState.addChannelBundle(bundle);
    }
  }
  /**
   * Sets the values of the properties of a specific <tt>ColibriConferenceIQ</tt> to the values of
   * the respective properties of this instance. Thus, the specified <tt>iq</tt> may be thought of
   * as a description of this instance.
   *
   * <p><b>Note</b>: The copying of the values is deep i.e. the <tt>Contents</tt>s of this instance
   * are described in the specified <tt>iq</tt>.
   *
   * @param iq the <tt>ColibriConferenceIQ</tt> to set the values of the properties of this instance
   *     on
   */
  public void describeDeep(ColibriConferenceIQ iq) {
    describeShallow(iq);

    if (isRecording()) {
      ColibriConferenceIQ.Recording recordingIQ =
          new ColibriConferenceIQ.Recording(State.ON.toString());
      recordingIQ.setDirectory(getRecordingDirectory());
      iq.setRecording(recordingIQ);
    }
    for (Content content : getContents()) {
      ColibriConferenceIQ.Content contentIQ = iq.getOrCreateContent(content.getName());

      for (Channel channel : content.getChannels()) {
        if (channel instanceof SctpConnection) {
          ColibriConferenceIQ.SctpConnection sctpConnectionIQ =
              new ColibriConferenceIQ.SctpConnection();

          channel.describe(sctpConnectionIQ);
          contentIQ.addSctpConnection(sctpConnectionIQ);
        } else {
          ColibriConferenceIQ.Channel channelIQ = new ColibriConferenceIQ.Channel();

          channel.describe(channelIQ);
          contentIQ.addChannel(channelIQ);
        }
      }
    }
  }