![](/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:
- 81:3656f00ab3db
- Parent:
- 78:1353744f01e1
- Child:
- 82:f55d13babca0
--- a/call_manager.cpp Tue Dec 16 19:34:30 2014 +0000 +++ b/call_manager.cpp Tue Dec 30 12:37:40 2014 +0000 @@ -1,6 +1,51 @@ #include "call_manager.h" -// manage ts +Timer invite_pkg_retry_timer; +Timer bye_pkg_retry_timer; + +void init_invite_pgk_retry_manager( void ){ + invite_pkg_retry_timer.start(); +} + +void init_bye_pgk_retry_manager( void ){ + bye_pkg_retry_timer.start(); +} + +void invite_pgk_retry_manager( Vector * v_cb, uint8_t * data, uint8_t * write_buffer ){ + for( register uint8_t i = 0; i < v_cb->size(); i++ ){ + Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); + if( cb->get_status() == cb_on_call ){ + if( cb->get_invite_response() == false ){ + invite_pkg_retry_timer.reset(); + + cb->set_msg_id( cb->get_msg_id() & ~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 ) ); + + return; + } + } + } +} + +void bye_pgk_retry_manager( Vector * v_cb, uint8_t * data, uint8_t * write_buffer ){ + for( register uint8_t i = 0; i < v_cb->size(); i++ ){ + Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); + if( cb->get_status() == cb_idle ){ + if( cb->get_bye_response() == false ){ + bye_pkg_retry_timer.reset(); + + cb->set_msg_id( cb->get_msg_id() & ~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 ) ); + + return; + } + } + } +} VZ_call * __find_Call__( Vector * v_call, int ext ){ VZ_call * call = NULL; @@ -13,12 +58,12 @@ /* remove calls por timeout */ void call_manager( Vector * v_call, Vector * v_cb, uint8_t * data, uint8_t * write_buffer, Timeslice * ts ){ - for( register int i = 0; i < v_call->size(); i++ ){ + 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() ){ v_call->remove_element( i ); Call_Box * cb = __find_CB__( v_cb, call->get_cb_ext() ); - if( cb ){ + if( cb != NULL ){ cb->status = cb_idle; ts->return_timeslice( cb->get_timeslice() ); cb->set_timeslice( 0x00 ); @@ -84,7 +129,7 @@ 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__ ] ); + if( debug_invite ) debug_msg("-- %d on TS::%d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); } }break; case cb_ringing : { @@ -97,16 +142,18 @@ set_status( cb->status, cb_on_call ); - data[ __TIMESLICE_PLACE__ ] = cb->get_timeslice(); - - if( debug_invite ) debug_msg("ts::%d", cb->get_timeslice() ); + 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_invite_response_pending(); if( debug_invite ) debug_msg( "-- ringing -- accepting call request --" ); + }else if( cb->get_sip_status() == sip_busy ){ + cb->cb_set_status( cb_busy ); } }else{ if( cb->get_sip_status() == sip_denied ) cb->cb_set_status( cb_denied ); @@ -117,7 +164,7 @@ ts->return_timeslice( cb->get_timeslice() ); cb->set_timeslice( 0x00 ); data[ __TIMESLICE_PLACE__ ] = 0x00; - if( debug_invite ) debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); + if( debug_invite ) debug_msg("-- %d on %d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); @@ -143,7 +190,7 @@ ts->return_timeslice( cb->get_timeslice() ); cb->set_timeslice( 0x00 ); data[ __TIMESLICE_PLACE__ ] = 0x00; - if( debug_invite ) debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); + if( debug_invite ) debug_msg("-- %d on %d --", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 );