/** * 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; }
/** * 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(); }
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(); }
/** * 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; } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
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); }
/** * 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); } }
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); } } }
/** * 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); }
/** * 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; }
/** * 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); } } }
/** * 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)); } } }
/** * 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; }
/** * 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)); } } }
/** * 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; }
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(); }
/** * 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)); }
/** * Setup API supported Payloads */ private void setupPayloads() { payloads.add(new PayloadType.Audio(30, "sshare")); }
public PayloadType getPreferredPayloadType() { return super.getPreferredPayloadType(); }
/** * Setup API supported Payloads */ private void setupPayloads() { payloads.add(new PayloadType.Audio(15, "speex")); }
public void setPayloads(List<PayloadType> payloads) { this.payloads.addAll(payloads); }
public PayloadType getPreferredPayloadType() { if (preferredPayloadType != null) return preferredPayloadType; return super.getPreferredPayloadType(); }
public void setPreferredPayloadType(PayloadType preferredPayloadType) { this.preferredPayloadType = preferredPayloadType; }
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) { }
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); }
/** * 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); } }
/** * Utility constructor, with a PayloadType */ public Audio(final PayloadType pt) { super(); addPayloadType(pt); }
public Audio(final PayloadType.Audio audio) { super(audio); }
/** * 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); }
/** * Return all supported Payloads for this Manager * * @return The Payload List */ public List<PayloadType> getPayloads() { return payloads; }
/** * 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(); }
/** * 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(); }
/** * Return all supported Payloads for this Manager. * * @return The Payload List */ public List<PayloadType> getPayloads() { return payloads; }
/** * 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); }