Revision: 15638
Author: oleg.kulikoff
Date: Mon Dec 6 04:04:45 2010
Log: Network Connection FSM
http://code.google.com/p/mobicents/source/detail?r=15638
Added:
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/CreateConnectionRequest.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/CreateConnectionResponseHandler.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/DeleteConnectionRequest.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/DeleteConnectionResponseHandler.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ModifyConnectionRequest.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ModifyConnectionResponseHandler.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/fsm
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/fsm/ConnectionState.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/fsm/ConnectionTransition.java
Deleted:
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ConnectionState.java
Modified:
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/NetworkConnectionImpl.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerEventImpl.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerImpl.java
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/spi/MgcpTransactionHandler.java
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/CreateConnectionRequest.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.message.CreateConnection;
+import jain.protocol.ip.mgcp.message.parms.CallIdentifier;
+import jain.protocol.ip.mgcp.message.parms.ConnectionDescriptor;
+import jain.protocol.ip.mgcp.message.parms.ConnectionMode;
+import jain.protocol.ip.mgcp.message.parms.EndpointIdentifier;
+import org.mobicents.fsm.State;
+import org.mobicents.fsm.TransitionHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class CreateConnectionRequest implements TransitionHandler {
+ private NetworkConnectionImpl connection;
+
+ protected CreateConnectionRequest(NetworkConnectionImpl connection) {
+ this.connection = connection;
+ }
+
+ public void process(State state) {
+ //prepear callID and endpointID parameters for request
+ CallIdentifier callId = connection.getSession().getCallID();
+ EndpointIdentifier endpointID = connection.endpointName;
+
+ //ask for new unique transaction handler
+ int txHandle = connection.getSession().getUniqueHandler();
+
+ //generate message
+ CreateConnection req = new CreateConnection(this, callId,
endpointID, ConnectionMode.SendRecv);
+ req.setTransactionHandle(txHandle);
+
req.setNotifiedEntity(connection.getSession().getDriver().getCallAgent());
+
+ //if SDP is present assign it to request
+ if (connection.sdpPortManager.remoteSdp != null) {
+ try {
+ req.setRemoteConnectionDescriptor(new
ConnectionDescriptor(connection.sdpPortManager.remoteSdp));
+ } catch (Exception e) {
+ }
+ }
+
+ //create handler for this tx
+// new CreateConnectionResponseHandler(txHandle);
+ //send request
+ connection.getSession().getDriver().send(req);
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/CreateConnectionResponseHandler.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.JainMgcpCommandEvent;
+import jain.protocol.ip.mgcp.JainMgcpResponseEvent;
+import jain.protocol.ip.mgcp.message.CreateConnectionResponse;
+import jain.protocol.ip.mgcp.message.parms.ReturnCode;
+import org.mobicents.fsm.UnknownTransitionException;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionTransition;
+import org.mobicents.javax.media.mscontrol.spi.MgcpTransactionHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class CreateConnectionResponseHandler extends
MgcpTransactionHandler {
+
+ private NetworkConnectionImpl connection;
+
+ public CreateConnectionResponseHandler(int txID, NetworkConnectionImpl
connection) {
+ super(txID, connection.getSession().getDriver());
+ this.connection = connection;
+ }
+
+ @Override
+ public boolean processCommandEvent(JainMgcpCommandEvent evt) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean processResponseEvent(JainMgcpResponseEvent evt) {
+ CreateConnectionResponse resp = (CreateConnectionResponse) evt;
+ switch (resp.getReturnCode().getValue()) {
+ case ReturnCode.TRANSACTION_BEING_EXECUTED :
+ return false;
+ case ReturnCode.TRANSACTION_EXECUTED_NORMALLY :
+ connection.connectionID = resp.getConnectionIdentifier();
+ connection.sdpPortManager.localSdp =
resp.getLocalConnectionDescriptor().toString();
+ connection.endpointName =
resp.getSpecificEndpointIdentifier();
+
+ try {
+ if (connection.sdpPortManager.remoteSdp != null) {
+ connection.fsm.signal(ConnectionTransition.OPENED);
+ } else {
+
connection.fsm.signal(ConnectionTransition.CREATED);
+ }
+ } catch (UnknownTransitionException e) {
+ }
+ return true;
+/* switch (connection.state) {
+ case OPENING:
+ //extract endpoint name, connection id and local
descriptor
+ updateParameters(resp);
+ connection.state = ConnectionState.HALF_OPENED;
+ fireEvent(SdpPortManagerEvent.OFFER_GENERATED,
true, null, null);
+ break;
+ case OPENING_WITH_REMOTE_SDP:
+ //extract endpoint name, connection id and local
descriptor
+ updateParameters(resp);
+ connection.state = ConnectionState.OPENED;
+ fireEvent(SdpPortManagerEvent.ANSWER_GENERATED,
true, null, null);
+ break;
+ default:
+ //ignore
+ }
+ */
+ case ReturnCode.ENDPOINT_UNKNOWN :
+ try {
+ connection.fsm.signal(ConnectionTransition.FAILURE);
+ } catch (UnknownTransitionException e) {
+ }
+// fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE,
false,
+// SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
+ return true;
+ default:
+ try {
+ connection.fsm.signal(ConnectionTransition.FAILURE);
+ } catch (UnknownTransitionException e) {
+ }
+ return true;
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/DeleteConnectionRequest.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.message.DeleteConnection;
+import jain.protocol.ip.mgcp.message.parms.CallIdentifier;
+import jain.protocol.ip.mgcp.message.parms.ConnectionIdentifier;
+import jain.protocol.ip.mgcp.message.parms.EndpointIdentifier;
+import org.mobicents.fsm.State;
+import org.mobicents.fsm.StateEventHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DeleteConnectionRequest implements StateEventHandler {
+ private NetworkConnectionImpl connection;
+
+ protected DeleteConnectionRequest(NetworkConnectionImpl connection) {
+ this.connection = connection;
+ }
+
+ public void onEvent(State state) {
+ //prepear callID and endpointID parameters for request
+ CallIdentifier callId = connection.getSession().getCallID();
+ EndpointIdentifier endpointID = connection.endpointName;
+ ConnectionIdentifier connectionID = connection.getConnectionID();
+ //ask for new unique transaction handler
+ int txHandle = connection.getSession().getUniqueHandler();
+
+ //ask for new unique transaction handler
+ DeleteConnection req = new DeleteConnection(this, callId,
endpointID, connectionID);
+ req.setTransactionHandle(txHandle);
+
+// new DeleteConnectionResponseHandler(txHandle);
+ //send request
+ connection.getSession().getDriver().send(req);
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/DeleteConnectionResponseHandler.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.JainMgcpCommandEvent;
+import jain.protocol.ip.mgcp.JainMgcpResponseEvent;
+import jain.protocol.ip.mgcp.message.DeleteConnectionResponse;
+import org.mobicents.fsm.UnknownTransitionException;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionTransition;
+import org.mobicents.javax.media.mscontrol.spi.MgcpTransactionHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DeleteConnectionResponseHandler extends
MgcpTransactionHandler {
+ private NetworkConnectionImpl connection;
+
+ public DeleteConnectionResponseHandler(int txID, NetworkConnectionImpl
connection) {
+ super(txID, connection.getSession().getDriver());
+ this.connection = connection;
+ }
+
+ @Override
+ public boolean processCommandEvent(JainMgcpCommandEvent evt) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean processResponseEvent(JainMgcpResponseEvent evt) {
+ DeleteConnectionResponse response = (DeleteConnectionResponse) evt;
+ try {
+ connection.fsm.signal(ConnectionTransition.CLOSED);
+ } catch (UnknownTransitionException e) {
+ }
+ return true;
+ }
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ModifyConnectionRequest.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.message.ModifyConnection;
+import jain.protocol.ip.mgcp.message.parms.CallIdentifier;
+import jain.protocol.ip.mgcp.message.parms.ConnectionDescriptor;
+import jain.protocol.ip.mgcp.message.parms.ConnectionIdentifier;
+import jain.protocol.ip.mgcp.message.parms.EndpointIdentifier;
+import org.mobicents.fsm.State;
+import org.mobicents.fsm.TransitionHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class ModifyConnectionRequest implements TransitionHandler {
+ private NetworkConnectionImpl connection;
+
+ protected ModifyConnectionRequest(NetworkConnectionImpl connection) {
+ this.connection = connection;
+ }
+
+ public void process(State state) {
+ //prepear callID and endpointID parameters for request
+ CallIdentifier callId = connection.getSession().getCallID();
+ EndpointIdentifier endpointID = connection.endpointName;
+ ConnectionIdentifier connectionID = connection.getConnectionID();
+
+ //ask for new unique transaction handler
+ int txHandle = connection.getSession().getUniqueHandler();
+
+ ModifyConnection req = new ModifyConnection(this, callId,
endpointID, connectionID);
+ req.setTransactionHandle(txHandle);
+
+// new ModifyConnectionResponseHandler(txHandle);
+ try {
+ req.setRemoteConnectionDescriptor(new
ConnectionDescriptor(connection.sdpPortManager.remoteSdp));
+ } catch (Exception e) {
+ }
+
+ //send request
+ connection.getSession().getDriver().send(req);
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ModifyConnectionResponseHandler.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.mobicents.javax.media.mscontrol.networkconnection;
+
+import jain.protocol.ip.mgcp.JainMgcpCommandEvent;
+import jain.protocol.ip.mgcp.JainMgcpResponseEvent;
+import jain.protocol.ip.mgcp.message.ModifyConnectionResponse;
+import jain.protocol.ip.mgcp.message.parms.ReturnCode;
+import org.mobicents.fsm.UnknownTransitionException;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionTransition;
+import org.mobicents.javax.media.mscontrol.spi.MgcpTransactionHandler;
+
+/**
+ *
+ * @author kulikov
+ */
+public class ModifyConnectionResponseHandler extends
MgcpTransactionHandler {
+ private NetworkConnectionImpl connection;
+
+ public ModifyConnectionResponseHandler(int txID, NetworkConnectionImpl
connection) {
+ super(txID, connection.getSession().getDriver());
+ this.connection = connection;
+ }
+
+ @Override
+ public boolean processCommandEvent(JainMgcpCommandEvent evt) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean processResponseEvent(JainMgcpResponseEvent evt) {
+ ModifyConnectionResponse resp = (ModifyConnectionResponse) evt;
+ switch (resp.getReturnCode().getValue()) {
+ case ReturnCode.TRANSACTION_BEING_EXECUTED:
+ return false;
+ case ReturnCode.TRANSACTION_EXECUTED_NORMALLY:
+ connection.sdpPortManager.localSdp =
resp.getLocalConnectionDescriptor().toString();
+ try {
+ connection.fsm.signal(ConnectionTransition.OPENED);
+ } catch (UnknownTransitionException e) {
+ }
+ return true;
+ case ReturnCode.ENDPOINT_UNKNOWN :
+ return true;
+// fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE,
false,
+// SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
+ case ReturnCode.CONNECTION_WAS_DELETED:
+ return true;
+// connection.state = ConnectionState.CLOSED;
+// fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE,
false,
+// SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
+ default:
+ return true;
+// connection.state = ConnectionState.INVALID;
+// fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE,
false,
+// SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
+
+ }
+ }
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/fsm/ConnectionState.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.mobicents.javax.media.mscontrol.networkconnection.fsm;
+
+/**
+ *
+ * @author kulikov
+ */
+public interface ConnectionState {
+ public final static String NULL = "NULL";
+ public final static String OPENING = "OPEN";
+ public final static String OPEN= "OPEN";
+ public final static String HALF_OPEN = "HALF_OPEN";
+ public final static String CANCELED = "CANCELED";
+ public final static String MODIFYING = "MODIFYING";
+ public final static String CLOSING = "CLOSING";
+ public final static String FAILED = "FAILED";
+ public final static String INVALID = "INVALID";
+}
=======================================
--- /dev/null
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/fsm/ConnectionTransition.java
Mon Dec 6 04:04:45 2010
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but
WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.mobicents.javax.media.mscontrol.networkconnection.fsm;
+
+/**
+ *
+ * @author kulikov
+ */
+public interface ConnectionTransition {
+ public final static String OPEN = "crcx";
+ public final static String OPENED = "opened";
+ public final static String CREATED = "created";
+ public final static String MODIFY = "modify";
+ public final static String FAILURE = "failure";
+ public final static String CLOSE = "close";
+ public final static String CLOSED = "closed";
+}
=======================================
---
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/ConnectionState.java
Tue Nov 30 08:24:58 2010
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as
indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- * This program is distributed in the hope that it will be useful, but
WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-
-package org.mobicents.javax.media.mscontrol.networkconnection;
-
-/**
- *
- * @author kulikov
- */
-public enum ConnectionState {
- NULL, OPENING, OPENING_WITH_REMOTE_SDP, HALF_OPENED, MODIFYING,
OPENED, CLOSING, CLOSED, INVALID;
-}
=======================================
---
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/NetworkConnectionImpl.java
Tue Nov 30 08:24:58 2010
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/NetworkConnectionImpl.java
Mon Dec 6 04:04:45 2010
@@ -8,7 +8,6 @@
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.locks.ReentrantLock;
import javax.media.mscontrol.MediaConfig;
import javax.media.mscontrol.MediaEvent;
import javax.media.mscontrol.MediaEventListener;
@@ -19,14 +18,18 @@
import javax.media.mscontrol.join.Joinable;
import javax.media.mscontrol.networkconnection.NetworkConnection;
import javax.media.mscontrol.networkconnection.SdpPortManager;
+import javax.media.mscontrol.networkconnection.SdpPortManagerEvent;
import javax.media.mscontrol.resource.Action;
import javax.media.mscontrol.resource.AllocationEventListener;
import org.apache.log4j.Logger;
+import org.mobicents.fsm.FSM;
import org.mobicents.javax.media.mscontrol.AbstractJoinableContainer;
import org.mobicents.javax.media.mscontrol.MediaConfigImpl;
import org.mobicents.javax.media.mscontrol.MediaSessionImpl;
import org.mobicents.javax.media.mscontrol.ParametersImpl;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionState;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionTransition;
/**
*
@@ -38,16 +41,15 @@
private final static String PACKET_RELAY
= "/mobicents/media/packetrelay/$";
private URI uri = null;
- private SdpPortManager sdpPortManager = null;
+ protected SdpPortManagerImpl sdpPortManager = null;
protected EndpointIdentifier endpointName;
protected ConnectionIdentifier connectionID;
- protected ConnectionState state = ConnectionState.NULL;
- protected ReentrantLock fsmLock = new ReentrantLock();
-
protected CopyOnWriteArrayList<MediaEventListener<? extends
MediaEvent<?>>> eventListenerList = new
CopyOnWriteArrayList<MediaEventListener<? extends MediaEvent<?>>>();
-
+
+ //FSM processor
+ protected FSM fsm;
private static Logger logger =
Logger.getLogger(NetworkConnectionImpl.class);
public NetworkConnectionImpl(MediaSessionImpl session, MediaConfigImpl
config) throws MsControlException {
@@ -73,8 +75,111 @@
maxJoinees = 1;
sdpPortManager = new SdpPortManagerImpl(this);
+
+ this.initFSM();
}
+ private void initFSM() {
+ fsm = new FSM();
+ fsm.createState(ConnectionState.NULL);
+ fsm.createState(ConnectionState.OPENING);
+ fsm.createState(ConnectionState.OPEN);
+ fsm.createState(ConnectionState.HALF_OPEN);
+ fsm.createState(ConnectionState.MODIFYING);
+ fsm.createState(ConnectionState.CLOSING).setOnEnter(
+ new DeleteConnectionRequest(this));
+ fsm.createState(ConnectionState.FAILED).setOnEnter(
+ new SdpPortManagerEventImpl(sdpPortManager,
SdpPortManagerEvent.NETWORK_STREAM_FAILURE));
+ fsm.createState(ConnectionState.INVALID);
+
+ fsm.setStart(ConnectionState.NULL);
+ fsm.setEnd(ConnectionState.INVALID);
+
+
//******************************************************************/
+ // STATE
NULL /
+
//******************************************************************/
+ //transition from NULL to OPENING
+ fsm.createTransition(ConnectionTransition.OPEN,
+ ConnectionState.NULL, ConnectionState.OPENING).setHandler(
+ new CreateConnectionRequest(this));
+
+
//******************************************************************/
+ // STATE
OPENING /
+
//******************************************************************/
+ //transition from OPENING to OPEN
+ fsm.createTransition(ConnectionTransition.OPENED,
+ ConnectionState.OPENING, ConnectionState.OPEN);
+
+ //transition from OPENING to HALF_OPEN
+ fsm.createTransition(ConnectionTransition.CREATED,
+ ConnectionState.OPENING, ConnectionState.HALF_OPEN);
+
+ //transition from OPENING to CANCELED
+ fsm.createTransition(ConnectionTransition.CLOSE,
+ ConnectionState.OPENING, ConnectionState.CANCELED);
+
+ //transition from OPENING to FAILED
+ fsm.createTransition(ConnectionTransition.FAILURE,
+ ConnectionState.OPENING, ConnectionState.FAILED);
+
+ //transition from OPENING to FAILED
+ fsm.createTimeoutTransition(
+ ConnectionState.OPENING, ConnectionState.FAILED, 5000);
+
+
+
+
//******************************************************************/
+ // STATE
OPENED /
+
//******************************************************************/
+ //transition to CLOSING
+ fsm.createTransition(ConnectionTransition.CLOSE,
+ ConnectionState.OPEN, ConnectionState.CLOSING);
+
+
//******************************************************************/
+ // STATE
HALF_OPEN /
+
//******************************************************************/
+ //transition to MODIFYING
+ fsm.createTransition(ConnectionTransition.MODIFY,
+ ConnectionState.HALF_OPEN,
ConnectionState.MODIFYING).setHandler(
+ new ModifyConnectionRequest(this));
+
+ //transition to CLOSING
+ fsm.createTransition(ConnectionTransition.CLOSE,
+ ConnectionState.HALF_OPEN, ConnectionState.CLOSING);
+
+
+
+
//******************************************************************/
+ // STATE
MODIFYING /
+
//******************************************************************/
+ //transition to OPEN
+ fsm.createTransition(
+ ConnectionTransition.OPENED,
+ ConnectionState.MODIFYING, ConnectionState.OPEN);
+ //transition to FAILED
+ fsm.createTransition(
+ ConnectionTransition.FAILURE,
+ ConnectionState.MODIFYING, ConnectionState.FAILED);
+ //transition to CLOSING
+ fsm.createTransition(ConnectionTransition.CLOSE,
+ ConnectionState.MODIFYING, ConnectionState.CLOSING);
+
+
//******************************************************************/
+ // STATE
CANCELED /
+
//******************************************************************/
+ //transition to CLOSING upon OPENED signal
+ fsm.createTransition(ConnectionTransition.OPENED,
+ ConnectionState.CANCELED, ConnectionState.CLOSING);
+
+ //transition to CLOSING upon CREATED signal
+ fsm.createTransition(ConnectionTransition.CREATED,
+ ConnectionState.CANCELED, ConnectionState.CLOSING);
+
+ //transition to CLOSING without signals
+ fsm.createTimeoutTransition(
+ ConnectionState.CANCELED, ConnectionState.FAILED, 5000);
+ }
+
protected ConnectionIdentifier getConnectionID() {
return connectionID;
}
=======================================
---
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerEventImpl.java
Tue Nov 30 08:24:58 2010
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerEventImpl.java
Mon Dec 6 04:04:45 2010
@@ -6,38 +6,37 @@
import javax.media.mscontrol.networkconnection.SdpPortManager;
import javax.media.mscontrol.networkconnection.SdpPortManagerEvent;
import javax.media.mscontrol.resource.Trigger;
+import org.mobicents.fsm.State;
+import org.mobicents.fsm.StateEventHandler;
+import org.mobicents.fsm.TransitionHandler;
/**
*
* @author amit.bhayani
- *
+ * @author okulikov
*/
-public class SdpPortManagerEventImpl implements SdpPortManagerEvent {
-
- private SdpPortManager source = null;
+public class SdpPortManagerEventImpl implements SdpPortManagerEvent,
TransitionHandler, StateEventHandler {
+
+ private SdpPortManagerImpl source = null;
private MediaErr error = MediaErr.NO_ERROR;
private String errorText = null;
private EventType eventType = null;
- private byte[] mediaServerSdp = null;
private boolean isSuccessful = false;
- public SdpPortManagerEventImpl(SdpPortManager source, EventType
eventType, byte[] mediaServerSdp,
- boolean isSuccessful) {
+ public SdpPortManagerEventImpl(SdpPortManagerImpl source, EventType
eventType) {
this.source = source;
this.eventType = eventType;
- this.mediaServerSdp = mediaServerSdp;
- this.isSuccessful = isSuccessful;
+ this.isSuccessful = true;
}
- public SdpPortManagerEventImpl(SdpPortManager source, EventType
eventType, byte[] mediaServerSdp,
+ public SdpPortManagerEventImpl(SdpPortManagerImpl source, EventType
eventType,
boolean isSuccessful, MediaErr error, String errorText) {
- this(source, eventType, mediaServerSdp, isSuccessful);
this.error = error;
this.errorText = errorText;
}
public byte[] getMediaServerSdp() {
- return this.mediaServerSdp;
+ return source.localSdp.getBytes();
}
public Qualifier getQualifier() {
@@ -74,4 +73,12 @@
public String toString() {
return eventType.toString();
}
-}
+
+ public void process(State state) {
+ source.fireEvent(this);
+ }
+
+ public void onEvent(State state) {
+ source.fireEvent(this);
+ }
+}
=======================================
---
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerImpl.java
Tue Nov 30 08:24:58 2010
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/networkconnection/SdpPortManagerImpl.java
Mon Dec 6 04:04:45 2010
@@ -18,22 +18,7 @@
package org.mobicents.javax.media.mscontrol.networkconnection;
-import jain.protocol.ip.mgcp.JainMgcpCommandEvent;
-import jain.protocol.ip.mgcp.JainMgcpResponseEvent;
-import jain.protocol.ip.mgcp.message.CreateConnection;
-import jain.protocol.ip.mgcp.message.CreateConnectionResponse;
-import jain.protocol.ip.mgcp.message.DeleteConnection;
-import jain.protocol.ip.mgcp.message.ModifyConnection;
-import jain.protocol.ip.mgcp.message.ModifyConnectionResponse;
-import jain.protocol.ip.mgcp.message.parms.CallIdentifier;
-import jain.protocol.ip.mgcp.message.parms.ConnectionDescriptor;
-import jain.protocol.ip.mgcp.message.parms.ConnectionIdentifier;
-import jain.protocol.ip.mgcp.message.parms.ConnectionMode;
-import jain.protocol.ip.mgcp.message.parms.EndpointIdentifier;
-import jain.protocol.ip.mgcp.message.parms.ReturnCode;
-import java.util.ArrayList;
-import javax.media.mscontrol.EventType;
-import javax.media.mscontrol.MediaErr;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.media.mscontrol.MediaEventListener;
import javax.media.mscontrol.MediaSession;
import javax.media.mscontrol.networkconnection.CodecPolicy;
@@ -41,7 +26,8 @@
import javax.media.mscontrol.networkconnection.SdpPortManager;
import javax.media.mscontrol.networkconnection.SdpPortManagerEvent;
import javax.media.mscontrol.networkconnection.SdpPortManagerException;
-import org.mobicents.javax.media.mscontrol.spi.MgcpTransactionHandler;
+import org.mobicents.fsm.UnknownTransitionException;
+import
org.mobicents.javax.media.mscontrol.networkconnection.fsm.ConnectionTransition;
/**
*
@@ -51,10 +37,10 @@
private NetworkConnectionImpl connection;
- private String localSdp;
- private String remoteSdp;
-
- private ArrayList<MediaEventListener> listeners = new ArrayList();
+ protected String localSdp;
+ protected String remoteSdp;
+
+ private CopyOnWriteArrayList<MediaEventListener> listeners = new
CopyOnWriteArrayList();
private CodecPolicy codecPolicy = null;
@@ -63,7 +49,12 @@
}
public void generateSdpOffer() throws SdpPortManagerException {
- connection.fsmLock.lock();
+ try {
+ connection.fsm.signal(ConnectionTransition.OPEN);
+ } catch (UnknownTransitionException e) {
+ throw new SdpPortManagerException(e.getMessage());
+ }
+/* connection.fsmLock.lock();
try {
//check for connection's state first
if (connection.state != ConnectionState.NULL) {
@@ -77,10 +68,17 @@
} finally {
connection.fsmLock.unlock();
}
+ */
}
public void processSdpOffer(byte[] sdp) throws SdpPortManagerException
{
- connection.fsmLock.lock();
+ try {
+ connection.fsm.signal(ConnectionTransition.OPEN);
+ } catch (UnknownTransitionException e) {
+ throw new SdpPortManagerException(e.getMessage());
+ }
+
+/* connection.fsmLock.lock();
try {
//we are expecting that connection is not created yet and
//there is request with sdp
@@ -95,12 +93,18 @@
} finally {
connection.fsmLock.unlock();
}
+ */
}
public void processSdpAnswer(byte[] sdp) throws
SdpPortManagerException {
+ try {
+ connection.fsm.signal(ConnectionTransition.MODIFY);
+ } catch (UnknownTransitionException e) {
+ throw new SdpPortManagerException(e.getMessage());
+ }
//it is supposed that connection already exist and we need modify
//remote sdp
- connection.fsmLock.lock();
+/* connection.fsmLock.lock();
try {
if (connection.state != ConnectionState.HALF_OPENED) {
throw new SdpPortManagerException("Illegal state: " +
connection.state);
@@ -113,10 +117,15 @@
} finally {
connection.fsmLock.unlock();
}
+ */
}
public void rejectSdpOffer() throws SdpPortManagerException {
- deleteConnection();
+ try {
+ connection.fsm.signal(ConnectionTransition.CLOSE);
+ } catch (UnknownTransitionException e) {
+ throw new SdpPortManagerException(e.getMessage());
+ }
}
public byte[] getMediaServerSessionDescription() throws
SdpPortManagerException {
@@ -140,273 +149,29 @@
}
public void addListener(MediaEventListener<SdpPortManagerEvent>
listener) {
- connection.fsmLock.lock();
- try {
- System.out.println("==== CALLED ADD LISTENER");
- listeners.add(listener);
- } finally {
- connection.fsmLock.unlock();
- }
+ listeners.add(listener);
}
public void removeListener(MediaEventListener<SdpPortManagerEvent>
listener) {
- connection.fsmLock.lock();
- try {
- listeners.remove(listener);
- } finally {
- connection.fsmLock.unlock();
- }
+ listeners.remove(listener);
}
public MediaSession getMediaSession() {
return connection.getMediaSession();
}
- private void fireEvent(SdpPortManagerEvent evt) {
+ protected void fireEvent(SdpPortManagerEvent evt) {
for (MediaEventListener listener : listeners) {
listener.onEvent(evt);
}
}
- private void fireEvent(EventType eventType, boolean isSuccessful,
MediaErr err, String text) {
- connection.fsmLock.lock();
- try {
- byte[] rawSdp = localSdp != null ? localSdp.getBytes() : null;
- SdpPortManagerEventImpl evt = new
SdpPortManagerEventImpl(this, eventType, rawSdp, isSuccessful, err, text);
- fireEvent(evt);
- } finally {
- connection.fsmLock.unlock();
- }
- }
-
- /**
- * Sends request for creating connection
- *
- * @param sdp the sdp offer
- */
- private void createConnection(String sdp) {
- //prepear callID and endpointID parameters for request
- CallIdentifier callId = connection.getSession().getCallID();
- EndpointIdentifier endpointID = connection.endpointName;
-
- //ask for new unique transaction handler
- int txHandle = connection.getSession().getUniqueHandler();
-
- //generate message
- CreateConnection req = new CreateConnection(this, callId,
endpointID, ConnectionMode.SendRecv);
- req.setTransactionHandle(txHandle);
-
req.setNotifiedEntity(connection.getSession().getDriver().getCallAgent());
-
- //if SDP is present assign it to request
- if (sdp != null) {
- try {
- req.setRemoteConnectionDescriptor(new
ConnectionDescriptor(sdp));
- } catch (Exception e) {
- }
- }
-
- //create handler for this tx
- new CreateConnectionResponseHandler(txHandle);
- //send request
- connection.getSession().getDriver().send(req);
- }
-
- /**
- * Sends request for deleting connection
- */
- private void deleteConnection() {
- //prepear callID and endpointID parameters for request
- CallIdentifier callId = connection.getSession().getCallID();
- EndpointIdentifier endpointID = connection.endpointName;
- ConnectionIdentifier connectionID = connection.getConnectionID();
- //ask for new unique transaction handler
- int txHandle = connection.getSession().getUniqueHandler();
-
- //ask for new unique transaction handler
- DeleteConnection req = new DeleteConnection(this, callId,
endpointID, connectionID);
- req.setTransactionHandle(txHandle);
-
- new DeleteConnectionResponseHandler(txHandle);
- //send request
- connection.getSession().getDriver().send(req);
- }
-
- /**
- * Sends request for connection modification.
- *
- * @param sdp the new sdp value.
- */
- private void modifyConnection(String sdp) {
- //prepear callID and endpointID parameters for request
- CallIdentifier callId = connection.getSession().getCallID();
- EndpointIdentifier endpointID = connection.endpointName;
- ConnectionIdentifier connectionID = connection.getConnectionID();
-
- //ask for new unique transaction handler
- int txHandle = connection.getSession().getUniqueHandler();
-
- ModifyConnection req = new ModifyConnection(this, callId,
endpointID, connectionID);
- req.setTransactionHandle(txHandle);
-
- new ModifyConnectionResponseHandler(txHandle);
- try {
- req.setRemoteConnectionDescriptor(new
ConnectionDescriptor(sdp));
- } catch (Exception e) {
- }
-
- //send request
- connection.getSession().getDriver().send(req);
- }
-
- private class CreateConnectionResponseHandler extends
MgcpTransactionHandler {
-
- public CreateConnectionResponseHandler(int txID) {
- super(txID, connection.getSession().getDriver());
- }
-
- public void processCommandEvent(JainMgcpCommandEvent arg0) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- private void updateParameters(CreateConnectionResponse resp) {
- //extract endpoint name, connection id and local descriptor
- connection.connectionID = resp.getConnectionIdentifier();
- localSdp = resp.getLocalConnectionDescriptor().toString();
- connection.endpointName = resp.getSpecificEndpointIdentifier();
- }
-
- public void processResponseEvent(JainMgcpResponseEvent response) {
- System.out.println("Receive CRCX response");
- connection.fsmLock.lock();
- try {
- CreateConnectionResponse resp = (CreateConnectionResponse)
response;
- switch (resp.getReturnCode().getValue()) {
- case ReturnCode.TRANSACTION_BEING_EXECUTED :
- //provisional response, still waiting
- //ignore current state
- break;
- case ReturnCode.TRANSACTION_EXECUTED_NORMALLY :
- switch (connection.state) {
- case OPENING :
- //extract endpoint name, connection id and
local descriptor
- updateParameters(resp);
- connection.state =
ConnectionState.HALF_OPENED;
-
fireEvent(SdpPortManagerEvent.OFFER_GENERATED, true, null, null);
- break;
- case OPENING_WITH_REMOTE_SDP :
- //extract endpoint name, connection id and
local descriptor
- updateParameters(resp);
- connection.state = ConnectionState.OPENED;
-
fireEvent(SdpPortManagerEvent.ANSWER_GENERATED, true, null, null);
- break;
- default :
- //ignore
- }
- break;
- case ReturnCode.ENDPOINT_UNKNOWN :
- System.out.println("Network stream failure
detected");
- connection.state = ConnectionState.INVALID;
-
fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE, false,
- SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
- break;
- default :
- connection.state = ConnectionState.INVALID;
-
fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE, false,
- SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
-
- }
- } finally {
- connection.fsmLock.unlock();
- }
- }
-
- }
-
- private class ModifyConnectionResponseHandler extends
MgcpTransactionHandler {
-
- public ModifyConnectionResponseHandler(int txID) {
- super(txID, connection.getSession().getDriver());
- }
-
- public void processCommandEvent(JainMgcpCommandEvent arg0) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- private void updateParameters(ModifyConnectionResponse resp) {
- //extract endpoint name, connection id and local descriptor
- localSdp = resp.getLocalConnectionDescriptor().toString();
- }
-
- public void processResponseEvent(JainMgcpResponseEvent response) {
- connection.fsmLock.lock();
- try {
- ModifyConnectionResponse resp = (ModifyConnectionResponse)
response;
- switch (resp.getReturnCode().getValue()) {
- case ReturnCode.TRANSACTION_BEING_EXECUTED :
- //provisional response, still waiting
- //ignore current state
- break;
- case ReturnCode.TRANSACTION_EXECUTED_NORMALLY :
- switch (connection.state) {
- case HALF_OPENED :
- case OPENED :
- //extract endpoint name, connection id and
local descriptor
- updateParameters(resp);
- connection.state =
ConnectionState.HALF_OPENED;
-
fireEvent(SdpPortManagerEvent.ANSWER_PROCESSED, true, null, null);
- break;
- default :
- //ignore
- }
- break;
- case ReturnCode.ENDPOINT_UNKNOWN :
- connection.state = ConnectionState.INVALID;
-
fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE, false,
- SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
- case ReturnCode.CONNECTION_WAS_DELETED :
- connection.state = ConnectionState.CLOSED;
-
fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE, false,
- SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
- default :
- connection.state = ConnectionState.INVALID;
-
fireEvent(SdpPortManagerEvent.NETWORK_STREAM_FAILURE, false,
- SdpPortManagerEvent.RESOURCE_UNAVAILABLE,
resp.getReturnCode().getComment());
-
- }
- } finally {
- connection.fsmLock.unlock();
- }
- }
-
- }
-
- private class DeleteConnectionResponseHandler extends
MgcpTransactionHandler {
-
- public DeleteConnectionResponseHandler(int txID) {
- super(txID, connection.getSession().getDriver());
- }
-
- public void processCommandEvent(JainMgcpCommandEvent arg0) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void processResponseEvent(JainMgcpResponseEvent response) {
- connection.fsmLock.lock();
- try {
- ModifyConnectionResponse resp = (ModifyConnectionResponse)
response;
- switch (resp.getReturnCode().getValue()) {
- case ReturnCode.TRANSACTION_BEING_EXECUTED :
- //provisional response, still waiting
- //ignore current state
- break;
- case ReturnCode.TRANSACTION_EXECUTED_NORMALLY :
- connection.state = ConnectionState.CLOSED;
- }
- } finally {
- connection.fsmLock.unlock();
- }
- }
-
- }
+// protected void fireEvent(EventType eventType, boolean isSuccessful,
MediaErr err, String text) {
+// byte[] rawSdp = localSdp != null ? localSdp.getBytes() : null;
+// SdpPortManagerEventImpl evt = new SdpPortManagerEventImpl(this,
eventType, rawSdp, isSuccessful, err, text);
+// fireEvent(evt);
+// }
+
+
}
=======================================
---
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/spi/MgcpTransactionHandler.java
Tue Nov 30 08:24:58 2010
+++
/trunk/servers/media/jsr-309/core/src/main/java/org/mobicents/javax/media/mscontrol/spi/MgcpTransactionHandler.java
Mon Dec 6 04:04:45 2010
@@ -52,26 +52,28 @@
public void processMgcpCommandEvent(JainMgcpCommandEvent evt) {
//process commands with expected txID only
+ boolean done = true;
if (evt.getTransactionHandle() == this.txID) {
try {
- this.processCommandEvent(evt);
+ done = processCommandEvent(evt);
} finally {
- driver.removeListener(this);
+ if (done) driver.removeListener(this);
}
}
}
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) {
//process responses with expected txID only
+ boolean done = true;
if (evt.getTransactionHandle() == this.txID) {
try {
- this.processResponseEvent(evt);
+ done = processResponseEvent(evt);
} finally {
- driver.removeListener(this);
+ if (done) driver.removeListener(this);
}
}
}
- public abstract void processCommandEvent(JainMgcpCommandEvent evt);
- public abstract void processResponseEvent(JainMgcpResponseEvent evt);
-}
+ public abstract boolean processCommandEvent(JainMgcpCommandEvent evt);
+ public abstract boolean processResponseEvent(JainMgcpResponseEvent
evt);
+}