JackTrip

JackTripWorker.h
Go to the documentation of this file.
1 //*****************************************************************
2 /*
3 JackTrip: A System for High-Quality Audio Network Performance
4 over the Internet
5
6 Copyright (c) 2008 Juan-Pablo Caceres, Chris Chafe.
7 SoundWIRE group at CCRMA, Stanford University.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use,
13 copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following
16 conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 OTHER DEALINGS IN THE SOFTWARE.
29 */
30 //*****************************************************************
31
38 #ifndef __JACKTRIPWORKER_H__
39 #define __JACKTRIPWORKER_H__
40
41 #include <iostream>
42
43 #include <QThreadPool>
44 #include <QObject>
45 #include <QEventLoop>
46 #include <QHostAddress>
47 #include <QMutex>
48
49 #include "JackTrip.h"
50
51 //class JackTrip; // forward declaration
52 class UdpMasterListener; // forward declaration
53
54
64 // Note that it is not possible to start run() as an event loop. That has to be implemented
65 // inside a QThread
66 class JackTripWorker : public QObject, public QRunnable
67 {
68 Q_OBJECT; // QRunnable is not a QObject, so I have to inherit from QObject as well
69
70 public:
72 JackTripWorker(UdpMasterListener* udpmasterlistener);
74 virtual ~JackTripWorker();
75
78 void run();
81 bool isSpawning();
85 void setJackTrip(int id, uint32_t client_address,
86 uint16_t server_port, uint16_t client_port,
87 int num_channels);
89 void stopThread();
90 int getID()
91 {
92 return mID;
93 }
94
95
96 private slots:
97 void slotTest()
98 { std::cout << "--- JackTripWorker TEST SLOT ---" << std::endl; }
99
100
101 signals:
102 void signalRemoveThread();
103
104
105 private:
106 int setJackTripFromClientHeader(JackTrip& jacktrip);
107 JackTrip::connectionModeT getConnectionModeFromHeader();
108
109 UdpMasterListener* mUdpMasterListener;
110 //QHostAddress mClientAddress; ///< Client Address
111 uint32_t mClientAddress;
112 uint16_t mServerPort;
113
115 uint16_t mClientPort;
116
119 volatile bool mSpawning;
120 QMutex mMutex;
121
122 int mID;
123 int mNumChans;
124 };
125
126
127 #endif //__JACKTRIPWORKER_H__
JackTripWorker::getID
int getID()
Definition: JackTripWorker.h:90
JackTrip.h
JackTripWorker::isSpawning
bool isSpawning()
Check if the Thread is Spawning.
Definition: JackTripWorker.cpp:264
uint32_t
quint32 uint32_t
Typedef for unsigned int. This type is guaranteed to be 32-bit.
Definition: jacktrip_types.h:73
JackTrip::connectionModeT
connectionModeT
Enum for Connection Mode (useful for connections to MultiClient Server)
Definition: JackTrip.h:102
UdpMasterListener
Master UDP listener on the Server.
Definition: UdpMasterListener.h:62
JackTripWorker::run
void run()
Implements the Thread Loop. To start the thread, call start() ( DO NOT CALL run() )...
Definition: JackTripWorker.cpp:104
JackTripWorker::~JackTripWorker
virtual ~JackTripWorker()
The class destructor.
Definition: JackTripWorker.cpp:78
JackTripWorker
Prototype of the worker class that will be cloned through sending threads to the Thread Pool...
Definition: JackTripWorker.h:66
JackTripWorker::setJackTrip
void setJackTrip(int id, uint32_t client_address, uint16_t server_port, uint16_t client_port, int num_channels)
Sets the JackTripWorker properties.
Definition: JackTripWorker.cpp:85
JackTrip
Main class to creates a SERVER (to listen) or a CLIENT (to connect to a listening server) to send aud...
Definition: JackTrip.h:67
JackTripWorker::signalRemoveThread
void signalRemoveThread()
Definition: moc_JackTripWorker.cpp:135
JackTripWorker::JackTripWorker
JackTripWorker(UdpMasterListener *udpmasterlistener)
The class constructor.
Definition: JackTripWorker.cpp:57
uint16_t
quint16 uint16_t
Typedef for unsigned short. This type is guaranteed to be 16-bit.
Definition: jacktrip_types.h:71
JackTripWorker::stopThread
void stopThread()
Stop and remove thread from pool.
Definition: JackTripWorker.cpp:272