RTP Audio System  2.0.0
audioserver.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                      RTP Audio Server Project                    ####
00004 // ####                    ============================                  ####
00005 // ####                                                                  ####
00006 // #### Audio Server                                                     ####
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: audioserver.h 1286 2011-12-18 13:43:16Z dreibh $
00032 
00033 
00034 #ifndef AUDIOSERVER_H
00035 #define AUDIOSERVER_H
00036 
00037 
00038 #include "tdsystem.h"
00039 #include "multiaudioreader.h"
00040 #include "tdsocket.h"
00041 #include "audioencoderrepository.h"
00042 #include "rtpsender.h"
00043 #include "rtcppacket.h"
00044 #include "rtcpreceiver.h"
00045 #include "rtcpabstractserver.h"
00046 #include "multiaudioreader.h"
00047 #include "qosmanagerinterface.h"
00048 
00049 #include "audioclientapppacket.h"
00050 
00051 #include <map>
00052 
00053 
00061 class AudioServer : public RTCPAbstractServer
00062 {
00063    // ====== Definitions ====================================================
00064    private:
00065    struct User {
00066       RTCPAbstractServer::Client* Client;
00067       RTPSender                   Sender;
00068       Socket                      SenderSocket;
00069       InternetFlow                Flow;
00070       AudioEncoderRepository      Repository;
00071       MultiAudioReader            Reader;
00072       String                      MediaName;
00073       integer                     StreamIdentifier;
00074       card64                      BandwidthLimit;
00075       card16                      LastSequenceNumber;
00076       card16                      PosChgSeqNumber;
00077       bool                        UserLimitPause;
00078       bool                        ManagerLimitPause;
00079       bool                        ClientPause;
00080    };
00081 
00082 
00083    // ====== Constructor/Destructor =========================================
00084    public:
00092    AudioServer(QoSManagerInterface* qosManager    = NULL,
00093                const cardinal       maxPacketSize = 1500,
00094                const bool           useSCTP       = false);
00095 
00099    ~AudioServer();
00100 
00101 
00102    // ====== Status functions ===============================================
00108    card32 getOurSSRC() const;
00109 
00115    inline bool getLossScalability() const;
00116 
00122    inline void setLossScalability(const bool on);
00123 
00124 
00125    // ====== Packet size ====================================================
00131    inline cardinal getMaxPacketSize() const;
00132 
00139    inline cardinal setMaxPacketSize(const cardinal size);
00140 
00141 
00142    // ====== RTCPAbstractServer implementation ==============================
00146    void outOfMemoryWarning();
00147 
00153    void* newClient(RTCPAbstractServer::Client* client, const char* cname);
00154 
00160    void deleteClient(RTCPAbstractServer::Client* client, const DeleteReason reason);
00161 
00167    bool checkClient(RTCPAbstractServer::Client* client);
00168 
00174    void appMessage(RTCPAbstractServer::Client* client,
00175                    const char*                 name,
00176                    void*                       data,
00177                    const cardinal              dataLength);
00178 
00184    void sdesMessage(RTCPAbstractServer::Client* client,
00185                     const card8                 type,
00186                     char*                       data,
00187                     const cardinal              length);
00188 
00194    void receiverReport(RTCPAbstractServer::Client* client,
00195                        RTCPReceptionReportBlock*   report,
00196                        const cardinal              layer);
00197 
00198 
00199    // ====== Execute user command ===========================================
00207    void userCommand(RTCPAbstractServer::Client* client,
00208                     User*                       user,
00209                     AudioClientAppPacket*       app);
00210 
00217    void managementUpdate(RTCPAbstractServer::Client* client, User* user);
00218 
00219 
00220    // ====== Private data ===================================================
00221    private:
00222    QoSManagerInterface*                QoSMgr;
00223    std::multimap<const cardinal,User*> UserSet;
00224    Synchronizable                      UserSetSync;
00225    cardinal                            MaxPacketSize;
00226    card32                              OurSSRC;
00227    bool                                LossScalability;
00228    bool                                UseSCTP;
00229 };
00230 
00231 
00232 #include "audioserver.icc"
00233 
00234 
00235 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines