• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

src/UdpMasterListener.h

Go to the documentation of this file.
00001 //*****************************************************************
00002 /*
00003   JackTrip: A System for High-Quality Audio Network Performance
00004   over the Internet
00005 
00006   Copyright (c) 2008 Juan-Pablo Caceres, Chris Chafe.
00007   SoundWIRE group at CCRMA, Stanford University.
00008   
00009   Permission is hereby granted, free of charge, to any person
00010   obtaining a copy of this software and associated documentation
00011   files (the "Software"), to deal in the Software without
00012   restriction, including without limitation the rights to use,
00013   copy, modify, merge, publish, distribute, sublicense, and/or sell
00014   copies of the Software, and to permit persons to whom the
00015   Software is furnished to do so, subject to the following
00016   conditions:
00017   
00018   The above copyright notice and this permission notice shall be
00019   included in all copies or substantial portions of the Software.
00020   
00021   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00023   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00024   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00025   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00026   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028   OTHER DEALINGS IN THE SOFTWARE.
00029 */
00030 //*****************************************************************
00031 
00038 #ifndef __UDPMASTERLISTENER_H__
00039 #define __UDPMASTERLISTENER_H__
00040 
00041 #include <iostream>
00042 
00043 #include <QThread>
00044 #include <QThreadPool>
00045 #include <QUdpSocket>
00046 #include <QHostAddress>
00047 
00048 #include "jacktrip_types.h"
00049 #include "jacktrip_globals.h"
00050 class JackTripWorker; // forward declaration
00051 
00052 
00058 class UdpMasterListener : public QThread
00059 {
00060   Q_OBJECT;
00061 
00062 public:
00063   UdpMasterListener(int server_port = gServerUdpPort);
00064   virtual ~UdpMasterListener();
00065   
00069   void run();
00070 
00072   void stop() { mStopped = true; };
00073 
00074   int releasePort(int id);
00075 
00076 private slots:
00077   void testRecieve()
00078   {
00079     std::cout << "========= TEST RECEIVE SLOT ===========" << std::endl;
00080   }
00081 
00082 signals:
00083   void Listening();
00084   void ClientAddressSet();
00085 
00086 
00087 private:
00092   static void bindUdpSocket(QUdpSocket& udpsocket, int port);
00093 
00094   /* \brief Send the JackTripWorker to the thread pool. This will run
00095    * until it's done. We still have control over the prototype class.
00096    * \param id Identification Number
00097    */
00098   void sendToPoolPrototype(int id);
00099 
00104   int isNewAddress(uint32_t address, uint16_t port);
00105 
00106   QUdpSocket mUdpMasterSocket; 
00107   QHostAddress mPeerAddress; 
00108 
00109   JackTripWorker* mJTWorker; 
00110   QThreadPool mThreadPool; 
00111 
00112   int mServerPort; //< Server known port number
00113   int mBasePort;
00114   uint32_t mActiveAddress[gMaxThreads][2]; 
00115   QHash<uint32_t, uint16_t> mActiveAddresPortPair;
00116 
00118   volatile bool mStopped;
00119   int mTotalRunningThreads; 
00120 };
00121 
00122 
00123 #endif //__UDPMASTERLISTENER_H__

 

Documentation generated by Doxygen 1.7.1 on Thu Feb 10 2011 18:57:32

© 2008 by Juan-Pablo Caceres (jcaceres at ccrma dot stanford dot edu) and Chris Chafe
SoundWIRE Group at CCRMA - Stanford University

SourceForge.net Logo