RTP Audio System  2.0.0
rtcpabstractserver.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                      RTP Audio Server Project                    ####
00004 // ####                    ============================                  ####
00005 // ####                                                                  ####
00006 // #### RTCP Abstract Server Implementation                              ####
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: rtcpabstractserver.h 1286 2011-12-18 13:43:16Z dreibh $
00032 
00033 
00034 #ifndef RTCPABSTRACTSERVER_H
00035 #define RTCPABSTRACTSERVER_H
00036 
00037 
00038 #include "tdsystem.h"
00039 #include "timedthread.h"
00040 #include "rtcppacket.h"
00041 #include "internetflow.h"
00042 #include "sourcestateinfo.h"
00043 
00044 #include <map>
00045 
00046 
00054 class RTCPAbstractServer : public TimedThread
00055 {
00056    // ====== Definitions ====================================================
00057    public:
00061    struct Client {
00062       card32       SSRC;
00063       InternetFlow ClientAddress;
00064       card64       TimeStamp;
00065       card64       Timeout;
00066       void*        UserData;
00067    };
00068 
00069 
00070    // ====== Constructor/Destructor =========================================
00074    RTCPAbstractServer();
00075 
00079    ~RTCPAbstractServer();
00080 
00081 
00082    // ====== Virtual functions ==============================================
00094    virtual void* newClient(Client* client, const char* cname) = 0;
00095 
00096 
00100    enum DeleteReason {
00101       DeleteReason_UserBye  = 0,
00102       DeleteReason_Timeout  = 1,
00103       DeleteReason_Shutdown = 2,
00104       DeleteReason_Error    = 3,
00105    };
00106 
00116    virtual void deleteClient(Client*            client,
00117                              const DeleteReason reason) = 0;
00118 
00126    virtual bool checkClient(Client* client) = 0;
00127 
00137    virtual void appMessage(Client*        client,
00138                            const char*    name,
00139                            void*          data,
00140                            const cardinal dataLength) = 0;
00141 
00152    virtual void sdesMessage(Client*        client,
00153                             const card8    type,
00154                             char*          data,
00155                             const cardinal length) = 0;
00156 
00166    virtual void receiverReport(Client*                   client,
00167                                RTCPReceptionReportBlock* report,
00168                                const cardinal            layer) = 0;
00169 
00170 
00177    virtual void outOfMemoryWarning();
00178 
00179 
00185    inline cardinal getMembers();
00186 
00187 
00188    // ====== Settings =======================================================
00195    inline card64 getDefaultTimeout() const;
00196 
00204    inline void setDefaultTimeout(const card64 timeout);
00205 
00206 
00207    // ====== stop() reimplementation ========================================
00214    void* stop();
00215 
00216 
00217    // ====== RTCP packet handlers ===========================================
00218    private:
00222    friend class RTCPReceiver;
00223 
00224    void receivedSenderReport(const InternetFlow        flow,
00225                              const card32              source,
00226                              RTCPReceptionReportBlock* report,
00227                              const cardinal            layer);
00228    void receivedReceiverReport(const InternetFlow        flow,
00229                                const card32              source,
00230                                RTCPReceptionReportBlock* report,
00231                                const cardinal            layer);
00232    void receivedSourceDescription(const InternetFlow flow,
00233                                   const card32       source,
00234                                   const card8        type,
00235                                   char*              data,
00236                                   const card8        length);
00237    void receivedApp(const InternetFlow flow,
00238                     const card32       source,
00239                     const char*        name,
00240                     void*              data,
00241                     const card32       dataLength);
00242    void receivedBye(const InternetFlow flow,
00243                     const card32       source,
00244                     const DeleteReason reason);
00245 
00246    Client* findClient(const card32 source, const InternetFlow flow);
00247 
00248 
00249    // ====== Private data ===================================================
00250    private:
00251    void timerEvent();
00252 
00253 
00254    card64                                DefaultTimeout;
00255    std::multimap<const cardinal,Client*> ClientSet;
00256 };
00257 
00258 
00259 #include "rtcpabstractserver.icc"
00260 
00261 
00262 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines