Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
132:05cd37f7e007
Parent:
121:ee02790d00b7
Child:
135:2f4290590e51
--- a/call.cpp	Tue Jul 21 20:03:35 2015 +0000
+++ b/call.cpp	Tue Sep 01 17:21:11 2015 +0000
@@ -15,7 +15,7 @@
     if( rtp == NULL )
     { 
         memory_is_over = true;
-        if( debug_memory ) debug_msg("[%d] Call_Box cb allocation fail", this->cb_ext );
+        if( debug_memory ) vz_debug ("[%d] Call_Box cb allocation fail", this->cb_ext );
     }
     
     t.start();
@@ -30,44 +30,61 @@
     call_delete_counter++;
 }
 
-char * VZ_call::get_eth_message( int * length ){
+char * 
+VZ_call::get_eth_message ( int * length )
+{
     uint8_t * pkg;
     Endpoint rtp_from;
     
-    *length = rtp_sock.receiveFrom( rtp_server, server2cb, sizeof( server2cb ) );
+    *length = rtp_sock.receiveFrom ( rtp_server, server2cb, sizeof( server2cb ) );
     t.reset();
     
-    rtpbuf_next( &rtpbuf );
+    rtpbuf_next ( &rtpbuf );
     
-    if( *length > 0 ){
-        rtpbuf_put( &rtpbuf, *length - ( RTP_HEADER_SIZE + ( server2cb[ 0 ] & 0xf ) ), 
-            ( uint8_t * )server2cb + ( RTP_HEADER_OFFSET + ( server2cb[ 0 ] & 0xf ) ) );
+    if ( *length > 0 )
+    {
+        rtpbuf_put ( &rtpbuf, *length - ( RTP_HEADER_SIZE + ( server2cb [ 0 ] & 0xf ) ), 
+            ( uint8_t * )server2cb + ( RTP_HEADER_OFFSET + ( server2cb [ 0 ] & 0xf ) ) );
+    } 
+        else if ( *length == -1 )
+    {
+        miss_rtp_udp_rcv_pkg ++;
+        reconnect ();
     }
     
-    pkg = rtpbuf_get( &rtpbuf );
+    pkg = rtpbuf_get ( &rtpbuf );
     
-    if (pkg != NULL) {
+    if ( pkg != NULL )
+    {
         *length = 240;
-        return (char *) pkg;
+        return (char *)pkg;
     }
+    
     *length = 0;
     return NULL;
 }
 
-int VZ_call::send_message ( char * buffer  )
+int 
+VZ_call::send_message ( char * buffer  )
 {
-    this->t.reset();
-    int send = this->rtp_sock.sendTo( this->rtp_server, buffer, CB_AUDIO_DATA_SIZE + this->rtp->header_size() );
-    if( send != CB_AUDIO_DATA_SIZE + this->rtp->header_size() )
+    this -> t.reset ();
+    const uint16_t SEND_MSG_SIZE = CB_AUDIO_DATA_SIZE + this -> rtp -> header_size ();
+    
+    int send = this -> rtp_sock.sendTo ( this -> rtp_server, buffer, SEND_MSG_SIZE );
+    
+    if ( send not_eq SEND_MSG_SIZE )
     {
-        if( debug_reconnect )
+        if ( debug_reconnect )
         {
-            send_msg("[%d] Reconnect RTP", this->cb_ext );
-            miss_ftp_udp_send_pkg++;
+            vz_printf ( "[%d] Reconnect RTP", this -> cb_ext );
         }
-        reconnect();
+        
+        miss_rtp_udp_send_pkg ++;
+        
+        reconnect ();
     }
-    return( send );
+    
+    return ( send );
 }
 
 char * VZ_call::build_eth_package( uint8_t * buffer ){
@@ -103,7 +120,7 @@
     return ( finish.read_ms() );
 }
 
-void VZ_call::cbx_pkg_idle_timer_reset( void ){
+void VZ_call::cbx_pkg_idle_timer_reset ( void ){
     cbx_pkg_idle_timer.reset();
 }
 
@@ -117,19 +134,19 @@
 
 int VZ_call::print_yourself ( void )
 {
-    send_msg("t :: %d", ( int  ) t.read () );
-    send_msg("finish :: %d", ( int ) finish.read () );
-    send_msg("cbx_pkg_idle_timer :: %d", ( int ) cbx_pkg_idle_timer.read () );
-    send_msg("cb_port :: %d", cb_port );
-    send_msg("cb2server :: %p", ( void * ) cb2server );
-    send_msg("server2cb :: %p", ( void * ) server2cb );
-    send_msg("buffer :: %p", ( void * ) buffer );
-    send_msg("rtp_sock :: %p", ( void * )&rtp_sock );
-    send_msg("rtp_server_ext :: %d", rtp_server_ext );
-    send_msg("rtp_server_port :: %d", rtp_server_port );
-    send_msg("rtp_server :: %p", &rtp_server );
-    send_msg("rtp :: %p", ( void * ) rtp );
-    send_msg("rtpbuf :: %p", ( void * ) &rtpbuf );
+    vz_printf ("t :: %d", ( int  ) t.read () );
+    vz_printf ("finish :: %d", ( int ) finish.read () );
+    vz_printf ("cbx_pkg_idle_timer :: %d", ( int ) cbx_pkg_idle_timer.read () );
+    vz_printf ("cb_port :: %d", cb_port );
+    vz_printf ("cb2server :: %p", ( void * ) cb2server );
+    vz_printf ("server2cb :: %p", ( void * ) server2cb );
+    vz_printf ("buffer :: %p", ( void * ) buffer );
+    vz_printf ("rtp_sock :: %p", ( void * )&rtp_sock );
+    vz_printf ("rtp_server_ext :: %d", rtp_server_ext );
+    vz_printf ("rtp_server_port :: %d", rtp_server_port );
+    vz_printf ("rtp_server :: %p", &rtp_server );
+    vz_printf ("rtp :: %p", ( void * ) rtp );
+    vz_printf ("rtpbuf :: %p", ( void * ) &rtpbuf );
     return ( sizeof( VZ_call ) );
 }
 
@@ -140,9 +157,12 @@
     return rtp -> print_yourself ();
 }
 
-void VZ_call::reconnect ( void )
+void 
+VZ_call::reconnect ( void )
 {
-    this->rtp_sock.close();
-    this->rtp_sock.set_blocking( false, 0 );
-    this->rtp_sock.bind( cb_port );
+    this -> rtp_sock.close ();
+    
+    this -> rtp_sock.bind ( cb_port );
+    
+    this -> rtp_sock.set_blocking ( false, 0 );
 }
\ No newline at end of file