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;
}
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();
}
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;
}
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));
}
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);
}
Aggregations