Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: call.cpp
- Revision:
- 104:62646ef786a3
- Parent:
- 92:92df17f538a8
- Child:
- 105:a930035b6556
diff -r e3cabfc2f533 -r 62646ef786a3 call.cpp --- a/call.cpp Thu Feb 19 18:04:33 2015 +0000 +++ b/call.cpp Wed Feb 25 18:44:11 2015 +0000 @@ -7,10 +7,9 @@ this->rtp_server_ext = rtp_server_ext; this->rtp_server_port = rtp_server_port; this->rtp_server.set_address( __RTP_SEVER_IP__, rtp_server_port ); - //rtp_sock.set_blocking( false, 3 ); - rtp_sock.set_blocking( false, 0 ); + this->rtp_sock.set_blocking( false, 0 ); this->rtp_sock.bind( cb_port ); // rtp port - this->rtp_sock.init(); + //this->rtp_sock.init(); this->rtp = new RTP( this->cb_ext ); if( rtp == NULL ) @@ -33,7 +32,9 @@ char * VZ_call::get_eth_message( int * length ){ uint8_t * pkg; - *length = rtp_sock.receiveFrom( rtp_server, server2cb, sizeof( server2cb ) ); + Endpoint rtp_from; + + *length = rtp_sock.receiveFrom( rtp_from, server2cb, sizeof( server2cb ) ); t.reset(); rtpbuf_next( &rtpbuf ); @@ -55,16 +56,17 @@ int VZ_call::send_message( char * buffer ){ t.reset(); - return( this->rtp_sock.sendTo( this->rtp_server, buffer, __CB_AUDIO_DATA_SIZE__ + this->rtp->header_size() ) ); + 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() ) + { + if( debug_reconnect ) + { + send_msg("Reconnect RTP"); + } + reconnect(); + } - /* - //FIXME verificar como fica se eu esperar o sendTo chegar em != 0 - int8_t sent = 0; - do{ - sent = this->rtp_sock.sendTo( this->rtp_server, buffer, __CB_AUDIO_DATA_SIZE__ + this->rtp->header_size() ) ); - }while( sent == 0 ); - return( sent ); - */ + return( send ); } uint8_t * VZ_call::build_cb_package( void ){ @@ -109,4 +111,11 @@ void VZ_call::init_cbx_pkg_idle_timer(){ cbx_pkg_idle_timer.start(); +} + +void VZ_call::reconnect( void ) +{ + this->rtp_sock.close(); + this->rtp_sock.set_blocking( false, 0 ); + this->rtp_sock.bind( cb_port ); } \ No newline at end of file