RTP Audio System  2.0.0
audioclient.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                      RTP Audio Server Project                    ####
00004 // ####                    ============================                  ####
00005 // ####                                                                  ####
00006 // #### Audio Client 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: audioclient.h 1286 2011-12-18 13:43:16Z dreibh $
00032 
00033 
00034 #ifndef AUDIOCLIENT_H
00035 #define AUDIOCLIENT_H
00036 
00037 
00038 #include "audiowriterinterface.h"
00039 #include "audiodecoderinterface.h"
00040 #include "audiodecoderrepository.h"
00041 #include "mediainfo.h"
00042 #include "rtcpsender.h"
00043 #include "rtpreceiver.h"
00044 #include "internetaddress.h"
00045 #include "tdsocket.h"
00046 #include "strings.h"
00047 
00048 #include "audioclientapppacket.h"
00049 
00050 #include <map>
00051 
00052 
00060 class AudioClient : virtual public AdjustableAudioQualityInterface
00061 {
00062    // ====== Constructor/Destructor =========================================
00063    public:
00069    AudioClient(AudioWriterInterface* audioOutput);
00070 
00074    virtual ~AudioClient();
00075 
00076 
00077    // ====== Player functions ===============================================
00078    public:
00085    bool play(const char* url);
00086 
00095    bool change(const char* mediaName);
00096 
00100    void stop();
00101 
00102 
00103    // ====== Settings =======================================================
00111    card64 getPosition();
00112 
00118    inline card64 getMaxPosition() const;
00119 
00120 
00126    card16 getSamplingRate() const;
00127 
00133    card8 getBits() const;
00134 
00140    card8 getChannels() const;
00141 
00142 
00148    card16 getByteOrder() const;
00149 
00150 
00156    cardinal getBytesPerSecond() const;
00157 
00163    cardinal getBitsPerSample() const;
00164 
00165 
00171    cardinal getRawBytesPerSecond();
00172 
00173 
00179    MediaInfo getMediaInfo() const;
00180 
00181 
00187    inline card8 getErrorCode() const;
00188 
00194    inline const char* getEncoding() const;
00195 
00201    inline card32 getBandwidthLimit() const;
00202 
00208    card8 getIPVersion() const;
00209 
00215    inline bool playing() const;
00216 
00217 
00226    String getServerAddressString(const InternetAddress::PrintFormat format = InternetAddress::PF_Address) const;
00227 
00236    String getOurAddressString(const InternetAddress::PrintFormat format = InternetAddress::PF_Address) const;
00237 
00238 
00242    inline cardinal getLayers() const;
00243 
00250    inline card64 getBytesReceived(const cardinal layer = 0) const;
00251 
00260    inline card64 getPacketsReceived(const cardinal layer = 0) const;
00261 
00270    inline InternetFlow getInternetFlow(const cardinal layer = 0) const;
00271 
00280    inline card32 getFlowLabel(const cardinal layer = 0) const;
00281 
00290    inline card8 getTrafficClass(const cardinal layer = 0) const;
00291 
00300    card32 getServerSSRC(const cardinal layer = 0) const;
00301 
00307    inline card32 getOurSSRC() const;
00308 
00317    card64 getPacketsLost(const cardinal layer = 0) const;
00318 
00327    double getFractionLost(const cardinal layer = 0) const;
00328 
00337    double getJitter(const cardinal layer = 0) const;
00338 
00339 
00346    const char* getEncodingName(const cardinal index);
00347 
00348 
00354    inline void setPosition(const card64 position);
00355 
00361    void setPause(const bool on);
00362 
00368    card16 setSamplingRate(const card16 rate);
00369 
00375    card8 setChannels(const card8 channels);
00376 
00382    card8 setBits(const card8 bits);
00383 
00389    card16 setByteOrder(const card16 byteOrder);
00390 
00396    void setEncoding(const cardinal index);
00397 
00403    inline void setBandwidthLimit(const card32 bandwidthLimit);
00404 
00405 
00406    // ====== Private data ===================================================
00407    private:
00408    void sendCommand(const bool updateRestartPosition = true);
00409 
00410 
00411    // Update of RestartPosition has to be delayed after change() call to
00412    // ensure that there are no more packets of the old file on the network
00413    // which change the restart position back to the old value.
00414    static const card64 RestartPositionUpdateDelay = 5000000;
00415 
00416 
00417    AudioWriterInterface*                                AudioOutput;
00418    RTPReceiver*                                         Receiver;
00419    RTCPSender*                                          Sender;
00420    Socket                                               SenderSocket;
00421    Socket                                               ReceiverSocket;
00422    InternetFlow                                         Flow;
00423    InternetAddress                                      ServerAddress;
00424    InternetAddress                                      OurAddress;
00425    card32                                               OurSSRC;
00426 
00427    std::multimap<const cardinal,AudioDecoderInterface*> DecoderSet;
00428    AudioDecoderRepository                               Decoders;
00429 
00430    AudioClientAppPacket                                 Status;
00431    card64                                               OldPosition;
00432    card64                                               ChangeTimeStamp;
00433    bool                                                 IsPlaying;
00434 };
00435 
00436 
00437 #include "audioclient.icc"
00438 
00439 
00440 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines