![](/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:
- 135:2f4290590e51
- Parent:
- 132:05cd37f7e007
--- a/call_manager.cpp Tue Sep 01 19:34:34 2015 +0000 +++ b/call_manager.cpp Thu Sep 10 20:11:35 2015 +0000 @@ -3,53 +3,17 @@ 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(); - - send2callboxes( build_cb_package( cb->get_ext(), cb->get_port(), INVITE, ( char * )data, - cb->msg_id_update (), 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(); - - send2callboxes( build_cb_package( cb->get_ext(), cb->get_port(), CB_BYE, ( char * )data, - cb->msg_id_update (), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - - return; - } - } - } -} - -VZ_call * find_Call ( Vector * v_call, const int ext ){ - VZ_call * call = NULL; - for( register int i = 0; i < v_call->size(); i++ ){ - call = ( VZ_call * )v_call->get_element( i ); +VZ_call * +find_Call ( Vector * v_call, const int ext ) +{ + for ( register int i = 0; i < v_call -> size(); i ++ ) + { + VZ_call * call = NULL; + + call = ( VZ_call * )v_call -> get_element ( i ); if ( call != NULL ) { - if( call->get_cb_ext() == ext ) return( call ); + if ( call -> get_cb_ext () == ext ) return ( call ); } } return( NULL ); @@ -61,11 +25,10 @@ //FIXME precisa tratar o caso dos parametros NULL ? static uint8_t data[ CB_BUFFER_SIZE ], write_buffer[ CB_BUFFER_SIZE ]; - bool should_remove = false; - for ( register uint8_t i = 0; i < v_call->size(); i++ ) { - should_remove = false; + bool should_remove = false; + VZ_call * call = ( VZ_call * )v_call->get_element( i ); if ( call == NULL ) continue; @@ -113,7 +76,8 @@ } } -void invite_handler( Vector * v_call, Vector * v_cb, Timeslice * ts, Call_Box * inviting_cb ) +void +invite_handler ( Vector * v_call, Vector * v_cb, Timeslice * ts, Call_Box * inviting_cb ) { if ( ( v_call != NULL ) and ( v_cb != NULL ) and ( ts != NULL ) ) @@ -140,8 +104,6 @@ int ext = cb->get_ext (); int port = cb->get_port (); - - VZ_call * call = NULL; switch ( cb -> get_status () ) { @@ -178,7 +140,7 @@ } }break; case cb_ringing : { - call = cb -> invite (); + VZ_call * call = cb -> invite (); if ( cb -> get_sip_status () == sip_busy ){ cb->cb_set_status( cb_busy );