RTP Audio System  2.0.0
rtcpsender.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                      RTP Audio Server Project                    ####
00004 // ####                    ============================                  ####
00005 // ####                                                                  ####
00006 // #### RTCP Sender                                                      ####
00007 // ####                                                                  ####
00008 // ####           Copyright (C) 1999-2012 by Thomas Dreibholz            ####
00009 // ####                                                                  ####
00010 // #### Contact:                                                         ####
00011 // ####    EMail: dreibh@iem.uni-due.de                                  ####
00012 // ####    WWW:   https://www.nntb.no/~dreibh/rtpaudio                ####
00013 // ####                                                                  ####
00014 // #### ---------------------------------------------------------------- ####
00015 // ####                                                                  ####
00016 // #### This program is free software: you can redistribute it and/or    ####
00017 // #### modify it under the terms of the GNU General Public License as   ####
00018 // #### published by the Free Software Foundation, either version 3 of   ####
00019 // #### the License, or (at your option) any later version.              ####
00020 // ####                                                                  ####
00021 // #### This program is distributed in the hope that it will be useful,  ####
00022 // #### but WITHOUT ANY WARRANTY; without even the implied warranty of   ####
00023 // #### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    ####
00024 // #### GNU General Public License for more details.                     ####
00025 // ####                                                                  ####
00026 // #### You should have received a copy of the GNU General Public        ####
00027 // #### License along with this program.  If not, see                    ####
00028 // #### <http://www.gnu.org/licenses/>.                                  ####
00029 // ####                                                                  ####
00030 // ##########################################################################
00031 // $Id: rtcpsender.h 1286 2011-12-18 13:43:16Z dreibh $
00032 
00033 
00034 #ifndef RTCPSENDER_H
00035 #define RTCPSENDER_H
00036 
00037 
00038 #include "tdsystem.h"
00039 #include "tdsocket.h"
00040 #include "timedthread.h"
00041 #include "rtcppacket.h"
00042 #include "rtpreceiver.h"
00043 #include "randomizer.h"
00044 
00045 #include <map>
00046 
00047 
00055 class RTCPSender : public TimedThread
00056 {
00057    // ====== Constructor/Destructor =========================================
00058    public:
00065    RTCPSender();
00066 
00078    RTCPSender(const InternetFlow& flow,
00079               const card32        ssrc,
00080               Socket*             senderSocket,
00081               RTPReceiver*        receiver,
00082               const card64        bandwidth,
00083               const card32        controlPPID);
00084 
00088    ~RTCPSender();
00089 
00090 
00091    // ====== Initialize =====================================================
00103    void init(const InternetFlow& flow,
00104              const card32        ssrc,
00105              Socket*             senderSocket,
00106              RTPReceiver*        receiver,
00107              const card64        bandwidth,
00108              const card32        controlPPID);
00109 
00110 
00111    // ====== RTCP packet sending functions ==================================
00120    integer sendApp(const char* name, const void* data, const cardinal dataLength);
00121 
00127    integer sendBye();
00128 
00135    integer sendReport();
00136 
00144    integer sendSDES();
00145 
00158    bool addSDESItem(const card8 type, const void* data, const card8 length = 0);
00159 
00168    void removeSDESItem(const card8 type);
00169 
00170 
00171    // ====== Private data ===================================================
00172    private:
00173    void timerEvent();
00174    double computeTransmissionInterval();
00175 
00176    InternetFlow                                          Flow;
00177    SocketAddress*                                        ReceiverAddress;
00178    Socket*                                               SenderSocket;
00179    RTPReceiver*                                          Receiver;
00180    card32                                                SSRC;
00181    std::multimap<const card8,RTCPSourceDescriptionItem*> SDESItemSet;
00182    Randomizer                                            Random;
00183    card32                                                ControlPPID;
00184 
00185    bool    Initial;         // True, if application has not yet sent an RTCP packet
00186    bool    WeSent;          // True, if data sent since 2nd previous RTCP report
00187    integer Senders;         // Most current estimate for nr. of session senders
00188    integer Members;         // Most current estimate for nr. of session members
00189    double  RTCPBandwidth;   // Bandwidth for RTCP in octets/second
00190    double  AverageRTCPSize; // Average compound RTCP packet size
00191 };
00192 
00193 
00194 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines