From bdfec79207f94fe0e23f64fb4a83f58db4281346 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Tue, 27 Mar 2007 15:44:07 +0000 Subject: [PATCH] git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7731 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/jingle/IncomingJingleSession.java | 6 +++--- .../smackx/jingle/JingleSession.java | 16 ++++++++------- .../smackx/jingle/media/MediaNegotiator.java | 7 +++++-- .../smackx/jingle/JingleMediaTest.java | 20 ++++++++++++------- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/IncomingJingleSession.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/IncomingJingleSession.java index c3d8ad796..b223dee89 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/IncomingJingleSession.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/IncomingJingleSession.java @@ -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); } diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/JingleSession.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/JingleSession.java index 1e5042333..390b894f0 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/JingleSession.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/JingleSession.java @@ -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; } diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/MediaNegotiator.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/MediaNegotiator.java index e16f11235..4c1a44012 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/MediaNegotiator.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/MediaNegotiator.java @@ -40,6 +40,7 @@ import java.util.List; *

* 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(); } diff --git a/jingle/extension/test/org/jivesoftware/smackx/jingle/JingleMediaTest.java b/jingle/extension/test/org/jivesoftware/smackx/jingle/JingleMediaTest.java index bceff9db2..99742ecb5 100644 --- a/jingle/extension/test/org/jivesoftware/smackx/jingle/JingleMediaTest.java +++ b/jingle/extension/test/org/jivesoftware/smackx/jingle/JingleMediaTest.java @@ -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);