]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
added new commands to enable/disable hardware loop and some boost code to handle...
authorMoises Silva <moy@sangoma.com>
Fri, 19 Feb 2010 21:18:13 +0000 (21:18 +0000)
committerMoises Silva <moy@sangoma.com>
Fri, 19 Feb 2010 21:18:13 +0000 (21:18 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@1038 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/include/zap_types.h
libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c
libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c

index 72c467c398b6e12e58d1dc121233b96990773e03..f318da6d567c1060601d14a03c9ba890d5054066 100644 (file)
@@ -284,6 +284,8 @@ typedef enum {
        ZAP_COMMAND_FLUSH_RX_BUFFERS,
        ZAP_COMMAND_FLUSH_BUFFERS,
        ZAP_COMMAND_SET_PRE_BUFFER_SIZE,
+       ZAP_COMMAND_ENABLE_LOOP,
+       ZAP_COMMAND_DISABLE_LOOP,
        ZAP_COMMAND_COUNT
 } zap_command_t;
 
@@ -341,6 +343,7 @@ typedef enum {
        ZAP_CHANNEL_STATE_CANCEL,
        ZAP_CHANNEL_STATE_HANGUP,
        ZAP_CHANNEL_STATE_HANGUP_COMPLETE,
+       ZAP_CHANNEL_STATE_IN_LOOP,
        ZAP_CHANNEL_STATE_INVALID
 } zap_channel_state_t;
 #define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \
index 04ee26ccb0fefa4129d65b25861f84dc999236ed..ffecef279db998a02e01bb5d5c9756a151aafc15 100644 (file)
@@ -774,6 +774,48 @@ static void handle_call_start(zap_span_t *span, sangomabc_connection_t *mcon, sa
                
 }
 
+static void handle_call_loop_start(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
+{
+       zap_status_t res = ZAP_FAIL;
+       zap_channel_t *zchan;
+
+       if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 0))) {
+               zap_log(ZAP_LOG_CRIT, "CANNOT START LOOP, CHAN NOT AVAILABLE %d:%d\n", event->span+1,event->chan+1);
+               return;
+       }
+
+       if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
+               zap_log(ZAP_LOG_CRIT, "CANNOT START LOOP, CANT OPEN CHAN %d:%d\n", event->span+1,event->chan+1);
+               return;
+       }
+
+       zap_set_state_r(zchan, ZAP_CHANNEL_STATE_IN_LOOP, 0, res);
+       if (res != ZAP_SUCCESS) {
+               zap_log(ZAP_LOG_CRIT, "yay, could not set the state of the channel to IN_LOOP, loop will fail\n");
+               zap_channel_done(zchan);
+               /* FIXME: do we need to send an error? */
+               return;
+       }
+       zap_channel_command(zchan, ZAP_COMMAND_ENABLE_LOOP, NULL);
+}
+
+static void handle_call_loop_stop(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
+{
+       zap_channel_t *zchan;
+       zap_status_t res = ZAP_FAIL;
+       if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 1))) {
+               zap_log(ZAP_LOG_CRIT, "CANNOT STOP LOOP, INVALID CHAN REQUESTED %d:%d\n", event->span+1,event->chan+1);
+               return;
+       }
+       if (zchan->state != ZAP_CHANNEL_STATE_IN_LOOP) {
+               zap_log(ZAP_LOG_ERROR, "Got stop loop request in a channel that is not in loop, ignoring ...\n");
+               /* FIXME: do we need to send an error? */
+               return;
+       }
+       zap_channel_command(zchan, ZAP_COMMAND_DISABLE_LOOP, NULL);
+       zap_set_state_r(zchan, ZAP_CHANNEL_STATE_DOWN, 0, res);
+}
+
 /**
  * \brief Handler for heartbeat event
  * \param mcon sangoma boost connection
@@ -955,10 +997,10 @@ static int parse_sangoma_event(zap_span_t *span, sangomabc_connection_t *mcon, s
                nack_map[event->call_setup_id] = 0;
                break;
     case SIGBOOST_EVENT_INSERT_CHECK_LOOP:
-               //handle_call_loop_start(event);
+               handle_call_loop_start(span, mcon, event);
                break;
     case SIGBOOST_EVENT_REMOVE_CHECK_LOOP:
-               //handle_call_stop(event);
+               handle_call_loop_stop(span, mcon, event);
                break;
     case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
                handle_restart_ack(mcon, span, event);
@@ -1177,6 +1219,11 @@ static __inline__ void state_advance(zap_channel_t *zchan)
                        status = zap_span_send_signal(zchan->span, &sig);
                }
                break;
+       case ZAP_CHANNEL_STATE_IN_LOOP:
+               {
+                       /* nothing to do, we sent the ZAP_COMMAND_ENABLE_LOOP command in handle_call_loop_start() right away */
+               }
+               break;
        default:
                break;
        }
@@ -1541,6 +1588,18 @@ static zap_state_map_t boost_state_map = {
                        {ZAP_CHANNEL_STATE_RESTART, ZAP_END},
                        {ZAP_CHANNEL_STATE_DOWN, ZAP_END}
                },
+               {
+                       ZSD_INBOUND,
+                       ZSM_UNACCEPTABLE,
+                       {ZAP_CHANNEL_STATE_DOWN},
+                       {ZAP_CHANNEL_STATE_IN_LOOP, ZAP_END}
+               },
+               {
+                       ZSD_INBOUND,
+                       ZSM_UNACCEPTABLE,
+                       {ZAP_CHANNEL_STATE_IN_LOOP},
+                       {ZAP_CHANNEL_STATE_DOWN, ZAP_END}
+               },
                {
                        ZSD_INBOUND,
                        ZSM_UNACCEPTABLE,
index eba1db346525e58902a4b0eb4c393b8277970e06..190edc2a8d691410d69c79aa734b3cc6fb9b0404 100644 (file)
@@ -593,6 +593,14 @@ static ZIO_COMMAND_FUNCTION(wanpipe_command)
                        //code me
                }
                break;
+       case ZAP_COMMAND_ENABLE_LOOP:
+               {
+                       // code me
+               }
+       case ZAP_COMMAND_DISABLE_LOOP:
+               {
+                       // code me
+               }
        case ZAP_COMMAND_SET_INTERVAL: 
                {
                        err=sangoma_tdm_set_usr_period(zchan->sockfd, &tdm_api, ZAP_COMMAND_OBJ_INT);