Java 类org.jivesoftware.smackx.jingleold.media.PayloadType 实例源码

项目:Smack    文件:JingleDescriptionProvider.java   
/**
 * Parse a iq/jingle/description element.
 * 
 * @param parser
 *            the input to parse
 * @return a description element
 * @throws SmackException 
 * @throws IOException 
 * @throws XmlPullParserException 
 */
public JingleDescription parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException, IOException {
    boolean done = false;
    JingleDescription desc = getInstance();

    while (!done) {
        int eventType = parser.next();
        String name = parser.getName();

        if (eventType == XmlPullParser.START_TAG) {
            if (name.equals(PayloadType.NODENAME)) {
                desc.addPayloadType(parsePayload(parser));
            } else {
                throw new SmackException("Unknow element \"" + name + "\" in content.");
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (name.equals(JingleDescription.NODENAME)) {
                done = true;
            }
        }
    }
    return desc;
}
项目:Smack    文件:JingleDescription.java   
/**
 * Convert a Jingle description to XML.
 *
 * @return a string with the XML representation
 */
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();
}
项目:Smack    文件:JingleContentDescription.java   
public String toXML() {
    StringBuilder buf = new StringBuilder();

    if (payload != null) {
        buf.append("<").append(getElementName()).append(" ");

        // We covert here the payload type to XML
        if (payload.getId() != PayloadType.INVALID_PT) {
            buf.append(" id=\"").append(payload.getId()).append("\"");
        }
        if (payload.getName() != null) {
            buf.append(" name=\"").append(payload.getName()).append("\"");
        }
        if (payload.getChannels() != 0) {
            buf.append(" channels=\"").append(payload.getChannels()).append("\"");
        }
        if (getChildAttributes() != null) {
            buf.append(getChildAttributes());
        }
        buf.append("/>");
    }
    return buf.toString();
}
项目:Smack    文件:AudioFormatUtils.java   
/**
 * Return a JMF AudioFormat for a given Jingle Payload type.
 * Return null if the payload is not supported by this jmf API.
 *
 * @param payloadtype payloadtype
 * @return correspondent audioType
 */
public static AudioFormat getAudioFormat(PayloadType payloadtype) {

    switch (payloadtype.getId()) {
        case 0:
            return new AudioFormat(AudioFormat.ULAW_RTP);
        case 3:
            return new AudioFormat(AudioFormat.GSM_RTP);
        case 4:
            return new AudioFormat(AudioFormat.G723_RTP);
        default:
            return null;
    }

}
项目:Smack    文件:ScreenShareMediaManager.java   
/**
 * Returns a new JingleMediaSession
 *
 * @param payloadType payloadType
 * @param remote      remote Candidate
 * @param local       local Candidate
 * @return JingleMediaSession JingleMediaSession
 */
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
    ScreenShareSession session = null;
    session = new ScreenShareSession(payloadType, remote, local, "Screen", jingleSession);
    if (encoder != null) {
        session.setEncoder(encoder);
    }
    if (decoder != null) {
        session.setDecoder(decoder);
    }
    return session;
}
项目:Smack    文件:TestMediaManager.java   
/**
 * Returns a new JingleMediaSession
 *
 * @param payloadType payloadType
 * @param remote      remote Candidate
 * @param local       local Candidate
 * @return JingleMediaSession JingleMediaSession
 */
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote,
        final TransportCandidate local, final JingleSession jingleSession) {
    TestMediaSession session = null;

    session = new TestMediaSession(payloadType, remote, local, "", jingleSession);

    return session;
}
项目:Smack    文件:MultiMediaManager.java   
/**
 * Return all supported Payloads for this Manager.
 *
 * @return The Payload List
 */
public List<PayloadType> getPayloads() {
    List<PayloadType> list = new ArrayList<PayloadType>();
    if (preferredPayloadType != null) list.add(preferredPayloadType);
    for (JingleMediaManager manager : managers) {
        for (PayloadType payloadType : manager.getPayloads()) {
            if (!list.contains(payloadType) && !payloadType.equals(preferredPayloadType))
                list.add(payloadType);
        }
    }
    return list;
}
项目:Smack    文件:MultiMediaManager.java   
/**
 * Returns a new JingleMediaSession
 *
 * @param payloadType payloadType
 * @param remote      remote Candidate
 * @param local       local Candidate
 * @return JingleMediaSession JingleMediaSession
 */
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
    for (JingleMediaManager manager : managers) {
        if (manager.getPayloads().contains(payloadType)) {
            return manager.createMediaSession(payloadType, remote, local, jingleSession);
        }
    }
    return null;
}
项目:Smack    文件:ContentNegotiator.java   
public void triggerContentEstablished() throws NotConnectedException {

        PayloadType bestCommonAudioPt = getMediaNegotiator().getBestCommonAudioPt();
        TransportCandidate bestRemoteCandidate = getTransportNegotiator().getBestRemoteCandidate();
        TransportCandidate acceptedLocalCandidate = getTransportNegotiator().getAcceptedLocalCandidate();

        // Trigger the session established flag
        triggerContentEstablished(bestCommonAudioPt, bestRemoteCandidate, acceptedLocalCandidate);
    }
项目:Smack    文件:ContentNegotiator.java   
/**
 * Trigger a session established event.
 * @throws NotConnectedException 
 */
private void triggerContentEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc) throws NotConnectedException {

    // Let the session know that we've established a content/media segment.
    JingleSession session = getSession();
    if (session != null) {
        List<JingleListener> listeners = session.getListenersList();
        for (JingleListener li : listeners) {
            if (li instanceof JingleSessionListener) {
                JingleSessionListener sli = (JingleSessionListener) li;
                sli.sessionEstablished(pt, rc, lc, session);
            }
        }
    }

    // Create a media session for each media manager in the session.
    if (mediaNeg.getMediaManager() != null) {
        rc.removeCandidateEcho();
        lc.removeCandidateEcho();

        jingleMediaSession = getMediaNegotiator().getMediaManager().createMediaSession(pt, rc, lc, session);
        jingleMediaSession.addMediaReceivedListener(session);
        if (jingleMediaSession != null) {

            jingleMediaSession.startTrasmit();
            jingleMediaSession.startReceive();

            for (TransportCandidate candidate : getTransportNegotiator().getOfferedCandidates())
                candidate.removeCandidateEcho();
        }
        JingleMediaManager mediaManager = getMediaNegotiator().getMediaManager();
        getSession().addJingleMediaSession(mediaManager.getName(), jingleMediaSession);
    }

}
项目:Smack    文件:ICETransportManager.java   
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException {
    if (lc instanceof ICECandidate) {
        if (((ICECandidate) lc).getType().equals("relay")) {
            RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
        }
    }
}
项目:Smack    文件:JingleContentDescriptionProvider.java   
/**
 * Parse an audio payload type.
 */
public JinglePayloadType parsePayload(final XmlPullParser parser) {
    JinglePayloadType pte = super.parsePayload(parser);
    PayloadType.Audio pt = new PayloadType.Audio(pte.getPayloadType());
    int ptClockRate = 0;

    try {
        ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
    } catch (Exception e) {
    }
    pt.setClockRate(ptClockRate);

    return new JinglePayloadType.Audio(pt);
}
项目:Smack    文件:JingleDescriptionProvider.java   
/**
 * Parse an audio payload type.
 */
public PayloadType parsePayload(final XmlPullParser parser) {
    PayloadType pte = super.parsePayload(parser);
    PayloadType.Audio pt = new PayloadType.Audio(pte);
    int ptClockRate = 0;

    try {
        ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
    } catch (Exception e) {
    }
    pt.setClockRate(ptClockRate);

    return pt;
}
项目:Smack    文件:JingleDescription.java   
/**
 * Adds a audio payload type to the packet.
 *
 * @param pt the audio payload type to add.
 */
public void addPayloadType(final PayloadType pt) {
    synchronized (payloads) {
        if (pt == null) {
            LOGGER.severe("Null payload type");
        } else {
            payloads.add(pt);
        }
    }
}
项目:Smack    文件:JingleDescription.java   
/**
 * Adds a list of payloads to the packet.
 *
 * @param pts the payloads to add.
 */
public void addAudioPayloadTypes(final List<PayloadType> pts) {
    synchronized (payloads) {
        Iterator<PayloadType> ptIter = pts.iterator();
        while (ptIter.hasNext()) {
            PayloadType.Audio pt = (PayloadType.Audio) ptIter.next();
            addPayloadType(new PayloadType.Audio(pt));
        }
    }
}
项目:Smack    文件:JingleDescription.java   
/**
 * 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 = (PayloadType) jinglePtsIter.next();
        if (jpt instanceof PayloadType.Audio) {
            PayloadType.Audio jpta = (PayloadType.Audio) jpt;
            result.add(jpta);
        }
    }

    return result;
}
项目:Smack    文件:JingleContentDescription.java   
/**
 * Adds a list of payloads to the packet.
 *
 * @param pts the payloads to add.
 */
public void addAudioPayloadTypes(final List<PayloadType.Audio> pts) {
    synchronized (payloads) {
        Iterator<PayloadType.Audio> ptIter = pts.iterator();
        while (ptIter.hasNext()) {
            PayloadType.Audio pt = ptIter.next();
            addJinglePayloadType(new JinglePayloadType.Audio(pt));
        }
    }
}
项目:Smack    文件:JingleContentDescription.java   
/**
 * Return the list of Payload types contained in the description.
 *
 * @return a list of PayloadType.Audio
 */
public ArrayList<PayloadType.Audio> getAudioPayloadTypesList() {
    ArrayList<PayloadType.Audio> result = new ArrayList<PayloadType.Audio>();
    Iterator<JinglePayloadType> jinglePtsIter = getJinglePayloadTypes();

    while (jinglePtsIter.hasNext()) {
        JinglePayloadType jpt = jinglePtsIter.next();
        if (jpt instanceof JinglePayloadType.Audio) {
            JinglePayloadType.Audio jpta = (JinglePayloadType.Audio) jpt;
            result.add((PayloadType.Audio)jpta.getPayloadType());
        }
    }

    return result;
}
项目:Smack    文件:JingleContentDescription.java   
protected String getChildAttributes() {
             StringBuilder buf = new StringBuilder();
             PayloadType pt = getPayloadType();
             if (pt instanceof PayloadType.Audio) {
        PayloadType.Audio pta = (PayloadType.Audio) pt;

        buf.append(" clockrate=\"").append(pta.getClockRate()).append("\" ");
    }
    return buf.toString();
}
项目:Smack    文件:JmfMediaManager.java   
/**
 * Setup API supported Payloads
 */
private void setupPayloads() {
    payloads.add(new PayloadType.Audio(3, "gsm"));
    payloads.add(new PayloadType.Audio(4, "g723"));
    payloads.add(new PayloadType.Audio(0, "PCMU", 16000));
}
项目:Smack    文件:ScreenShareMediaManager.java   
/**
 * Setup API supported Payloads
 */
private void setupPayloads() {
    payloads.add(new PayloadType.Audio(30, "sshare"));
}
项目:Smack    文件:ScreenShareMediaManager.java   
public PayloadType getPreferredPayloadType() {
    return super.getPreferredPayloadType();
}
项目:Smack    文件:SpeexMediaManager.java   
/**
 * Setup API supported Payloads
 */
private void setupPayloads() {
    payloads.add(new PayloadType.Audio(15, "speex"));
}
项目:Smack    文件:TestMediaManager.java   
public void setPayloads(List<PayloadType> payloads) {
    this.payloads.addAll(payloads);
}
项目:Smack    文件:TestMediaManager.java   
public PayloadType getPreferredPayloadType() {
    if (preferredPayloadType != null)
        return preferredPayloadType;
    return super.getPreferredPayloadType();
}
项目:Smack    文件:TestMediaManager.java   
public void setPreferredPayloadType(PayloadType preferredPayloadType) {
    this.preferredPayloadType = preferredPayloadType;
}
项目:Smack    文件:MultiMediaManager.java   
public PayloadType getPreferredPayloadType() {
    if (preferredPayloadType != null) return preferredPayloadType;
    return super.getPreferredPayloadType();
}
项目:Smack    文件:MultiMediaManager.java   
public void setPreferredPayloadType(PayloadType preferredPayloadType) {
    this.preferredPayloadType = preferredPayloadType;
}
项目:Smack    文件:JingleManager.java   
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) {
}
项目:Smack    文件:FixedTransportManager.java   
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) {
}
项目:Smack    文件:BridgedTransportManager.java   
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException {
    RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
}
项目:Smack    文件:JingleDescription.java   
/**
 * Returns a list for the audio payloads in the packet.
 *
 * @return a list for the audio payloads in the packet.
 */
public List<PayloadType> getPayloadTypesList() {
    synchronized (payloads) {
        return new ArrayList<PayloadType>(payloads);
    }
}
项目:Smack    文件:JingleDescription.java   
/**
 * Utility constructor, with a PayloadType
 */
public Audio(final PayloadType pt) {
    super();
    addPayloadType(pt);
}
项目:Smack    文件:JingleContentDescription.java   
public Audio(final PayloadType.Audio audio) {
    super(audio);
}
项目:Smack    文件:JmfMediaManager.java   
/**
 * Returns a new jingleMediaSession
 *
 * @param payloadType payloadType
 * @param remote      remote Candidate
 * @param local       local Candidate
 * @return JingleMediaSession
 */
public JingleMediaSession createMediaSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
    return new AudioMediaSession(payloadType, remote, local, mediaLocator, jingleSession);
}
项目:Smack    文件:JmfMediaManager.java   
/**
 * Return all supported Payloads for this Manager
 *
 * @return The Payload List
 */
public List<PayloadType> getPayloads() {
    return payloads;
}
项目:Smack    文件:AudioMediaSession.java   
/**
 * Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates
 *
 * @param payloadType Payload of the jmf
 * @param remote      the remote information. The candidate that the jmf will be sent to.
 * @param local       the local information. The candidate that will receive the jmf
 * @param locator     media locator
 */
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
        final TransportCandidate local, String locator, JingleSession jingleSession) {
    super(payloadType, remote, local, locator==null?"dsound://":locator,jingleSession);
    initialize();
}
项目:Smack    文件:ScreenShareSession.java   
/**
 * Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates
 *
 * @param payloadType Payload of the jmf
 * @param remote      the remote information. The candidate that the jmf will be sent to.
 * @param local       the local information. The candidate that will receive the jmf
 * @param locator     media locator
 */
public ScreenShareSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local,
        final String locator, JingleSession jingleSession) {
    super(payloadType, remote, local, "Screen", jingleSession);
    initialize();
}
项目:Smack    文件:ScreenShareMediaManager.java   
/**
 * Return all supported Payloads for this Manager.
 *
 * @return The Payload List
 */
public List<PayloadType> getPayloads() {
    return payloads;
}
项目:Smack    文件:SpeexMediaManager.java   
/**
 * Returns a new jingleMediaSession
 *
 * @param payloadType payloadType
 * @param remote      remote Candidate
 * @param local       local Candidate
 * @return JingleMediaSession
 */
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
    return new AudioMediaSession(payloadType, remote, local, null,null);
}