Search in sources :

Example 1 with PayloadType

use of org.jivesoftware.smackx.jingleold.media.PayloadType in project Smack by igniterealtime.

the class JingleDescription method getAudioPayloadTypesList.

/**
     * Return the list of Payload types contained in the description.
     *
     * @return a list of PayloadType.Audio
     */
public List<PayloadType> getAudioPayloadTypesList() {
    ArrayList<PayloadType> result = new ArrayList<PayloadType>();
    Iterator<PayloadType> jinglePtsIter = getPayloadTypes();
    while (jinglePtsIter.hasNext()) {
        PayloadType jpt = jinglePtsIter.next();
        if (jpt instanceof PayloadType.Audio) {
            PayloadType.Audio jpta = (PayloadType.Audio) jpt;
            result.add(jpta);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType)

Example 2 with PayloadType

use of org.jivesoftware.smackx.jingleold.media.PayloadType in project Smack by igniterealtime.

the class JingleDescription method toXML.

/**
     * Convert a Jingle description to XML.
     *
     * @return a string with the XML representation
     */
@Override
public String toXML() {
    StringBuilder buf = new StringBuilder();
    synchronized (payloads) {
        if (payloads.size() > 0) {
            buf.append('<').append(getElementName());
            buf.append(" xmlns=\"").append(getNamespace()).append("\" >");
            for (PayloadType payloadType : payloads) {
                if (payloadType != null) {
                    buf.append(payloadType.toXML());
                }
            }
            buf.append("</").append(getElementName()).append('>');
        }
    }
    return buf.toString();
}
Also used : PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType)

Example 3 with PayloadType

use of org.jivesoftware.smackx.jingleold.media.PayloadType in project Smack by igniterealtime.

the class JingleSessionStateUnknown method receiveSessionInitiateAction.

/**
     * In the UNKNOWN state we received a <session-initiate> action.
     * This method processes that action.
     * @throws SmackException 
     * @throws InterruptedException 
     */
private IQ receiveSessionInitiateAction(JingleSession session, Jingle inJingle) throws SmackException, InterruptedException {
    IQ response = null;
    boolean shouldAck = true;
    if (!shouldAck) {
        response = session.createJingleError(inJingle, JingleError.NEGOTIATION_ERROR);
    } else {
        // Create the Ack
        response = session.createAck(inJingle);
        session.setSessionState(JingleSessionStatePending.getInstance());
        // Now set up all of the initial content negotiators for the session.
        for (JingleContent jingleContent : inJingle.getContentsList()) {
            // First create the content negotiator for this <content> section.
            ContentNegotiator contentNeg = new ContentNegotiator(session, jingleContent.getCreator(), jingleContent.getName());
            // Get the media negotiator that goes with the <description> of this content.
            JingleDescription jingleDescription = jingleContent.getDescription();
            // Loop through each media manager looking for the ones that matches the incoming 
            // session-initiate <content> choices.
            // (Set the first media manager as the default, so that in case things don't match we can still negotiate.)
            JingleMediaManager chosenMediaManager = session.getMediaManagers().get(0);
            for (JingleMediaManager mediaManager : session.getMediaManagers()) {
                boolean matches = true;
                for (PayloadType mediaPayloadType : mediaManager.getPayloads()) {
                    for (PayloadType descPayloadType2 : jingleDescription.getPayloadTypesList()) {
                        if (mediaPayloadType.getId() != descPayloadType2.getId()) {
                            matches = false;
                        }
                    }
                    if (matches) {
                        chosenMediaManager = mediaManager;
                    }
                }
            }
            // Create the media negotiator for this content description.
            contentNeg.setMediaNegotiator(new MediaNegotiator(session, chosenMediaManager, jingleDescription.getPayloadTypesList(), contentNeg));
            // Then create a transport negotiator for that transport.
            for (JingleTransport jingleTransport : jingleContent.getJingleTransportsList()) {
                for (JingleMediaManager mediaManager : session.getMediaManagers()) {
                    JingleTransportManager transportManager = mediaManager.getTransportManager();
                    TransportResolver resolver = null;
                    try {
                        resolver = transportManager.getResolver(session);
                    } catch (XMPPException e) {
                        LOGGER.log(Level.WARNING, "exception", e);
                    }
                    if (resolver.getType().equals(TransportResolver.Type.rawupd)) {
                        contentNeg.setTransportNegotiator(new TransportNegotiator.RawUdp(session, resolver, contentNeg));
                    }
                    if (resolver.getType().equals(TransportResolver.Type.ice)) {
                        contentNeg.setTransportNegotiator(new TransportNegotiator.Ice(session, resolver, contentNeg));
                    }
                }
            }
            // Add the content negotiator to the session.
            session.addContentNegotiator(contentNeg);
        }
        // Now setup to track the media negotiators, so that we know when (if) to send a session-accept.
        session.setupListeners();
    }
    return response;
}
Also used : JingleDescription(org.jivesoftware.smackx.jingleold.packet.JingleDescription) IQ(org.jivesoftware.smack.packet.IQ) MediaNegotiator(org.jivesoftware.smackx.jingleold.media.MediaNegotiator) JingleTransport(org.jivesoftware.smackx.jingleold.packet.JingleTransport) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType) TransportNegotiator(org.jivesoftware.smackx.jingleold.nat.TransportNegotiator) JingleMediaManager(org.jivesoftware.smackx.jingleold.media.JingleMediaManager) TransportResolver(org.jivesoftware.smackx.jingleold.nat.TransportResolver) JingleContent(org.jivesoftware.smackx.jingleold.packet.JingleContent) XMPPException(org.jivesoftware.smack.XMPPException) JingleTransportManager(org.jivesoftware.smackx.jingleold.nat.JingleTransportManager)

Example 4 with PayloadType

use of org.jivesoftware.smackx.jingleold.media.PayloadType in project Smack by igniterealtime.

the class JingleContentDescriptionProvider method parsePayload.

/**
     * Parse a iq/jingle/description/payload-type element.
     *
     * @param parser the input to parse
     * @return a payload type element
     */
protected JinglePayloadType parsePayload(final XmlPullParser parser) {
    int ptId = 0;
    String ptName;
    int ptChannels = 0;
    try {
        ptId = Integer.parseInt(parser.getAttributeValue("", "id"));
    } catch (Exception e) {
    }
    ptName = parser.getAttributeValue("", "name");
    try {
        ptChannels = Integer.parseInt(parser.getAttributeValue("", "channels"));
    } catch (Exception e) {
    }
    return new JinglePayloadType(new PayloadType(ptId, ptName, ptChannels));
}
Also used : JinglePayloadType(org.jivesoftware.smackx.jingleold.packet.JingleContentDescription.JinglePayloadType) SmackException(org.jivesoftware.smack.SmackException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) JinglePayloadType(org.jivesoftware.smackx.jingleold.packet.JingleContentDescription.JinglePayloadType) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType)

Example 5 with PayloadType

use of org.jivesoftware.smackx.jingleold.media.PayloadType in project Smack by igniterealtime.

the class ContentNegotiator method triggerContentEstablished.

public void triggerContentEstablished() throws NotConnectedException, InterruptedException {
    PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
    TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
    TransportCandidate acceptedLocalCandidate = getTransportNegotiator().getAcceptedLocalCandidate();
    // Trigger the session established flag
    triggerContentEstablished(bestCommonAudioPt, bestRemoteCandidate, acceptedLocalCandidate);
}
Also used : TransportCandidate(org.jivesoftware.smackx.jingleold.nat.TransportCandidate) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType)

Aggregations

PayloadType (org.jivesoftware.smackx.jingleold.media.PayloadType)6 XMPPException (org.jivesoftware.smack.XMPPException)2 TransportCandidate (org.jivesoftware.smackx.jingleold.nat.TransportCandidate)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 SmackException (org.jivesoftware.smack.SmackException)1 IQ (org.jivesoftware.smack.packet.IQ)1 JingleMediaListener (org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener)1 JingleTransportListener (org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener)1 JingleMediaManager (org.jivesoftware.smackx.jingleold.media.JingleMediaManager)1 MediaNegotiator (org.jivesoftware.smackx.jingleold.media.MediaNegotiator)1 JingleTransportManager (org.jivesoftware.smackx.jingleold.nat.JingleTransportManager)1 TransportNegotiator (org.jivesoftware.smackx.jingleold.nat.TransportNegotiator)1 TransportResolver (org.jivesoftware.smackx.jingleold.nat.TransportResolver)1 Jingle (org.jivesoftware.smackx.jingleold.packet.Jingle)1 JingleContent (org.jivesoftware.smackx.jingleold.packet.JingleContent)1 JinglePayloadType (org.jivesoftware.smackx.jingleold.packet.JingleContentDescription.JinglePayloadType)1 JingleDescription (org.jivesoftware.smackx.jingleold.packet.JingleDescription)1 JingleTransport (org.jivesoftware.smackx.jingleold.packet.JingleTransport)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1