/** * 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); } } } }
/** * {@inheritDoc} * * <p>Creates a <tt>TransportManager</tt> instance suitable for an <tt>SctpConnection</tt> (e.g. * with 1 component only). */ protected TransportManager createTransportManager(String xmlNamespace) throws IOException { if (IceUdpTransportPacketExtension.NAMESPACE.equals(xmlNamespace)) { Content content = getContent(); return new IceUdpTransportManager( content.getConference(), isInitiator(), 1 /* num components */, content.getName()); } else if (RawUdpTransportPacketExtension.NAMESPACE.equals(xmlNamespace)) { // TODO: support RawUdp once RawUdpTransportManager is updated // return new RawUdpTransportManager(this); throw new IllegalArgumentException("Unsupported Jingle transport " + xmlNamespace); } else { throw new IllegalArgumentException("Unsupported Jingle transport " + xmlNamespace); } }
/** * Expires this <tt>Conference</tt>, its <tt>Content</tt>s and their respective <tt>Channel</tt>s. * Releases the resources acquired by this instance throughout its life time and prepares it to be * garbage collected. */ public void expire() { synchronized (this) { if (expired) return; else expired = true; } EventAdmin eventAdmin = videobridge.getEventAdmin(); if (eventAdmin != null) eventAdmin.sendEvent(EventFactory.conferenceExpired(this)); setRecording(false); if (recorderEventHandler != null) { recorderEventHandler.close(); recorderEventHandler = null; } Videobridge videobridge = getVideobridge(); try { videobridge.expireConference(this); } finally { // Expire the Contents of this Conference. for (Content content : getContents()) { try { content.expire(); } catch (Throwable t) { logger.warn( "Failed to expire content " + content.getName() + " of conference " + getID() + "!", t); if (t instanceof InterruptedException) Thread.currentThread().interrupt(); else if (t instanceof ThreadDeath) throw (ThreadDeath) t; } } // Close the transportManagers of this Conference. Normally, there // will be no TransportManager left to close at this point because // all Channels have expired and the last Channel to be removed from // a TransportManager closes the TransportManager. However, a // Channel may have expired before it has learned of its // TransportManager and then the TransportManager will not close. closeTransportManagers(); if (logger.isInfoEnabled()) { logger.info( "Expired conference " + getID() + ". " + videobridge.getConferenceCountString()); } } }
/** * Gets a <tt>Content</tt> of this <tt>Conference</tt> which has a specific name. If a * <tt>Content</tt> of this <tt>Conference</tt> with the specified <tt>name</tt> does not exist at * the time the method is invoked, the method initializes a new <tt>Content</tt> instance with the * specified <tt>name</tt> and adds it to the list of <tt>Content</tt>s of this * <tt>Conference</tt>. * * @param name the name of the <tt>Content</tt> which is to be returned * @return a <tt>Content</tt> of this <tt>Conference</tt> which has the specified <tt>name</tt> */ public Content getOrCreateContent(String name) { Content content; synchronized (contents) { for (Content aContent : contents) { if (aContent.getName().equals(name)) { aContent.touch(); // It seems the content is still active. return aContent; } } content = new Content(this, name); if (isRecording()) { content.setRecording(true, getRecordingPath()); } contents.add(content); } if (logger.isInfoEnabled()) { /* * The method Videobridge.getChannelCount() should better be * executed outside synchronized blocks in order to reduce the risks * of causing deadlocks. */ Videobridge videobridge = getVideobridge(); logger.info( "Created content " + name + " of conference " + getID() + ". " + videobridge.getConferenceCountString()); } return content; }
/** * 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, returns <tt>null</tt>. * * @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> if such a <tt>Content</tt> exists; otherwise, * <tt>null</tt> */ public Content getContent(String contentName) { for (Content content : getContents()) if (contentName.equals(content.getName())) return content; return null; }