Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
87:679ee0d594a9
Parent:
86:bf7b0d4c3232
Child:
89:0fe315117b00
--- a/sip.cpp	Mon Jan 05 12:43:12 2015 +0000
+++ b/sip.cpp	Tue Jan 06 16:37:03 2015 +0000
@@ -194,10 +194,14 @@
     char callbox_string[ 32 ];
     itoa( get_id(), callbox_string, 10 );
     static int invite_pkg_sent;
+    static VZ_call * call = NULL;
+    
     if( status != sip_on_call ){
         if( status == sip_idle ){
             int cseq = 0;
  
+            call = NULL;
+ 
             build_invite_package( buffer, callbox_string, &cseq );
             invite_pkg_sent = 0;
             do{
@@ -227,7 +231,6 @@
     static int ok_sent = 0;
     static bool waiting = false;
     static uint16_t length_muted = 0;
-    VZ_call * call = NULL;
     
     if( invite_timer.read() > __INVITE_MAX_WAITING_TIME__ ){
         if( debug_invite == true ) send_msg("Invite call timeout :(");
@@ -266,7 +269,11 @@
                 if( ref != NULL ){
                     ref += 6; // audio 
                     ref = strtok( ref, " ");
-                    if( call == NULL ) call = new VZ_call( this->my_ext, this->my_rtp_port, this->peer_ext, atoi( ref ) );
+                    if( call == NULL ){
+                        debug_msg("");
+                        call = new VZ_call( this->my_ext, this->my_rtp_port, this->peer_ext, atoi( ref ) );
+                        if( call == NULL ) memory_is_over = true;
+                    }
                     char ans[ 1024 ];
                     build_ack_package( ans, ( unsigned char *)buffer );
                     
@@ -284,7 +291,7 @@
             if( !( strncasecmp( buffer + 12, "Busy Here", strlen("Busy Here") ) ) ){
                 if( debug_sip ) debug_msg("Busy Here");
                 send_bye();
-                delete( call );
+                if( call != NULL ) delete( call );
                 set_status( status, sip_busy );
                 return( NULL );  
             }else if( !( strncasecmp( buffer + 12, "Session Progress", strlen("Session Progress") ) ) ){
@@ -292,7 +299,11 @@
                 if( ref != NULL ){
                     ref += 6; // strlen( "audio" ) == 6
                     ref = strtok( ref, " ");
-                    if( call == NULL ) call = new VZ_call( this->my_ext, this->my_rtp_port, this->peer_ext, atoi( ref ) );
+                    if( call == NULL ){
+                        debug_msg("");
+                        call = new VZ_call( this->my_ext, this->my_rtp_port, this->peer_ext, atoi( ref ) );
+                        if( call == NULL ) memory_is_over = true;
+                    }
                     waiting = true;
                 }
             }