rtpinternalsourcedata.h

Go to the documentation of this file.
00001 /*
00002 
00003   This file is a part of JRTPLIB
00004   Copyright (c) 1999-2007 Jori Liesenborgs
00005 
00006   Contact: jori.liesenborgs@gmail.com
00007 
00008   This library was developed at the "Expertisecentrum Digitale Media"
00009   (http://www.edm.uhasselt.be), a research center of the Hasselt University
00010   (http://www.uhasselt.be). The library is based upon work done for 
00011   my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
00012 
00013   Permission is hereby granted, free of charge, to any person obtaining a
00014   copy of this software and associated documentation files (the "Software"),
00015   to deal in the Software without restriction, including without limitation
00016   the rights to use, copy, modify, merge, publish, distribute, sublicense,
00017   and/or sell copies of the Software, and to permit persons to whom the
00018   Software is furnished to do so, subject to the following conditions:
00019 
00020   The above copyright notice and this permission notice shall be included
00021   in all copies or substantial portions of the Software.
00022 
00023   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00024   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00025   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00026   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00027   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00028   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00029   IN THE SOFTWARE.
00030 
00031 */
00032 
00037 #ifndef RTPINTERNALSOURCEDATA_H
00038 
00039 #define RTPINTERNALSOURCEDATA_H
00040 
00041 #include "rtpconfig.h"
00042 #include "rtpsourcedata.h"
00043 #include "rtpaddress.h"
00044 #include "rtptimeutilities.h"
00045 #include "rtpsources.h"
00046 
00047 class RTPInternalSourceData : public RTPSourceData
00048 {
00049 public:
00050         RTPInternalSourceData(uint32_t ssrc, RTPSources::ProbationType probtype, RTPMemoryManager *mgr = 0);
00051         ~RTPInternalSourceData();
00052 
00053         int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,bool *stored);
00054         void ProcessSenderInfo(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t packetcount,
00055                                uint32_t octetcount,const RTPTime &receivetime)                          { SRprevinf = SRinf; SRinf.Set(ntptime,rtptime,packetcount,octetcount,receivetime); stats.SetLastMessageTime(receivetime); }
00056         void ProcessReportBlock(uint8_t fractionlost,int32_t lostpackets,uint32_t exthighseqnr,
00057                                 uint32_t jitter,uint32_t lsr,uint32_t dlsr,
00058                                 const RTPTime &receivetime)                                             { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); }
00059         void UpdateMessageTime(const RTPTime &receivetime)                                              { stats.SetLastMessageTime(receivetime); }
00060         int ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis);
00061 #ifdef RTP_SUPPORT_SDESPRIV
00062         int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime);
00063 #endif // RTP_SUPPORT_SDESPRIV
00064         int ProcessBYEPacket(const uint8_t *reason,size_t reasonlen,const RTPTime &receivetime);
00065                 
00066         int SetRTPDataAddress(const RTPAddress *a);
00067         int SetRTCPDataAddress(const RTPAddress *a);
00068 
00069         void ClearSenderFlag()                                                                          { issender = false; }
00070         void SentRTPPacket()                                                                            { if (!ownssrc) return; RTPTime t = RTPTime::CurrentTime(); issender = true; stats.SetLastRTPPacketTime(t); stats.SetLastMessageTime(t); }
00071         void SetOwnSSRC()                                                                               { ownssrc = true; validated = true; }
00072         void SetCSRC()                                                                                  { validated = true; iscsrc = true; }
00073         void ClearNote()                                                                                { SDESinf.SetNote(0,0); }
00074         
00075 #ifdef RTP_SUPPORT_PROBATION
00076 private:
00077         RTPSources::ProbationType probationtype;
00078 #endif // RTP_SUPPORT_PROBATION
00079 };
00080 
00081 inline int RTPInternalSourceData::SetRTPDataAddress(const RTPAddress *a)
00082 {
00083         if (a == 0)
00084         {
00085                 if (rtpaddr)
00086                 {
00087                         RTPDelete(rtpaddr,GetMemoryManager());
00088                         rtpaddr = 0;
00089                 }
00090         }
00091         else
00092         {
00093                 RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
00094                 if (newaddr == 0)
00095                         return ERR_RTP_OUTOFMEM;
00096                 
00097                 if (rtpaddr && a != rtpaddr)
00098                         RTPDelete(rtpaddr,GetMemoryManager());
00099                 rtpaddr = newaddr;
00100         }
00101         isrtpaddrset = true;
00102         return 0;
00103 }
00104 
00105 inline int RTPInternalSourceData::SetRTCPDataAddress(const RTPAddress *a)
00106 {
00107         if (a == 0)
00108         {
00109                 if (rtcpaddr)
00110                 {
00111                         RTPDelete(rtcpaddr,GetMemoryManager());
00112                         rtcpaddr = 0;
00113                 }
00114         }
00115         else
00116         {
00117                 RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
00118                 if (newaddr == 0)
00119                         return ERR_RTP_OUTOFMEM;
00120                 
00121                 if (rtcpaddr && a != rtcpaddr)
00122                         RTPDelete(rtcpaddr,GetMemoryManager());
00123                 rtcpaddr = newaddr;
00124         }
00125         isrtcpaddrset = true;
00126         return 0;
00127 }
00128         
00129 #endif // RTPINTERNALSOURCEDATA_H
00130 

Generated on Thu Feb 8 16:22:05 2007 for jrtplib by  doxygen 1.5.1