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 __JACKTRIPWORKER_H__ 00039 #define __JACKTRIPWORKER_H__ 00040 00041 #include <iostream> 00042 00043 #include <QThreadPool> 00044 #include <QObject> 00045 #include <QEventLoop> 00046 #include <QHostAddress> 00047 #include <QMutex> 00048 00049 #include "jacktrip_types.h" 00050 00051 class JackTrip; // forward declaration 00052 class UdpMasterListener; // forward declaration 00053 00054 00064 // Note that it is not possible to start run() as an event loop. That has to be implemented 00065 // inside a QThread 00066 class JackTripWorker : public QObject, public QRunnable 00067 { 00068 Q_OBJECT; // QRunnable is not a QObject, so I have to inherit from QObject as well 00069 00070 public: 00072 JackTripWorker(UdpMasterListener* udpmasterlistener); 00073 00075 virtual ~JackTripWorker(); 00076 00080 void run(); 00081 00085 bool isSpawning(); 00086 00091 void setJackTrip(int id, uint32_t client_address, 00092 uint16_t server_port, uint16_t client_port, 00093 int num_channels); 00094 00095 00096 private slots: 00097 void slotTest() 00098 { 00099 std::cout << "--- JackTripWorker TEST SLOT ---" << std::endl; 00100 } 00101 00102 00103 private: 00104 00105 UdpMasterListener* mUdpMasterListener; 00106 QHostAddress mClientAddress; 00107 uint16_t mServerPort; 00108 00110 uint16_t mClientPort; 00111 00114 volatile bool mSpawning; 00115 QMutex mMutex; 00116 00117 int mID; 00118 int mNumChans; 00119 }; 00120 00121 00122 #endif //__JACKTRIPWORKER_H__