Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
call_box.cpp@108:18a3702650f3, 2015-03-18 (annotated)
- Committer:
- klauss
- Date:
- Wed Mar 18 13:33:54 2015 +0000
- Revision:
- 108:18a3702650f3
- Parent:
- 106:a34fcf9f0e02
- Child:
- 109:a5b8264ffbbc
wip - bug udp porta, corrompendo v_cb->size () em ultima analise
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include "call_box.h" |
klauss | 0:4d17cd9c8f9d | 2 | |
klauss | 0:4d17cd9c8f9d | 3 | Call_Box::Call_Box( int ext, int port ){ |
klauss | 0:4d17cd9c8f9d | 4 | this->ext = ext; |
klauss | 0:4d17cd9c8f9d | 5 | this->port = port; |
klauss | 0:4d17cd9c8f9d | 6 | t.start(); |
klauss | 0:4d17cd9c8f9d | 7 | remaining_attempts = __MAX_ATTEMPTS__; |
klauss | 0:4d17cd9c8f9d | 8 | timeout = __TIMEOUT__; |
klauss | 4:de46f0d9b14d | 9 | msg_id = 0x10; |
klauss | 0:4d17cd9c8f9d | 10 | timeslice = 0x00; |
klauss | 0:4d17cd9c8f9d | 11 | status = cb_idle; |
klauss | 106:a34fcf9f0e02 | 12 | |
klauss | 106:a34fcf9f0e02 | 13 | { |
klauss | 106:a34fcf9f0e02 | 14 | FILE * fp = NULL; |
klauss | 106:a34fcf9f0e02 | 15 | char inner_tmp[ 20 ]; |
klauss | 106:a34fcf9f0e02 | 16 | |
klauss | 106:a34fcf9f0e02 | 17 | fp = fopen( "/qspi/shift_port.txt", "r" ); |
klauss | 106:a34fcf9f0e02 | 18 | if( fp == NULL ) |
klauss | 106:a34fcf9f0e02 | 19 | { |
klauss | 106:a34fcf9f0e02 | 20 | if( debug_cb ) debug_msg("Failed to open /qspi/shift_port.txt" ); |
klauss | 106:a34fcf9f0e02 | 21 | shift_port = SHIFT_PORT; |
klauss | 106:a34fcf9f0e02 | 22 | }else{ |
klauss | 106:a34fcf9f0e02 | 23 | if( fread( (void *)inner_tmp, 1, 20, fp ) > 0 ){ |
klauss | 106:a34fcf9f0e02 | 24 | shift_port = atoi( inner_tmp ); |
klauss | 106:a34fcf9f0e02 | 25 | if( debug_cb ) debug_msg("Shift port %d", shift_port ); |
klauss | 106:a34fcf9f0e02 | 26 | }else{ |
klauss | 106:a34fcf9f0e02 | 27 | if( debug_cb ) debug_msg("Failed to read /qspi/shift_port.txt" ); |
klauss | 106:a34fcf9f0e02 | 28 | shift_port = SHIFT_PORT; |
klauss | 106:a34fcf9f0e02 | 29 | } |
klauss | 106:a34fcf9f0e02 | 30 | } |
klauss | 106:a34fcf9f0e02 | 31 | |
klauss | 106:a34fcf9f0e02 | 32 | fclose( fp ); |
klauss | 106:a34fcf9f0e02 | 33 | } |
klauss | 106:a34fcf9f0e02 | 34 | |
klauss | 106:a34fcf9f0e02 | 35 | shift_port = SHIFT_PORT; |
klauss | 106:a34fcf9f0e02 | 36 | sip = new Sip( ext, ext + shift_port ); |
klauss | 89:0fe315117b00 | 37 | sip_socket_fd = sip->get_socket_fd(); |
klauss | 89:0fe315117b00 | 38 | if( sip == NULL ) |
klauss | 106:a34fcf9f0e02 | 39 | |
klauss | 89:0fe315117b00 | 40 | { |
klauss | 89:0fe315117b00 | 41 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 42 | if( debug_memory ) debug_msg("Sip allocation fail"); |
klauss | 89:0fe315117b00 | 43 | } |
klauss | 87:679ee0d594a9 | 44 | |
klauss | 78:1353744f01e1 | 45 | next_aging_type = __CYCLES__; |
klauss | 78:1353744f01e1 | 46 | seconds.start(); |
klauss | 81:3656f00ab3db | 47 | invite_response = true; |
klauss | 81:3656f00ab3db | 48 | bye_response = true; |
klauss | 92:92df17f538a8 | 49 | invite_retry_count = MAX_INVITE_RETRY; |
klauss | 85:b6f2dc1d0f4f | 50 | cb_new_counter++; |
klauss | 78:1353744f01e1 | 51 | } |
klauss | 78:1353744f01e1 | 52 | |
klauss | 78:1353744f01e1 | 53 | int Call_Box::get_status( void ){ return this->status; } |
klauss | 78:1353744f01e1 | 54 | |
klauss | 78:1353744f01e1 | 55 | void Call_Box::cb_set_status( uint8_t status ){ this->status = status; } |
klauss | 78:1353744f01e1 | 56 | |
klauss | 78:1353744f01e1 | 57 | int Call_Box::get_sip_status( void ){ |
klauss | 78:1353744f01e1 | 58 | if( sip == NULL ) return -1; |
klauss | 78:1353744f01e1 | 59 | |
klauss | 78:1353744f01e1 | 60 | else return this->sip->get_status(); |
klauss | 78:1353744f01e1 | 61 | } |
klauss | 78:1353744f01e1 | 62 | |
klauss | 78:1353744f01e1 | 63 | int Call_Box::set_sip_status( uint8_t status ){ |
klauss | 78:1353744f01e1 | 64 | if( sip == NULL ) return( -1 ); |
klauss | 78:1353744f01e1 | 65 | |
klauss | 78:1353744f01e1 | 66 | sip->sip_set_status( status ); |
klauss | 78:1353744f01e1 | 67 | |
klauss | 78:1353744f01e1 | 68 | return( 0 ); |
klauss | 0:4d17cd9c8f9d | 69 | } |
klauss | 0:4d17cd9c8f9d | 70 | |
klauss | 0:4d17cd9c8f9d | 71 | Call_Box::~Call_Box( void ){ |
klauss | 85:b6f2dc1d0f4f | 72 | if( sip != NULL ) delete( sip ); |
klauss | 85:b6f2dc1d0f4f | 73 | cb_delete_counter++; |
klauss | 0:4d17cd9c8f9d | 74 | } |
klauss | 0:4d17cd9c8f9d | 75 | |
klauss | 0:4d17cd9c8f9d | 76 | int Call_Box::get_port( void ){ return( this->port ); } |
klauss | 0:4d17cd9c8f9d | 77 | int Call_Box::get_ext( void ){ return( this->ext ); } |
klauss | 0:4d17cd9c8f9d | 78 | |
klauss | 0:4d17cd9c8f9d | 79 | float Call_Box::get_elapsed_time( void ){ return( this->t.read_ms() ); } |
klauss | 0:4d17cd9c8f9d | 80 | |
klauss | 100:09a23fcd3bdf | 81 | void Call_Box::reset_elapsed_time( void ){ |
klauss | 0:4d17cd9c8f9d | 82 | this->t.reset(); |
klauss | 78:1353744f01e1 | 83 | timeout = __TIMEOUT__; |
klauss | 78:1353744f01e1 | 84 | next_aging_type = __CYCLES__; |
klauss | 0:4d17cd9c8f9d | 85 | } |
klauss | 0:4d17cd9c8f9d | 86 | |
klauss | 0:4d17cd9c8f9d | 87 | bool Call_Box::is_timeout( void ){ |
klauss | 78:1353744f01e1 | 88 | if( seconds.read() > __RESQUEST_TIME__ ){ |
klauss | 78:1353744f01e1 | 89 | seconds.reset(); |
klauss | 78:1353744f01e1 | 90 | return( t.read() > __TIME_TO_REGISTER__ ) ? true : false; |
klauss | 78:1353744f01e1 | 91 | }else return false; |
klauss | 0:4d17cd9c8f9d | 92 | } |
klauss | 0:4d17cd9c8f9d | 93 | |
klauss | 78:1353744f01e1 | 94 | bool Call_Box::has_next_try( void ){ |
klauss | 78:1353744f01e1 | 95 | return( ( t.read() < __TIMEOUT__ ) ? true : false ); |
klauss | 0:4d17cd9c8f9d | 96 | } |
klauss | 0:4d17cd9c8f9d | 97 | |
klauss | 0:4d17cd9c8f9d | 98 | void Call_Box::registry( void ){ |
klauss | 0:4d17cd9c8f9d | 99 | if( this->sip == NULL ){ |
klauss | 106:a34fcf9f0e02 | 100 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 101 | deleted_sip++; |
klauss | 87:679ee0d594a9 | 102 | if( sip == NULL ){ |
klauss | 87:679ee0d594a9 | 103 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 104 | if( debug_memory ) debug_msg("Call_Box cb allocation fail"); |
klauss | 87:679ee0d594a9 | 105 | return; |
klauss | 87:679ee0d594a9 | 106 | } |
klauss | 0:4d17cd9c8f9d | 107 | |
klauss | 78:1353744f01e1 | 108 | if( sip->registry() > 0x00 ) reset_elapsed_time(); |
klauss | 81:3656f00ab3db | 109 | if( debug_aging ) debug_msg( "%d Registered - ( %f )", ext, __TIMEOUT__ - t.read() ); |
klauss | 78:1353744f01e1 | 110 | |
klauss | 0:4d17cd9c8f9d | 111 | delete( sip ); |
klauss | 0:4d17cd9c8f9d | 112 | this->sip = NULL; |
klauss | 0:4d17cd9c8f9d | 113 | }else{ |
klauss | 78:1353744f01e1 | 114 | if( sip->registry() > 0x00 ) reset_elapsed_time(); |
klauss | 81:3656f00ab3db | 115 | if( debug_aging ) debug_msg( "%d Registered - ( %f )", ext, __TIMEOUT__ - t.read() ); |
klauss | 0:4d17cd9c8f9d | 116 | } |
klauss | 0:4d17cd9c8f9d | 117 | } |
klauss | 0:4d17cd9c8f9d | 118 | |
klauss | 0:4d17cd9c8f9d | 119 | void Call_Box::unregistry( void ){ |
klauss | 0:4d17cd9c8f9d | 120 | if( this->sip == NULL ){ |
klauss | 106:a34fcf9f0e02 | 121 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 122 | deleted_sip++; |
klauss | 87:679ee0d594a9 | 123 | if( sip == NULL ){ |
klauss | 87:679ee0d594a9 | 124 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 125 | if( debug_memory ) debug_msg("Call_Box cb allocation fail"); |
klauss | 87:679ee0d594a9 | 126 | return; |
klauss | 87:679ee0d594a9 | 127 | } |
klauss | 0:4d17cd9c8f9d | 128 | sip->send_unregistry_pkg(); |
klauss | 0:4d17cd9c8f9d | 129 | |
klauss | 0:4d17cd9c8f9d | 130 | delete( sip ); |
klauss | 0:4d17cd9c8f9d | 131 | this->sip = NULL; |
klauss | 0:4d17cd9c8f9d | 132 | }else{ |
klauss | 0:4d17cd9c8f9d | 133 | sip->send_unregistry_pkg(); |
klauss | 0:4d17cd9c8f9d | 134 | } |
klauss | 0:4d17cd9c8f9d | 135 | } |
klauss | 0:4d17cd9c8f9d | 136 | |
klauss | 0:4d17cd9c8f9d | 137 | VZ_call * Call_Box::invite( void ){ |
klauss | 99:e80850c51106 | 138 | //t.stop(); |
klauss | 29:7246460b73f8 | 139 | VZ_call * call = NULL; |
klauss | 29:7246460b73f8 | 140 | |
klauss | 0:4d17cd9c8f9d | 141 | if( this->sip == NULL ){ |
klauss | 106:a34fcf9f0e02 | 142 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 143 | deleted_sip++; |
klauss | 0:4d17cd9c8f9d | 144 | |
klauss | 87:679ee0d594a9 | 145 | if( sip != NULL ){ |
klauss | 87:679ee0d594a9 | 146 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 147 | if( debug_memory ) debug_msg("Call_Box cb allocation fail"); |
klauss | 87:679ee0d594a9 | 148 | return( NULL ); |
klauss | 87:679ee0d594a9 | 149 | }else{ |
klauss | 87:679ee0d594a9 | 150 | call = sip->invite(); |
klauss | 87:679ee0d594a9 | 151 | |
klauss | 87:679ee0d594a9 | 152 | delete( sip ); |
klauss | 87:679ee0d594a9 | 153 | this->sip = NULL; |
klauss | 87:679ee0d594a9 | 154 | } |
klauss | 29:7246460b73f8 | 155 | }else{ |
klauss | 29:7246460b73f8 | 156 | call = sip->invite(); |
klauss | 0:4d17cd9c8f9d | 157 | } |
klauss | 29:7246460b73f8 | 158 | |
klauss | 29:7246460b73f8 | 159 | if( debug_cb ) debug_msg("Call returned value :: %p ", (void * )call ); |
klauss | 29:7246460b73f8 | 160 | if( call == NULL ) t.start(); |
klauss | 29:7246460b73f8 | 161 | return( call ); |
klauss | 0:4d17cd9c8f9d | 162 | } |
klauss | 0:4d17cd9c8f9d | 163 | |
klauss | 0:4d17cd9c8f9d | 164 | /* Retorna |
klauss | 0:4d17cd9c8f9d | 165 | = 0 :: ok |
klauss | 0:4d17cd9c8f9d | 166 | < 0 :: tive problemas |
klauss | 0:4d17cd9c8f9d | 167 | > 0 :: devo remover essa call do vetor de calls |
klauss | 0:4d17cd9c8f9d | 168 | */ |
klauss | 0:4d17cd9c8f9d | 169 | int Call_Box::listen_SIP_server( void ){ |
klauss | 0:4d17cd9c8f9d | 170 | if( this->sip == NULL ){ |
klauss | 0:4d17cd9c8f9d | 171 | if( status == cb_on_call || status == cb_idle ){ |
klauss | 106:a34fcf9f0e02 | 172 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 173 | deleted_sip++; |
klauss | 87:679ee0d594a9 | 174 | |
klauss | 87:679ee0d594a9 | 175 | if( sip == NULL ){ |
klauss | 87:679ee0d594a9 | 176 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 177 | if( debug_memory ) debug_msg("Call_Box cb allocation fail"); |
klauss | 87:679ee0d594a9 | 178 | return( -1 ); |
klauss | 87:679ee0d594a9 | 179 | }else{ |
klauss | 87:679ee0d594a9 | 180 | int out_read = sip->listen_SIP_server(); |
klauss | 87:679ee0d594a9 | 181 | |
klauss | 87:679ee0d594a9 | 182 | delete( sip ); |
klauss | 87:679ee0d594a9 | 183 | this->sip = NULL; |
klauss | 87:679ee0d594a9 | 184 | return( out_read ); |
klauss | 87:679ee0d594a9 | 185 | } |
klauss | 0:4d17cd9c8f9d | 186 | }else return( 0 ); |
klauss | 0:4d17cd9c8f9d | 187 | }else{ |
klauss | 0:4d17cd9c8f9d | 188 | if( status == cb_on_call || status == cb_idle ){ |
klauss | 13:ae278302dffe | 189 | return ( sip->listen_SIP_server() ); |
klauss | 13:ae278302dffe | 190 | } else return( 0 ); |
klauss | 0:4d17cd9c8f9d | 191 | } |
klauss | 0:4d17cd9c8f9d | 192 | } |
klauss | 0:4d17cd9c8f9d | 193 | |
klauss | 0:4d17cd9c8f9d | 194 | void Call_Box::set_msg_id( uint8_t msg_id ){ |
klauss | 78:1353744f01e1 | 195 | this->msg_id = ( msg_id > 0x10 ) ? msg_id : 0x11; |
klauss | 0:4d17cd9c8f9d | 196 | } |
klauss | 0:4d17cd9c8f9d | 197 | uint8_t Call_Box::get_msg_id( void ){ return( this->msg_id ); } |
klauss | 0:4d17cd9c8f9d | 198 | |
klauss | 0:4d17cd9c8f9d | 199 | void Call_Box::set_timeslice( uint8_t timeslice ){ |
klauss | 0:4d17cd9c8f9d | 200 | this->timeslice = timeslice; |
klauss | 0:4d17cd9c8f9d | 201 | } |
klauss | 0:4d17cd9c8f9d | 202 | uint8_t Call_Box::get_timeslice( void ){ return( this->timeslice ); } |
klauss | 0:4d17cd9c8f9d | 203 | |
klauss | 0:4d17cd9c8f9d | 204 | //void Call_Box::set_sip( Sip * sip ){ |
klauss | 0:4d17cd9c8f9d | 205 | // this->sip = sip; |
klauss | 0:4d17cd9c8f9d | 206 | //} |
klauss | 0:4d17cd9c8f9d | 207 | |
klauss | 0:4d17cd9c8f9d | 208 | void Call_Box::send_bye( void ){ |
klauss | 0:4d17cd9c8f9d | 209 | if( this->sip == NULL ){ |
klauss | 106:a34fcf9f0e02 | 210 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 211 | deleted_sip++; |
klauss | 0:4d17cd9c8f9d | 212 | |
klauss | 87:679ee0d594a9 | 213 | if( sip == NULL ){ |
klauss | 87:679ee0d594a9 | 214 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 215 | if( debug_memory ) debug_msg("Call_Box cb allocation fail"); |
klauss | 87:679ee0d594a9 | 216 | return; |
klauss | 87:679ee0d594a9 | 217 | }else{ |
klauss | 13:ae278302dffe | 218 | |
klauss | 87:679ee0d594a9 | 219 | sip->send_bye(); |
klauss | 87:679ee0d594a9 | 220 | |
klauss | 87:679ee0d594a9 | 221 | delete( sip ); |
klauss | 87:679ee0d594a9 | 222 | sip = NULL; |
klauss | 87:679ee0d594a9 | 223 | } |
klauss | 0:4d17cd9c8f9d | 224 | }else{ |
klauss | 0:4d17cd9c8f9d | 225 | sip->send_bye(); |
klauss | 0:4d17cd9c8f9d | 226 | } |
klauss | 1:a1758104fa1d | 227 | } |
klauss | 1:a1758104fa1d | 228 | |
klauss | 1:a1758104fa1d | 229 | void Call_Box::reset_sip( void ){ |
klauss | 1:a1758104fa1d | 230 | if( this->sip != NULL ) delete( this->sip ); |
klauss | 1:a1758104fa1d | 231 | |
klauss | 106:a34fcf9f0e02 | 232 | this->sip = new Sip( ext, ext + shift_port ); |
klauss | 106:a34fcf9f0e02 | 233 | deleted_sip++; |
klauss | 87:679ee0d594a9 | 234 | |
klauss | 87:679ee0d594a9 | 235 | if( sip == NULL ) memory_is_over = true; |
klauss | 14:22a35f575502 | 236 | } |
klauss | 14:22a35f575502 | 237 | |
klauss | 14:22a35f575502 | 238 | void Call_Box::set_sip_status( int status ){ |
klauss | 14:22a35f575502 | 239 | if( this->sip != NULL ){ |
klauss | 14:22a35f575502 | 240 | this->sip->status = status; |
klauss | 14:22a35f575502 | 241 | }else{ |
klauss | 78:1353744f01e1 | 242 | if( debug_cb) debug_msg("Sip equals NULL o.O"); |
klauss | 108:18a3702650f3 | 243 | } |
klauss | 29:7246460b73f8 | 244 | } |
klauss | 29:7246460b73f8 | 245 | |
klauss | 29:7246460b73f8 | 246 | void Call_Box::re_start_timer( void ){ |
klauss | 29:7246460b73f8 | 247 | t.start(); |
klauss | 78:1353744f01e1 | 248 | } |
klauss | 78:1353744f01e1 | 249 | |
klauss | 78:1353744f01e1 | 250 | int8_t Call_Box::get_next_aging_type( void ){ |
klauss | 78:1353744f01e1 | 251 | next_aging_type--; |
klauss | 78:1353744f01e1 | 252 | |
klauss | 78:1353744f01e1 | 253 | if( ( next_aging_type % 2 ) == 0 || ( next_aging_type > __CYCLES__ - 15 ) ) return( REQUEST_REGISTRY ); |
klauss | 78:1353744f01e1 | 254 | |
klauss | 78:1353744f01e1 | 255 | else if( ( next_aging_type % 7 ) == 0 ) return( REQUEST_PEND ); |
klauss | 78:1353744f01e1 | 256 | |
klauss | 78:1353744f01e1 | 257 | else return( REQUEST_PING ); |
klauss | 81:3656f00ab3db | 258 | } |
klauss | 81:3656f00ab3db | 259 | |
klauss | 81:3656f00ab3db | 260 | void Call_Box::set_invite_response_ok( void ){ this->invite_response = true; } |
klauss | 92:92df17f538a8 | 261 | |
klauss | 92:92df17f538a8 | 262 | //void Call_Box::set_first_invite_response_ok( void ){ this->invite_first_response = true; |
klauss | 92:92df17f538a8 | 263 | // debug_msg(""); |
klauss | 92:92df17f538a8 | 264 | //} |
klauss | 92:92df17f538a8 | 265 | |
klauss | 81:3656f00ab3db | 266 | void Call_Box::set_invite_response_pending( void ){ this->invite_response = false; } |
klauss | 81:3656f00ab3db | 267 | bool Call_Box::get_invite_response( void ){ return( this->invite_response ); } |
klauss | 81:3656f00ab3db | 268 | |
klauss | 92:92df17f538a8 | 269 | //void Call_Box::set_first_invite_response_pending( void ){ this->first_invite_response = false; } |
klauss | 92:92df17f538a8 | 270 | //bool Call_Box::get_first_invite_response( void ){ return( this->first_invite_response ); } |
klauss | 92:92df17f538a8 | 271 | |
klauss | 92:92df17f538a8 | 272 | |
klauss | 92:92df17f538a8 | 273 | void Call_Box::invite_retry_count_reset( void ){ invite_retry_count = MAX_INVITE_RETRY; } |
klauss | 92:92df17f538a8 | 274 | uint8_t Call_Box::get_invite_retry_count( void ){ |
klauss | 92:92df17f538a8 | 275 | return ( invite_retry_count ) ? invite_retry_count-- : 0; |
klauss | 92:92df17f538a8 | 276 | } |
klauss | 92:92df17f538a8 | 277 | |
klauss | 81:3656f00ab3db | 278 | void Call_Box::set_bye_response_ok( void ){ this->bye_response = true; } |
klauss | 81:3656f00ab3db | 279 | void Call_Box::set_bye_response_pending( void ){ this->bye_response = false; } |
klauss | 89:0fe315117b00 | 280 | bool Call_Box::get_bye_response( void ){ return( this->bye_response ); } |
klauss | 89:0fe315117b00 | 281 | |
klauss | 89:0fe315117b00 | 282 | |
klauss | 89:0fe315117b00 | 283 | int Call_Box::get_sip_socket_fd( void ){ |
klauss | 89:0fe315117b00 | 284 | return( sip_socket_fd ); |
klauss | 89:0fe315117b00 | 285 | } |
klauss | 89:0fe315117b00 | 286 | |
klauss | 91:c2a86b1f8aaa | 287 | int Call_Box::sip_udp_incomming_pkg( void ){ |
klauss | 91:c2a86b1f8aaa | 288 | return sip->udp_incomming_pkg(); |
klauss | 91:c2a86b1f8aaa | 289 | } |
klauss | 91:c2a86b1f8aaa | 290 | |
klauss | 91:c2a86b1f8aaa | 291 | void Call_Box::reset_cb_status( void ){ |
klauss | 91:c2a86b1f8aaa | 292 | if( sip != NULL ) sip->reset_call(); |
klauss | 97:8985817e8847 | 293 | } |
klauss | 97:8985817e8847 | 294 | |
klauss | 97:8985817e8847 | 295 | int Call_Box::get_sip_ext( void ){ return this->sip->get_ext(); } |
klauss | 99:e80850c51106 | 296 | int Call_Box::get_sip_port( void ){ return this->sip->get_port(); } |
klauss | 99:e80850c51106 | 297 | |
klauss | 99:e80850c51106 | 298 | |
klauss | 108:18a3702650f3 | 299 | int Call_Box::get_timer( void ){ return t.read(); } |
klauss | 108:18a3702650f3 | 300 | |
klauss | 108:18a3702650f3 | 301 | int Call_Box::get_rtp_port ( void ) |
klauss | 108:18a3702650f3 | 302 | { |
klauss | 108:18a3702650f3 | 303 | if( this->sip != NULL ){ |
klauss | 108:18a3702650f3 | 304 | return this->sip->get_sip_rtp_port(); |
klauss | 108:18a3702650f3 | 305 | }else{ |
klauss | 108:18a3702650f3 | 306 | if( debug_cb) debug_msg("Sip equals NULL o.O"); |
klauss | 108:18a3702650f3 | 307 | return -1; |
klauss | 108:18a3702650f3 | 308 | } |
klauss | 108:18a3702650f3 | 309 | } |
klauss | 108:18a3702650f3 | 310 | |
klauss | 108:18a3702650f3 | 311 | void Call_Box::set_rtp_port ( int new_rtp_port ) |
klauss | 108:18a3702650f3 | 312 | { |
klauss | 108:18a3702650f3 | 313 | if( this->sip != NULL ){ |
klauss | 108:18a3702650f3 | 314 | this->sip->set_sip_rtp_port( new_rtp_port ); |
klauss | 108:18a3702650f3 | 315 | } |
klauss | 108:18a3702650f3 | 316 | } |
klauss | 108:18a3702650f3 | 317 | |
klauss | 108:18a3702650f3 | 318 | void Call_Box::init_rtp_timer ( void ) |
klauss | 108:18a3702650f3 | 319 | { |
klauss | 108:18a3702650f3 | 320 | this->rtp_timer.start(); |
klauss | 108:18a3702650f3 | 321 | } |
klauss | 108:18a3702650f3 | 322 | |
klauss | 108:18a3702650f3 | 323 | void Call_Box::reset_rtp_timer ( void ) |
klauss | 108:18a3702650f3 | 324 | { |
klauss | 108:18a3702650f3 | 325 | this->rtp_timer.stop(); |
klauss | 108:18a3702650f3 | 326 | this->rtp_timer.reset(); |
klauss | 108:18a3702650f3 | 327 | } |
klauss | 108:18a3702650f3 | 328 | |
klauss | 108:18a3702650f3 | 329 | bool Call_Box::is_rtp_timer_timeout ( void ) |
klauss | 108:18a3702650f3 | 330 | { |
klauss | 108:18a3702650f3 | 331 | return ( rtp_timer.read () > RTP_REQUEST_PORT_TIMEOUT ) ? true : false; |
klauss | 108:18a3702650f3 | 332 | } |
klauss | 108:18a3702650f3 | 333 | |
klauss | 108:18a3702650f3 | 334 | int Call_Box::get_rtp_timer ( void ) |
klauss | 108:18a3702650f3 | 335 | { |
klauss | 108:18a3702650f3 | 336 | return ( rtp_timer.read () ); |
klauss | 108:18a3702650f3 | 337 | } |