1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7731 b35dd754-fafc-0310-a699-88a17e54d16e

This commit is contained in:
Thiago Camargo 2007-03-27 15:44:07 +00:00 committed by thiago
parent 6059fb7b82
commit bdfec79207
4 changed files with 30 additions and 19 deletions

View file

@ -124,6 +124,7 @@ public class IncomingJingleSession extends JingleSession {
}
setMediaNeg(new MediaNegotiator(this, payloadTypes));
if (resolver.getType().equals(TransportResolver.Type.rawupd)) {
setTransportNeg(new TransportNegotiator.RawUdp(this, resolver));
}
@ -131,11 +132,10 @@ public class IncomingJingleSession extends JingleSession {
setTransportNeg(new TransportNegotiator.Ice(this, resolver));
}
// Establish the default state
setState(accepting);
updatePacketListener();
// Establish the default state
setState(accepting);
}

View file

@ -429,7 +429,14 @@ public abstract class JingleSession extends JingleNegotiator {
jout = getState().eventInfo(jin);
}
else if (action.equals(Jingle.Action.SESSIONINITIATE)) {
if (!(getState() instanceof IncomingJingleSession.Accepting)) {
jout = getState().eventInitiate(jin);
}else{
jout =null;
throw new JingleException("Discard");
}
}
else if (action.equals(Jingle.Action.SESSIONREDIRECT)) {
jout = getState().eventRedirect(jin);
@ -477,6 +484,7 @@ public abstract class JingleSession extends JingleNegotiator {
// Send the packet to the right event handler for the session...
try {
sessionResponse = dispatchIncomingPacket(iq, null);
if (sessionResponse != null) {
responseId = sessionResponse.getPacketID();
@ -493,17 +501,14 @@ public abstract class JingleSession extends JingleNegotiator {
}
// Acknowledge the IQ reception
if (!(getState() instanceof IncomingJingleSession.Accepting))
sendAck(iq);
sendAck(iq);
// ... and send all these parts in a Jingle response.
response = sendJingleParts(iq, (Jingle) sessionResponse,
(Jingle) descriptionResponse, (Jingle) transportResponse);
}
catch (JingleException e) {
// Send an error message, if present
System.out.println("E:" + iq);
JingleError error = e.getError();
if (error != null) {
sendFormattedError(iq, error);
@ -513,9 +518,6 @@ public abstract class JingleSession extends JingleNegotiator {
triggerSessionClosedOnError(e);
}
}
else {
System.out.println("K:" + iq);
}
return response;
}

View file

@ -40,6 +40,7 @@ import java.util.List;
* <p/>
* This class is responsible for managing the descriptor negotiation process,
* handling all the xmpp packets interchange and the stage control.
* handling all the xmpp packets interchange and the stage control.
*
* @author Thiago Camargo
*/
@ -462,7 +463,7 @@ public class MediaNegotiator extends JingleNegotiator {
*/
public Jingle eventInfo(Jingle jin) throws JingleException {
PayloadType.Audio oldBestCommonAudioPt = bestCommonAudioPt;
List offeredPayloads = new ArrayList();
List offeredPayloads;
Jingle response = null;
boolean ptChange = false;
@ -558,10 +559,11 @@ public class MediaNegotiator extends JingleNegotiator {
* @see org.jivesoftware.smackx.jingle.JingleNegotiator.State#eventAck(org.jivesoftware.smack.packet.IQ)
*/
public Jingle eventAck(IQ iq) {
if (isEstablished()) {
setState(active);
return null;
}
return null;
}
}
@ -582,6 +584,7 @@ public class MediaNegotiator extends JingleNegotiator {
*/
public void eventEnter() {
triggerMediaEstablished(getBestCommonAudioPt());
System.err.println("BS:"+getBestCommonAudioPt().getName());
super.eventEnter();
}

View file

@ -161,15 +161,21 @@ public class JingleMediaTest extends SmackTestCase {
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
jm0.setMediaManager(jingleMediaManager0);
jm1.setMediaManager(jingleMediaManager1);
jm0.setMediaManager(new JmfMediaManager());
jm1.setMediaManager(new JmfMediaManager());
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
public void sessionRequested(final JingleSessionRequest request) {
try {
IncomingJingleSession session = request.accept(jm1.getMediaManager().getPayloads());
//session.start(request);
try {
Thread.sleep(30000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
session.start(request);
}
catch (XMPPException e) {
e.printStackTrace();
@ -178,7 +184,7 @@ public class JingleMediaTest extends SmackTestCase {
}
});
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 10; i++) {
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
@ -189,15 +195,15 @@ public class JingleMediaTest extends SmackTestCase {
public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
if (newOne != null) {
System.out.println(newOne.getClass().getCanonicalName());
assertFalse(newOne instanceof OutgoingJingleSession.Active);
if ((newOne instanceof OutgoingJingleSession.Active))
System.err.println("|||"+newOne.getClass().getCanonicalName()+"|||");
}
}
});
js0.start();
Thread.sleep(5000);
Thread.sleep(45000);
js0.terminate();
Thread.sleep(1500);