/**
   * Returns a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
   * which has a specific name. If no such <tt>Content</tt> exists at the time of the invocation of
   * the method, initializes a new <tt>Content</tt> instance with the specified <tt>contentName</tt>
   * and includes it into this <tt>conference</tt> IQ.
   *
   * @param contentName the name of the <tt>Content</tt> to be returned
   * @return a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
   *     which has the specified <tt>contentName</tt>
   */
  public Content getOrCreateContent(String contentName) {
    Content content = getContent(contentName);

    if (content == null) {
      content = new Content(contentName);
      addContent(content);
    }

    return content;
  }
示例#2
0
  /**
   * Utility method for extracting info about channels allocated from JVB response. FIXME: this
   * might not work as expected when channels for multiple peers with single query were allocated.
   *
   * @param conferenceResponse JVB response to allocate channels request.
   * @param peerContents list of peer media contents that has to be matched with allocated channels.
   * @return the Colibri IQ that describes allocated channels.
   */
  public static ColibriConferenceIQ getResponseContents(
      ColibriConferenceIQ conferenceResponse, List<ContentPacketExtension> peerContents) {
    ColibriConferenceIQ conferenceResult = new ColibriConferenceIQ();

    conferenceResult.setFrom(conferenceResponse.getFrom());
    conferenceResult.setID(conferenceResponse.getID());

    // FIXME: we support single bundle for all channels
    String bundleId = null;
    for (ContentPacketExtension content : peerContents) {
      MediaType mediaType = JingleUtils.getMediaType(content);

      ColibriConferenceIQ.Content contentResponse =
          conferenceResponse.getContent(mediaType.toString());

      if (contentResponse != null) {
        String contentName = contentResponse.getName();
        ColibriConferenceIQ.Content contentResult = new ColibriConferenceIQ.Content(contentName);

        conferenceResult.addContent(contentResult);

        for (ColibriConferenceIQ.Channel channelResponse : contentResponse.getChannels()) {
          contentResult.addChannel(channelResponse);

          bundleId = readChannelBundle(channelResponse, bundleId);
        }

        for (ColibriConferenceIQ.SctpConnection sctpConnResponse :
            contentResponse.getSctpConnections()) {
          contentResult.addSctpConnection(sctpConnResponse);

          bundleId = readChannelBundle(sctpConnResponse, bundleId);
        }
      }
    }

    // Copy only peer's bundle(JVB returns all bundles)
    if (bundleId != null) {
      for (ColibriConferenceIQ.ChannelBundle bundle : conferenceResponse.getChannelBundles()) {
        if (bundleId.equals(bundle.getId())) {
          conferenceResult.addChannelBundle(bundle);
          break;
        }
      }
    }

    return conferenceResult;
  }