![](/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
rtp.cpp
- Committer:
- klauss
- Date:
- 2015-04-30
- Revision:
- 119:ee6a53069455
- Parent:
- 109:a5b8264ffbbc
- Child:
- 121:ee02790d00b7
File content as of revision 119:ee6a53069455:
#include "rtp.h" RTP_Header::RTP_Header( int cb_ext ){ // por algum motivo do alem, comecar do 0 nao funcionou ss_id = 0x01010101 + ( uint32_t )cb_ext; seq_number = 0x0101; timestamp = 240; } RTP_Header::~RTP_Header(){ // something } char * RTP_Header::build_header( char * pkg ){ if( pkg == NULL ) return( NULL ); for( register int i = 0; i < __RTP_HEADER_SIZE__; i++ ) pkg[ i ] = 0xff; pkg[ 0 ] &= 0x80; pkg[ 1 ] &= 0x08; pkg[ 2 ] = 0xff; pkg[ 2 ] &= ( char )( seq_number >> 8 ); pkg[ 3 ] &= ( char )( seq_number & 0xff ); pkg[ 4 ] &= ( char )( timestamp >> 24 & 0xff ); pkg[ 5 ] &= ( char )( timestamp >> 16 & 0xff ); pkg[ 6 ] &= ( char )( timestamp >> 8 & 0xff ); pkg[ 7 ] &= ( char )( timestamp & 0xff ); pkg[ 8 ] &= ( char )( ss_id >> 24 & 0xff ); pkg[ 9 ] &= ( char )( ss_id >> 16 & 0xff ); pkg[ 10 ] &= ( char )( ss_id >> 8 & 0xff ); pkg[ 11 ] &= ( char )( ss_id & 0xff ); pkg[ __RTP_HEADER_SIZE__ ] = 0; timestamp += 240; seq_number++; return( pkg ); } size_t RTP_Header::size( void ){ return( __RTP_HEADER_SIZE__ ); } RTP_Body::RTP_Body(){ // do something } RTP_Body::~RTP_Body(){ // something } size_t RTP_Body::size( void ){ return( sizeof( RTP_Body ) ); } char * RTP_Body::build_body( char * dest, char * buffer ){ for( register int i = 0; i < CB_AUDIO_DATA_SIZE; i++ ) dest[ i ] = buffer[ i ]; return( dest ); } RTP::RTP( int ext ){ rtp_header = new RTP_Header( ext ); if( rtp_header == NULL ) { memory_is_over = true; if( debug_rtp == true ) send_msg("[%d] RTP_HEADER allocation failed", ext ); if( debug_memory ) debug_msg("[%d] RTP_Header allocation fail", ext ); } else { rtp_header_new_counter++; } rtp_body = new RTP_Body(); if( rtp_body == NULL ) { memory_is_over = true; if( debug_rtp == true ) send_msg("[%d] RTP_BODY allocation failed", ext ); if( debug_memory ) debug_msg("[%d ]RTP_Body allocation fail", ext ); } else { rtp_body_new_counter++; } } RTP::~RTP(){ if( rtp_header != NULL) { delete( rtp_header ); rtp_header_delete_counter++; } if( rtp_body != NULL ) { delete( rtp_body ); rtp_body_delete_counter++; } } char * RTP::build_eth_package( char * buffer ){ if( rtp_header != NULL ) rtp_header->build_header( this->pkg ); if( rtp_body != NULL ) rtp_body->build_body( this->pkg + __RTP_HEADER_OFFSET__, buffer ); return( this->pkg ); } size_t RTP::header_size( void ){ //if( rtp_header != NULL ) return rtp_header->size(); return ( rtp_header != NULL ) ? rtp_header->size() : 0; } int RTP::print_yourself ( void ) { send_msg("buffer :: %p", ( void * ) buffer ); send_msg("pkg :: %p", ( void * ) pkg ); send_msg("rtp_header :: %p", ( void * ) rtp_header ); send_msg("rtp_body :: %p", ( void * ) rtp_body ); if ( rtp_header != NULL ) { send_msg("ss_id :: %d", rtp_header -> get_ss_id () ); send_msg("seq_number :: %d", rtp_header -> get_seq_number () ); send_msg("timestamp :: %d", rtp_header -> get_timestamp () ); } else { send_msg("Objeto rtp_header nao vinculado"); } return ( sizeof( RTP ) ); }