RTP Audio System  2.0.0
rtpa-qclient.h
Go to the documentation of this file.
00001 // ##########################################################################
00002 // ####                                                                  ####
00003 // ####                      RTP Audio Server Project                    ####
00004 // ####                    ============================                  ####
00005 // ####                                                                  ####
00006 // #### QClient - A graphical client for the RTP 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: rtpa-qclient.h 1286 2011-12-18 13:43:16Z dreibh $
00032 
00033 
00034 #ifndef RTPA_QCLIENT_H
00035 #define RTPA_QCLIENT_H
00036 
00037 
00038 #include "audiowriterinterface.h"
00039 #include "spectrumanalyzer.h"
00040 #include "audiomixer.h"
00041 #include "tools.h"
00042 #include "strings.h"
00043 #include "audioclient.h"
00044 #include "strings.h"
00045 
00046 
00047 #include <qapplication.h>
00048 #include <qlayout.h>
00049 #include <qpushbutton.h>
00050 #include <qscrollbar.h>
00051 #include <qlineedit.h>
00052 #include <qbuttongroup.h>
00053 #include <qcheckbox.h>
00054 #include <qcombobox.h>
00055 #include <qradiobutton.h>
00056 #include <qframe.h>
00057 #include <qgroupbox.h>
00058 #include <qlabel.h>
00059 #include <qlcdnumber.h>
00060 #include <qwhatsthis.h>
00061 #include <qmainwindow.h>
00062 #include <qlist.h>
00063 
00064 
00065 #include "qspectrumanalyzer.h"
00066 #include "qaudiomixer.h"
00067 #include "qinfotabwidget.h"
00068 
00069 
00073 const InfoEntry InfoEntries1[] = {
00074    {"SA",    "Server Address",   "This are the IPv4 or IPv6 address and port number of the audio server."},
00075    {"TF",    "TOS/Flow Label",   "This are the TOS/traffic class values for each layer and the flow label "
00076                                  "(IPv6 only) of the received packets."},
00077    {"SSSRC", "Server SSRC",      "This is the audio server's RTP SSRC. It is a 32-bit random number."},
00078    {"CA",    "Client Address",   "This is the IPv4 or IPv6 address and port number of the audio client."},
00079    {"CSSRC", "Client SSRC",      "This is the audio clients's RTP SSRC. It is a 32-bit random number."},
00080    {"BR",    "Bytes Received",   "This is a counter for the number of bytes received from server "
00081                                  "(IP/UDP/RTP/RTP Audio headers + payload)."},
00082    {"PR",    "Packets Received", "This is a counter for the number of packets received from server. "
00083                                  "The bytes per second value is the value for the quality received "
00084                                  "from server (IP/UDP/RTP/RTP Audio headers + payload)."},
00085    {"PL",    "Packets Lost",     "This is a counter for the number of packets lost during transmission."
00086                                  "The loss fraction shows the fraction of packets lost during the last "
00087                                  "RTCP report interval in each layer."},
00088    {"IJ", "Interarrival Jitter", "This is the interarrival jitter: An estimate of the statistical variance of "
00089                                  "the RTP data packet interarrival time, measured in milliseconds.\n\n"
00090                                  "Definition:\n"
00091                                  "Let Si, Sj be the RTP timestamps of packets i, j.\n"
00092                                  "Let Ri, Rj be the arrival timestamps.\n"
00093                                  "Dij := (Rj - Sj) - (Ri - Si).\n"
00094                                  "Jitter := Jitter + (1.0/16.0) * abs(Dij).\n\n"
00095                                  "See RFC 1889, Page 25-26 for more details."},
00096    {"Q", "Quality",  "This is the audio quality received from server: Sampling rate, bits and channels."},
00097    {"E", "Encoding", "This is the name of the audio encoding format received from server."},
00098 };
00099 
00100 
00104 const InfoTable InfoTable1 =
00105 {
00106    sizeof(InfoEntries1) / sizeof(InfoEntry),
00107    (const InfoEntry*)&InfoEntries1
00108 };
00109 
00110 
00111 
00115 const InfoEntry InfoEntries2[] = {
00116    {"LSA", "Source",           "This is the current layer's source address and port number."},
00117    {"LTF", "TOS/Flow Label",   "This are the current layer's traffic class and flow label (IPv6 only)."},
00118    {"CA",  "Destination",      "This is the current layer's destination address and port number."},
00119    {"LPR", "Packets Received", "This is the number of packets received in this layer."},
00120    {"LPL", "Packets Lost",     "This is the number of packets lost in this layer."},
00121    {"LFL", "Fraction Lost",    "This is the fraction of packets lost in this layer."},
00122    {"LBR", "Bytes Received",   "This is the sum of bytes received in this layer."},
00123    {"LIJ", "Interarrival Jitter", "This is the interarrival jitter of this layer."},
00124    {"Q", "Quality",  "This is the audio quality received from server: Sampling rate, bits and channels."},
00125    {"E", "Encoding", "This is the name of the audio encoding format received from server."},
00126 };
00127 
00128 
00132 const InfoTable InfoTable2 =
00133 {
00134    sizeof(InfoEntries2) / sizeof(InfoEntry),
00135    (const InfoEntry*)&InfoEntries2
00136 };
00137 
00138 
00139 
00147 class QClient : public QMainWindow
00148 {
00149    Q_OBJECT
00150 
00151    // ====== Constructor/Destructor =========================================
00152    public:
00163    QClient(AudioWriterInterface* audioOutput,
00164            const char*           receiverName = NULL,
00165            const char*           defaultURL   = NULL,
00166            SpectrumAnalyzer*     analyzer     = NULL,
00167            AudioMixer*           mixer        = NULL,
00168            QWidget*              parent       = NULL);
00169 
00173    ~QClient();
00174 
00175 
00176    // ====== Slots for Qt ===================================================
00177    public slots:
00181    void play();
00182 
00186    void stop();
00187 
00191    void information();
00192 
00196    void whatsThis();
00197 
00201    void pause(bool on);
00202 
00206    void togglePause();
00207 
00211    void toggleAddressResolution(bool selected);
00212 
00216    void spectrumAnalyzer();
00217 
00221    void audioMixer();
00222 
00226    void closeSpectrumAnalyzer();
00227 
00231    void closeAudioMixer();
00232 
00236    void quit();
00237 
00241    void position(int value);
00242 
00246    void setSamplingRate(int index);
00247 
00251    void setChannels(bool stereo);
00252 
00256    void setBits(int index);
00257 
00261    void setEncoding(int index);
00262 
00266    void locationSelected(QAction* action);
00267 
00271    void loadBookmarks();
00272 
00276    void clearBookmarks();
00277 
00281    void saveBookmarks();
00282 
00286    void timerEvent();
00287 
00288 
00289    // ====== Status update ==================================================
00290    private:
00291    void updateCounter(card64 position);
00292    void insertURL(const String& urlToInsert, const int where = 0);
00293 
00294 
00295    // ====== Private data ===================================================
00296    private:
00297    void showError(const cardinal error);
00298    QString bytesToQString(const card64 bytes) const;
00299    QString card64ToQString(const card64 value,
00300                            const char*  formatString = "%Ld") const;
00301    QString doubleToQString(const double value,
00302                            const char*  formatString = "%f") const;
00303    QString flowInfoToQString(const card8  trafficClass,
00304                              const card32 flowLabel) const;
00305 
00306    static const cardinal LocationCount           = 15;
00307    static const cardinal DisplayUpdateInterval   = 250;
00308    static const cardinal EOFRepeatInterval       = 20000 / DisplayUpdateInterval;
00309    static const cardinal MaxScrollBarUpdateDelay = 4;
00310    static const cardinal MaxLayerInfo            = 3;
00311 
00312    QAction*              ResolverAction;
00313    QAction*              MixerAction;
00314    QAction*              SpectrumAnalyzerAction;
00315    QAction*              AutoRepeatAction;
00316    QAction*              AutoSaveBookmarksAction;
00317    QAction*              LocationAction[LocationCount];
00318 
00319    QSpectrumAnalyzer*    SpectrumAnalyzerWindow;
00320    QAudioMixer*          MixerWindow;
00321    SpectrumAnalyzer*     SpectrumAnalyzerDevice;
00322    AudioMixer*           MixerDevice;
00323 
00324    QMenu*                ToolsMenu;
00325    QMenu*                URLMenu;
00326    QMenu*                SettingsMenu;
00327    QLineEdit*            Location;
00328    QLCDNumber*           Counter;
00329    QLabel*               TitleLabel;
00330    QLabel*               ArtistLabel;
00331    QLabel*               CommentLabel;
00332    QLabel*               StatusBar;
00333    QInfoTabWidget*       InfoWidget;
00334    QInfoWidget*          LayerInfo[MaxLayerInfo];
00335    QScrollBar*           ScrollBar;
00336    bool                  ScrollBarUpdated;
00337    cardinal              ScrollBarUpdateDelay;
00338    cardinal              EOFRepeatDelay;
00339    QPushButton*          Pause;
00340    QWhatsThis*           WhatsThis;
00341 
00342    AudioClient*          Client;
00343    QList<String*>        URLList;
00344    String                PlayingURL;
00345    bool                  InsertionRequired;
00346 };
00347 
00348 
00349 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines