mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 02:58:00 +01:00
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7731 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
6059fb7b82
commit
bdfec79207
4 changed files with 30 additions and 19 deletions
|
@ -124,6 +124,7 @@ public class IncomingJingleSession extends JingleSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
setMediaNeg(new MediaNegotiator(this, payloadTypes));
|
setMediaNeg(new MediaNegotiator(this, payloadTypes));
|
||||||
|
|
||||||
if (resolver.getType().equals(TransportResolver.Type.rawupd)) {
|
if (resolver.getType().equals(TransportResolver.Type.rawupd)) {
|
||||||
setTransportNeg(new TransportNegotiator.RawUdp(this, resolver));
|
setTransportNeg(new TransportNegotiator.RawUdp(this, resolver));
|
||||||
}
|
}
|
||||||
|
@ -131,11 +132,10 @@ public class IncomingJingleSession extends JingleSession {
|
||||||
setTransportNeg(new TransportNegotiator.Ice(this, resolver));
|
setTransportNeg(new TransportNegotiator.Ice(this, resolver));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establish the default state
|
|
||||||
setState(accepting);
|
|
||||||
|
|
||||||
updatePacketListener();
|
updatePacketListener();
|
||||||
|
|
||||||
|
// Establish the default state
|
||||||
|
setState(accepting);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,14 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
jout = getState().eventInfo(jin);
|
jout = getState().eventInfo(jin);
|
||||||
}
|
}
|
||||||
else if (action.equals(Jingle.Action.SESSIONINITIATE)) {
|
else if (action.equals(Jingle.Action.SESSIONINITIATE)) {
|
||||||
|
|
||||||
|
if (!(getState() instanceof IncomingJingleSession.Accepting)) {
|
||||||
jout = getState().eventInitiate(jin);
|
jout = getState().eventInitiate(jin);
|
||||||
|
}else{
|
||||||
|
jout =null;
|
||||||
|
throw new JingleException("Discard");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (action.equals(Jingle.Action.SESSIONREDIRECT)) {
|
else if (action.equals(Jingle.Action.SESSIONREDIRECT)) {
|
||||||
jout = getState().eventRedirect(jin);
|
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...
|
// Send the packet to the right event handler for the session...
|
||||||
try {
|
try {
|
||||||
|
|
||||||
sessionResponse = dispatchIncomingPacket(iq, null);
|
sessionResponse = dispatchIncomingPacket(iq, null);
|
||||||
if (sessionResponse != null) {
|
if (sessionResponse != null) {
|
||||||
responseId = sessionResponse.getPacketID();
|
responseId = sessionResponse.getPacketID();
|
||||||
|
@ -493,17 +501,14 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acknowledge the IQ reception
|
// Acknowledge the IQ reception
|
||||||
if (!(getState() instanceof IncomingJingleSession.Accepting))
|
sendAck(iq);
|
||||||
sendAck(iq);
|
|
||||||
|
|
||||||
// ... and send all these parts in a Jingle response.
|
// ... and send all these parts in a Jingle response.
|
||||||
response = sendJingleParts(iq, (Jingle) sessionResponse,
|
response = sendJingleParts(iq, (Jingle) sessionResponse,
|
||||||
(Jingle) descriptionResponse, (Jingle) transportResponse);
|
(Jingle) descriptionResponse, (Jingle) transportResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (JingleException e) {
|
catch (JingleException e) {
|
||||||
// Send an error message, if present
|
// Send an error message, if present
|
||||||
System.out.println("E:" + iq);
|
|
||||||
JingleError error = e.getError();
|
JingleError error = e.getError();
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
sendFormattedError(iq, error);
|
sendFormattedError(iq, error);
|
||||||
|
@ -513,9 +518,6 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
triggerSessionClosedOnError(e);
|
triggerSessionClosedOnError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
System.out.println("K:" + iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.List;
|
||||||
* <p/>
|
* <p/>
|
||||||
* This class is responsible for managing the descriptor negotiation process,
|
* 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.
|
||||||
|
* handling all the xmpp packets interchange and the stage control.
|
||||||
*
|
*
|
||||||
* @author Thiago Camargo
|
* @author Thiago Camargo
|
||||||
*/
|
*/
|
||||||
|
@ -462,7 +463,7 @@ public class MediaNegotiator extends JingleNegotiator {
|
||||||
*/
|
*/
|
||||||
public Jingle eventInfo(Jingle jin) throws JingleException {
|
public Jingle eventInfo(Jingle jin) throws JingleException {
|
||||||
PayloadType.Audio oldBestCommonAudioPt = bestCommonAudioPt;
|
PayloadType.Audio oldBestCommonAudioPt = bestCommonAudioPt;
|
||||||
List offeredPayloads = new ArrayList();
|
List offeredPayloads;
|
||||||
Jingle response = null;
|
Jingle response = null;
|
||||||
boolean ptChange = false;
|
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)
|
* @see org.jivesoftware.smackx.jingle.JingleNegotiator.State#eventAck(org.jivesoftware.smack.packet.IQ)
|
||||||
*/
|
*/
|
||||||
public Jingle eventAck(IQ iq) {
|
public Jingle eventAck(IQ iq) {
|
||||||
|
|
||||||
if (isEstablished()) {
|
if (isEstablished()) {
|
||||||
setState(active);
|
setState(active);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,6 +584,7 @@ public class MediaNegotiator extends JingleNegotiator {
|
||||||
*/
|
*/
|
||||||
public void eventEnter() {
|
public void eventEnter() {
|
||||||
triggerMediaEstablished(getBestCommonAudioPt());
|
triggerMediaEstablished(getBestCommonAudioPt());
|
||||||
|
System.err.println("BS:"+getBestCommonAudioPt().getName());
|
||||||
super.eventEnter();
|
super.eventEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,15 +161,21 @@ public class JingleMediaTest extends SmackTestCase {
|
||||||
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
|
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
|
||||||
jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
|
jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
|
||||||
|
|
||||||
jm0.setMediaManager(jingleMediaManager0);
|
jm0.setMediaManager(new JmfMediaManager());
|
||||||
jm1.setMediaManager(jingleMediaManager1);
|
jm1.setMediaManager(new JmfMediaManager());
|
||||||
|
|
||||||
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
||||||
public void sessionRequested(final JingleSessionRequest request) {
|
public void sessionRequested(final JingleSessionRequest request) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IncomingJingleSession session = request.accept(jm1.getMediaManager().getPayloads());
|
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) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
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());
|
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());
|
||||||
|
|
||||||
|
@ -189,15 +195,15 @@ public class JingleMediaTest extends SmackTestCase {
|
||||||
|
|
||||||
public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
|
public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
|
||||||
if (newOne != null) {
|
if (newOne != null) {
|
||||||
System.out.println(newOne.getClass().getCanonicalName());
|
if ((newOne instanceof OutgoingJingleSession.Active))
|
||||||
assertFalse(newOne instanceof OutgoingJingleSession.Active);
|
System.err.println("|||"+newOne.getClass().getCanonicalName()+"|||");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
js0.start();
|
js0.start();
|
||||||
|
|
||||||
Thread.sleep(5000);
|
Thread.sleep(45000);
|
||||||
js0.terminate();
|
js0.terminate();
|
||||||
|
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
|
|
Loading…
Reference in a new issue