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: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
rtp.cpp
00001 #include "rtp.h" 00002 00003 RTP_Header::RTP_Header( int cb_ext ){ 00004 // por algum motivo do alem, comecar do 0 nao funcionou 00005 ss_id = 0x01010101 + ( uint32_t )cb_ext; 00006 seq_number = 0x0101; 00007 timestamp = 240; 00008 } 00009 00010 RTP_Header::~RTP_Header(){ 00011 // something 00012 } 00013 00014 char * RTP_Header::build_header( char * pkg ){ 00015 if( pkg == NULL ) return( NULL ); 00016 00017 for( register int i = 0; i < RTP_HEADER_SIZE; i++ ) pkg[ i ] = 0xff; 00018 00019 pkg[ 0 ] &= 0x80; 00020 00021 pkg[ 1 ] &= 0x08; 00022 00023 pkg[ 2 ] = 0xff; 00024 pkg[ 2 ] &= ( char )( seq_number >> 8 ); 00025 pkg[ 3 ] &= ( char )( seq_number & 0xff ); 00026 00027 pkg[ 4 ] &= ( char )( timestamp >> 24 & 0xff ); 00028 pkg[ 5 ] &= ( char )( timestamp >> 16 & 0xff ); 00029 pkg[ 6 ] &= ( char )( timestamp >> 8 & 0xff ); 00030 pkg[ 7 ] &= ( char )( timestamp & 0xff ); 00031 00032 pkg[ 8 ] &= ( char )( ss_id >> 24 & 0xff ); 00033 pkg[ 9 ] &= ( char )( ss_id >> 16 & 0xff ); 00034 pkg[ 10 ] &= ( char )( ss_id >> 8 & 0xff ); 00035 pkg[ 11 ] &= ( char )( ss_id & 0xff ); 00036 00037 pkg[ RTP_HEADER_SIZE ] = 0; 00038 timestamp += 240; 00039 seq_number++; 00040 00041 return( pkg ); 00042 } 00043 00044 size_t RTP_Header::size( void ){ 00045 return( RTP_HEADER_SIZE ); 00046 } 00047 00048 RTP_Body::RTP_Body(){ 00049 // do something 00050 } 00051 00052 RTP_Body::~RTP_Body(){ 00053 // something 00054 } 00055 00056 size_t RTP_Body::size( void ){ 00057 return( sizeof( RTP_Body ) ); 00058 } 00059 00060 char * RTP_Body::build_body( char * dest, char * buffer ){ 00061 for( register int i = 0; i < CB_AUDIO_DATA_SIZE; i++ ) dest[ i ] = buffer[ i ]; 00062 return( dest ); 00063 } 00064 00065 RTP::RTP( int ext ){ 00066 rtp_header = new RTP_Header( ext ); 00067 00068 if( rtp_header == NULL ) 00069 { 00070 memory_is_over = true; 00071 if( debug_rtp == true ) vz_printf ("[%d] RTP_HEADER allocation failed", ext ); 00072 if( debug_memory ) vz_debug ("[%d] RTP_Header allocation fail", ext ); 00073 } 00074 else 00075 { 00076 rtp_header_new_counter++; 00077 } 00078 00079 rtp_body = new RTP_Body(); 00080 if( rtp_body == NULL ) 00081 { 00082 memory_is_over = true; 00083 if( debug_rtp == true ) vz_printf ("[%d] RTP_BODY allocation failed", ext ); 00084 if( debug_memory ) vz_debug ("[%d ]RTP_Body allocation fail", ext ); 00085 } 00086 else 00087 { 00088 rtp_body_new_counter++; 00089 } 00090 00091 buffer [ 0 ] = '\0'; 00092 pkg [ 0 ] = '\0'; 00093 } 00094 00095 RTP::~RTP(){ 00096 if( rtp_header != NULL) 00097 { 00098 delete( rtp_header ); 00099 rtp_header_delete_counter++; 00100 } 00101 if( rtp_body != NULL ) 00102 { 00103 delete( rtp_body ); 00104 rtp_body_delete_counter++; 00105 } 00106 } 00107 00108 char * RTP::build_eth_package( char * buffer ){ 00109 if( rtp_header != NULL ) rtp_header->build_header( this->pkg ); 00110 if( rtp_body != NULL ) rtp_body->build_body( this->pkg + RTP_HEADER_OFFSET, buffer ); 00111 return( this->pkg ); 00112 } 00113 00114 size_t RTP::header_size( void ){ 00115 //if( rtp_header != NULL ) return rtp_header->size(); 00116 return ( rtp_header != NULL ) ? rtp_header->size() : 0; 00117 } 00118 00119 int RTP::print_yourself ( void ) 00120 { 00121 vz_printf ("buffer :: %p", ( void * ) buffer ); 00122 vz_printf ("pkg :: %p", ( void * ) pkg ); 00123 vz_printf ("rtp_header :: %p", ( void * ) rtp_header ); 00124 vz_printf ("rtp_body :: %p", ( void * ) rtp_body ); 00125 if ( rtp_header != NULL ) 00126 { 00127 vz_printf ("ss_id :: %d", rtp_header -> get_ss_id () ); 00128 vz_printf ("seq_number :: %d", rtp_header -> get_seq_number () ); 00129 vz_printf ("timestamp :: %d", rtp_header -> get_timestamp () ); 00130 } 00131 else 00132 { 00133 vz_printf ("Objeto rtp_header nao vinculado"); 00134 } 00135 return ( sizeof( RTP ) ); 00136 }
Generated on Tue Jul 12 2022 16:25:12 by
