Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
call.cpp
00001 #include "call.h" 00002 #include "debug.h" 00003 00004 VZ_call::VZ_call( int cb_ext, int cb_port, int rtp_server_ext, int rtp_server_port ){ 00005 this->cb_ext = cb_ext; 00006 this->cb_port = cb_port; 00007 00008 this->rtp_server_ext = rtp_server_ext; 00009 this->rtp_server_port = rtp_server_port; 00010 this->rtp_server.set_address( __RPT_SEVER_IP__, rtp_server_port ); 00011 rtp_sock.set_blocking( false, 3 ); 00012 this->rtp_sock.bind( cb_port ); // rtp port 00013 this->rtp_sock.init(); 00014 this->rtp = new RTP( this->cb_ext ); 00015 00016 t.start(); 00017 finish.start(); 00018 rtpbuf_clear( &( this->rtpbuf ) ); 00019 } 00020 00021 VZ_call::~VZ_call(){ 00022 rtp_sock.close(); 00023 delete( this->rtp ); 00024 } 00025 00026 char * VZ_call::get_eth_message( int * length ){ 00027 uint8_t * pkg; 00028 *length = rtp_sock.receiveFrom( rtp_server, server2cb, sizeof( server2cb ) ); 00029 t.reset(); 00030 00031 rtpbuf_next( &rtpbuf ); 00032 00033 if( *length > 0 ){ 00034 rtpbuf_put( &rtpbuf, *length - ( __RTP_HEADER_SIZE__ + ( server2cb[ 0 ] & 0xf ) ), 00035 ( uint8_t * )server2cb + ( __RTP_HEADER_OFFSET__ + ( server2cb[ 0 ] & 0xf ) ) ); 00036 } 00037 00038 pkg = rtpbuf_get( &rtpbuf ); 00039 00040 if (pkg != NULL) { 00041 *length = 240; 00042 return (char *) pkg; 00043 } 00044 led1 = !led1; 00045 *length = 0; 00046 return NULL; 00047 } 00048 00049 int VZ_call::send_message( char * buffer ){ 00050 t.reset(); 00051 return( this->rtp_sock.sendTo( this->rtp_server, buffer, __CB_AUDIO_DATA_SIZE__ + this->rtp->header_size() ) ); 00052 } 00053 00054 uint8_t * VZ_call::build_cb_package( void ){ 00055 // return __build_cb_package__( cb_ext, cb_port, __AUDIO__, server2cb, buffer ); 00056 // colocar esta funcao novamente pra envio de msg, assim como encapsular melhor a funcao 00057 // de criacao dos pacotes pro cb em algumas funcoes. 00058 return 0x00; 00059 } 00060 00061 char * VZ_call::build_eth_package( uint8_t * buffer ){ 00062 return this->rtp->build_eth_package( ( char * )buffer ); 00063 } 00064 00065 int VZ_call::get_cb_ext(){ return this->cb_ext; } 00066 int VZ_call::get_cb_port(){ return this->cb_port; } 00067 00068 int VZ_call::get_rtp_server_ext(){ return rtp_server_ext; } 00069 int VZ_call::get_rtp_server_port(){ return rtp_server_port; } 00070 uint8_t * VZ_call::get_cb2server_buffer(){ return cb2server; } 00071 char * VZ_call::get_server2cb_buffer(){ return server2cb; } 00072 inline uint8_t * VZ_call::get_buffer(){ return buffer; } 00073 00074 bool VZ_call::is_timeout( void ){ 00075 return ( t.read() > __CALL_MAX_IDLE_TIME__ ) ? true : false; 00076 } 00077 00078 bool VZ_call::is_timetofinish( void ){ 00079 return ( finish.read() > __MAX_CALL_TIME__ ) ? true : false; 00080 }
Generated on Fri Jul 22 2022 09:19:18 by
1.7.2