00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _RTCP_HH
00022 #define _RTCP_HH
00023
00024 #ifndef _RTP_SINK_HH
00025 #include "RTPSink.hh"
00026 #endif
00027 #ifndef _RTP_SOURCE_HH
00028 #include "RTPSource.hh"
00029 #endif
00030
00031 class SDESItem {
00032 public:
00033 SDESItem(unsigned char tag, unsigned char const* value);
00034
00035 unsigned char const* data() const {return fData;}
00036 unsigned totalSize() const;
00037
00038 private:
00039 unsigned char fData[2 + 0xFF];
00040 };
00041
00042 class RTCPMemberDatabase;
00043
00044 class RTCPInstance: public Medium {
00045 public:
00046 static RTCPInstance* createNew(UsageEnvironment& env, Groupsock* RTCPgs,
00047 unsigned totSessionBW,
00048 unsigned char const* cname,
00049 RTPSink* sink,
00050 RTPSource const* source,
00051 Boolean isSSMSource = False);
00052
00053 static Boolean lookupByName(UsageEnvironment& env, char const* instanceName,
00054 RTCPInstance*& resultInstance);
00055
00056 unsigned numMembers() const;
00057
00058 void setByeHandler(TaskFunc* handlerTask, void* clientData,
00059 Boolean handleActiveParticipantsOnly = True);
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 void setSRHandler(TaskFunc* handlerTask, void* clientData);
00071 void setRRHandler(TaskFunc* handlerTask, void* clientData);
00072
00073
00074
00075
00076 void setSpecificRRHandler(netAddressBits fromAddress, Port fromPort,
00077 TaskFunc* handlerTask, void* clientData);
00078
00079
00080
00081
00082 Groupsock* RTCPgs() const { return fRTCPInterface.gs(); }
00083
00084 void setStreamSocket(int sockNum, unsigned char streamChannelId);
00085 void addStreamSocket(int sockNum, unsigned char streamChannelId);
00086 void removeStreamSocket(int sockNum, unsigned char streamChannelId) {
00087 fRTCPInterface.removeStreamSocket(sockNum, streamChannelId);
00088 }
00089
00090
00091 void setAuxilliaryReadHandler(AuxHandlerFunc* handlerFunc,
00092 void* handlerClientData) {
00093 fRTCPInterface.setAuxilliaryReadHandler(handlerFunc,
00094 handlerClientData);
00095 }
00096
00097 protected:
00098 RTCPInstance(UsageEnvironment& env, Groupsock* RTPgs, unsigned totSessionBW,
00099 unsigned char const* cname,
00100 RTPSink* sink, RTPSource const* source,
00101 Boolean isSSMSource);
00102
00103 virtual ~RTCPInstance();
00104
00105 private:
00106
00107 virtual Boolean isRTCPInstance() const;
00108
00109 private:
00110 void addReport();
00111 void addSR();
00112 void addRR();
00113 void enqueueCommonReportPrefix(unsigned char packetType, u_int32_t SSRC,
00114 unsigned numExtraWords = 0);
00115 void enqueueCommonReportSuffix();
00116 void enqueueReportBlock(RTPReceptionStats* receptionStats);
00117 void addSDES();
00118 void addBYE();
00119
00120 void sendBuiltPacket();
00121
00122 static void onExpire(RTCPInstance* instance);
00123 void onExpire1();
00124
00125 static void incomingReportHandler(RTCPInstance* instance, int );
00126 void incomingReportHandler1();
00127 void onReceive(int typeOfPacket, int totPacketSize, u_int32_t ssrc);
00128
00129 void unsetSpecificRRHandler(netAddressBits fromAddress, Port fromPort);
00130
00131 private:
00132 unsigned char* fInBuf;
00133 OutPacketBuffer* fOutBuf;
00134 RTPInterface fRTCPInterface;
00135 unsigned fTotSessionBW;
00136 RTPSink* fSink;
00137 RTPSource const* fSource;
00138 Boolean fIsSSMSource;
00139
00140 SDESItem fCNAME;
00141 RTCPMemberDatabase* fKnownMembers;
00142 unsigned fOutgoingReportCount;
00143
00144 double fAveRTCPSize;
00145 int fIsInitial;
00146 double fPrevReportTime;
00147 double fNextReportTime;
00148 int fPrevNumMembers;
00149
00150 int fLastSentSize;
00151 int fLastReceivedSize;
00152 u_int32_t fLastReceivedSSRC;
00153 int fTypeOfEvent;
00154 int fTypeOfPacket;
00155 Boolean fHaveJustSentPacket;
00156 unsigned fLastPacketSentSize;
00157
00158 TaskFunc* fByeHandlerTask;
00159 void* fByeHandlerClientData;
00160 Boolean fByeHandleActiveParticipantsOnly;
00161 TaskFunc* fSRHandlerTask;
00162 void* fSRHandlerClientData;
00163 TaskFunc* fRRHandlerTask;
00164 void* fRRHandlerClientData;
00165 AddressPortLookupTable* fSpecificRRHandlerTable;
00166
00167 public:
00168 void schedule(double nextTime);
00169 void reschedule(double nextTime);
00170 void sendReport();
00171 void sendBYE();
00172 int typeOfEvent() {return fTypeOfEvent;}
00173 int sentPacketSize() {return fLastSentSize;}
00174 int packetType() {return fTypeOfPacket;}
00175 int receivedPacketSize() {return fLastReceivedSize;}
00176 int checkNewSSRC();
00177 void removeLastReceivedSSRC();
00178 void removeSSRC(u_int32_t ssrc, Boolean alsoRemoveStats);
00179 };
00180
00181
00182 const unsigned char RTCP_PT_SR = 200;
00183 const unsigned char RTCP_PT_RR = 201;
00184 const unsigned char RTCP_PT_SDES = 202;
00185 const unsigned char RTCP_PT_BYE = 203;
00186 const unsigned char RTCP_PT_APP = 204;
00187
00188
00189 const unsigned char RTCP_SDES_END = 0;
00190 const unsigned char RTCP_SDES_CNAME = 1;
00191 const unsigned char RTCP_SDES_NAME = 2;
00192 const unsigned char RTCP_SDES_EMAIL = 3;
00193 const unsigned char RTCP_SDES_PHONE = 4;
00194 const unsigned char RTCP_SDES_LOC = 5;
00195 const unsigned char RTCP_SDES_TOOL = 6;
00196 const unsigned char RTCP_SDES_NOTE = 7;
00197 const unsigned char RTCP_SDES_PRIV = 8;
00198
00199 #endif