AmRtpPacket.h

Go to the documentation of this file.
00001 /*
00002  * $Id: AmRtpPacket.h 949 2008-05-14 12:15:28Z sayer $
00003  *
00004  * Copyright (C) 2002-2003 Fhg Fokus
00005  *
00006  * This file is part of sems, a free SIP media server.
00007  *
00008  * sems is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * sems is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00028 #ifndef _AmRtpPacket_h_
00029 #define _AmRtpPacket_h_
00030 
00031 #include <sys/time.h>
00032 #include <sys/types.h>
00033 #include <netinet/in.h>
00034 
00035 class AmRtpPacketTracer;
00036 
00038 class AmRtpPacket {
00039 
00040   unsigned char  buffer[4096];
00041   unsigned int   b_size;
00042 
00043   unsigned int   data_offset;
00044   unsigned int   d_size;
00045 
00046 public:
00047   unsigned char  payload;
00048   bool           marker;
00049   unsigned short sequence;    
00050   unsigned int   timestamp;   
00051   unsigned int   ssrc;
00052 
00053   struct timeval recv_time;
00054 
00055 #ifdef SUPPORT_IPV6
00056   struct sockaddr_storage addr;
00057 #else
00058   struct sockaddr_in addr;
00059 #endif
00060     
00061 
00062   AmRtpPacket();
00063   ~AmRtpPacket();
00064 
00065 #ifdef SUPPORT_IPV6
00066   void setAddr(struct sockaddr_storage* a);
00067   void getAddr(struct sockaddr_storage* a);
00068 #else
00069   void setAddr(struct sockaddr_in* a);
00070   void getAddr(struct sockaddr_in* a);
00071 #endif
00072 
00073   // returns -1 if error, else 0
00074   int compile(unsigned char* data_buf, unsigned int size);
00075   // returns -1 if error, else 0
00076   int compile_raw(unsigned char* data_buf, unsigned int size);
00077 
00078   int send(int sd);
00079   int recv(int sd);
00080 
00081   int parse();
00082 
00083   unsigned int   getDataSize() const { return d_size; }
00084   unsigned char* getData();
00085 
00086   unsigned int   getBufferSize() const { return b_size; }
00087   unsigned char* getBuffer();
00088   void setBufferSize(unsigned int b) { b_size = b; }
00089 
00090   void copy(const AmRtpPacket* p);
00091 
00092   friend class AmRtpPacketTracer;
00093 };
00094 
00095 #endif
00096 
00097 

Generated on Fri May 16 12:02:05 2008 for SEMS by  doxygen 1.5.1
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login