![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: call_manager.cpp
- Revision:
- 92:92df17f538a8
- Parent:
- 91:c2a86b1f8aaa
- Child:
- 93:69ccd653c7ca
diff -r c2a86b1f8aaa -r 92df17f538a8 call_manager.cpp --- a/call_manager.cpp Thu Jan 08 23:44:08 2015 +0000 +++ b/call_manager.cpp Sat Jan 10 16:35:11 2015 +0000 @@ -18,7 +18,8 @@ if( cb->get_invite_response() == false ){ invite_pkg_retry_timer.reset(); - cb->set_msg_id( cb->get_msg_id() & ~BIT7 ); + //cb->set_msg_id( cb->get_msg_id() & ~BIT7 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); send2callboxes( __build_cb_package__( cb->get_ext(), cb->get_port(), __INVITE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); @@ -36,7 +37,8 @@ if( cb->get_bye_response() == false ){ bye_pkg_retry_timer.reset(); - cb->set_msg_id( cb->get_msg_id() & ~BIT7 ); + //cb->set_msg_id( cb->get_msg_id() & ~BIT7 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); send2callboxes( __build_cb_package__( cb->get_ext(), cb->get_port(), __CB_BYE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); @@ -60,7 +62,15 @@ void call_manager( Vector * v_call, Vector * v_cb, uint8_t * data, uint8_t * write_buffer, Timeslice * ts ){ for( register uint8_t i = 0; i < v_call->size(); i++ ){ VZ_call * call = ( VZ_call * )v_call->get_element( i ); - if( call->is_timetofinish() ){ + if( call->is_timetofinish() || call->cbx_pkg_is_idle() ){ + + if( debug_invite ){ + if( call->cbx_pkg_is_idle() ){ + debug_msg("Call timeout: no pkg"); + } else { + debug_msg("Call timeout"); + } + } v_call->remove_element( i ); Call_Box * cb = __find_CB__( v_cb, call->get_cb_ext() ); if( cb != NULL ){ @@ -68,7 +78,8 @@ ts->return_timeslice( cb->get_timeslice() ); cb->set_timeslice( 0x00 ); data[ __TIMESLICE_PLACE__ ] = 0x00; - cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); +// cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); send2callboxes( __build_cb_package__( cb->get_ext(), cb->get_port(), __CB_BYE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); cb->send_bye(); @@ -85,8 +96,13 @@ uint8_t data[ __CB_BUFFER_SIZE__ ]; uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; + static uint8_t supress = 0; + if( inviting_cb != NULL ){ - if( inviting_cb->status != cb_on_call ){ + //if( inviting_cb->status != cb_on_call ){ + + //} + if( inviting_cb->status == cb_idle ){ inviting_cb->cb_set_status( cb_trying ); if( debug_invite ) debug_msg("Request invite cbx status :: cb_trying" ); } @@ -117,7 +133,8 @@ set_status( cb->sip->status, sip_idle ); - cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); if( debug_invite ) debug_msg( "-- Trying -- without TS --"); @@ -127,8 +144,26 @@ cb->cb_set_status( cb_ringing ); - send2callboxes( __build_cb_package__( ext, port, __INVITE__, - ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); + cb->set_invite_response_pending(); + + supress++; + + if( supress == 0x04 ) supress = 0x00; + + if( supress & BIT0 ) + { + debug_msg("supress entendi"); + } + else + { + debug_msg("don't supress entendi "); + + //cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ( ~BIT7 ) ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); + + send2callboxes( __build_cb_package__( ext, port, __INVITE__, + ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); + } if( debug_invite ) debug_msg("-- %d on TS::%d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); } @@ -141,16 +176,27 @@ }else if( call != NULL ){ if( __find_Call__( v_call, call->get_cb_ext() ) == NULL ) v_call -> add( call ); + call->init_cbx_pkg_idle_timer(); + if( cb->get_sip_status() == sip_on_call ){ set_status( cb->status, cb_on_call ); data[ __TIMESLICE_PLACE__ ] = cb->get_timeslice(); - cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); - - send2callboxes( __build_cb_package__( ext, port, __INVITE__, ( char * )data, - cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); + //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); + + if( supress & BIT1 ) + { + debug_msg("supress ok vai la"); + } + else + { + send2callboxes( __build_cb_package__( ext, port, __INVITE__, ( char * )data, + cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); + debug_msg("send ok liga o mic"); + } cb->set_invite_response_pending(); @@ -167,7 +213,8 @@ data[ __TIMESLICE_PLACE__ ] = 0x00; if( debug_invite ) debug_msg("-- %d on %d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); - cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); @@ -193,7 +240,8 @@ data[ __TIMESLICE_PLACE__ ] = 0x00; if( debug_invite ) debug_msg("-- %d on %d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); - cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); + cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) );