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 unsigned totSessionBW() const { return fTotSessionBW; }
00058
00059 void setByeHandler(TaskFunc* handlerTask, void* clientData,
00060 Boolean handleActiveParticipantsOnly = True);
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 void setSRHandler(TaskFunc* handlerTask, void* clientData);
00072 void setRRHandler(TaskFunc* handlerTask, void* clientData);
00073
00074
00075
00076
00077 void setSpecificRRHandler(netAddressBits fromAddress, Port fromPort,
00078 TaskFunc* handlerTask, void* clientData);
00079
00080
00081
00082 void unsetSpecificRRHandler(netAddressBits fromAddress, Port fromPort);
00083
00084 Groupsock* RTCPgs() const { return fRTCPInterface.gs(); }
00085
00086 void setStreamSocket(int sockNum, unsigned char streamChannelId);
00087 void addStreamSocket(int sockNum, unsigned char streamChannelId);
00088 void removeStreamSocket(int sockNum, unsigned char streamChannelId) {
00089 fRTCPInterface.removeStreamSocket(sockNum, streamChannelId);
00090 }
00091
00092
00093 void setAuxilliaryReadHandler(AuxHandlerFunc* handlerFunc,
00094 void* handlerClientData) {
00095 fRTCPInterface.setAuxilliaryReadHandler(handlerFunc,
00096 handlerClientData);
00097 }
00098
00099 protected:
00100 RTCPInstance(UsageEnvironment& env, Groupsock* RTPgs, unsigned totSessionBW,
00101 unsigned char const* cname,
00102 RTPSink* sink, RTPSource const* source,
00103 Boolean isSSMSource);
00104
00105 virtual ~RTCPInstance();
00106
00107 private:
00108
00109 virtual Boolean isRTCPInstance() const;
00110
00111 private:
00112 void addReport();
00113 void addSR();
00114 void addRR();
00115 void enqueueCommonReportPrefix(unsigned char packetType, u_int32_t SSRC,
00116 unsigned numExtraWords = 0);
00117 void enqueueCommonReportSuffix();
00118 void enqueueReportBlock(RTPReceptionStats* receptionStats);
00119 void addSDES();
00120 void addBYE();
00121
00122 void sendBuiltPacket();
00123
00124 static void onExpire(RTCPInstance* instance);
00125 void onExpire1();
00126
00127 static void incomingReportHandler(RTCPInstance* instance, int );
00128 void incomingReportHandler1();
00129 void onReceive(int typeOfPacket, int totPacketSize, u_int32_t ssrc);
00130
00131 private:
00132 unsigned char* fInBuf;
00133 unsigned fNumBytesAlreadyRead;
00134 OutPacketBuffer* fOutBuf;
00135 RTPInterface fRTCPInterface;
00136 unsigned fTotSessionBW;
00137 RTPSink* fSink;
00138 RTPSource const* fSource;
00139 Boolean fIsSSMSource;
00140
00141 SDESItem fCNAME;
00142 RTCPMemberDatabase* fKnownMembers;
00143 unsigned fOutgoingReportCount;
00144
00145 double fAveRTCPSize;
00146 int fIsInitial;
00147 double fPrevReportTime;
00148 double fNextReportTime;
00149 int fPrevNumMembers;
00150
00151 int fLastSentSize;
00152 int fLastReceivedSize;
00153 u_int32_t fLastReceivedSSRC;
00154 int fTypeOfEvent;
00155 int fTypeOfPacket;
00156 Boolean fHaveJustSentPacket;
00157 unsigned fLastPacketSentSize;
00158
00159 TaskFunc* fByeHandlerTask;
00160 void* fByeHandlerClientData;
00161 Boolean fByeHandleActiveParticipantsOnly;
00162 TaskFunc* fSRHandlerTask;
00163 void* fSRHandlerClientData;
00164 TaskFunc* fRRHandlerTask;
00165 void* fRRHandlerClientData;
00166 AddressPortLookupTable* fSpecificRRHandlerTable;
00167
00168 public:
00169 void schedule(double nextTime);
00170 void reschedule(double nextTime);
00171 void sendReport();
00172 void sendBYE();
00173 int typeOfEvent() {return fTypeOfEvent;}
00174 int sentPacketSize() {return fLastSentSize;}
00175 int packetType() {return fTypeOfPacket;}
00176 int receivedPacketSize() {return fLastReceivedSize;}
00177 int checkNewSSRC();
00178 void removeLastReceivedSSRC();
00179 void removeSSRC(u_int32_t ssrc, Boolean alsoRemoveStats);
00180 };
00181
00182
00183 const unsigned char RTCP_PT_SR = 200;
00184 const unsigned char RTCP_PT_RR = 201;
00185 const unsigned char RTCP_PT_SDES = 202;
00186 const unsigned char RTCP_PT_BYE = 203;
00187 const unsigned char RTCP_PT_APP = 204;
00188
00189
00190 const unsigned char RTCP_SDES_END = 0;
00191 const unsigned char RTCP_SDES_CNAME = 1;
00192 const unsigned char RTCP_SDES_NAME = 2;
00193 const unsigned char RTCP_SDES_EMAIL = 3;
00194 const unsigned char RTCP_SDES_PHONE = 4;
00195 const unsigned char RTCP_SDES_LOC = 5;
00196 const unsigned char RTCP_SDES_TOOL = 6;
00197 const unsigned char RTCP_SDES_NOTE = 7;
00198 const unsigned char RTCP_SDES_PRIV = 8;
00199
00200 #endif