/** * 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; }
/** * Finds a <tt>Channel</tt> of this <tt>Conference</tt> which receives a specific SSRC and is with * a specific <tt>MediaType</tt>. * * @param receiveSSRC the SSRC of a received RTP stream whose receiving <tt>Channel</tt> in this * <tt>Conference</tt> is to be found * @param mediaType the <tt>MediaType</tt> of the <tt>Channel</tt> to be found * @return the <tt>Channel</tt> in this <tt>Conference</tt> which receives the specified * <tt>ssrc</tt> and is with the specified <tt>mediaType</tt>; otherwise, <tt>null</tt> */ public Channel findChannelByReceiveSSRC(long receiveSSRC, MediaType mediaType) { for (Content content : getContents()) { if (mediaType.equals(content.getMediaType())) { Channel channel = content.findChannelByReceiveSSRC(receiveSSRC); if (channel != null) return channel; } } return null; }