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_types.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);
73 
75  virtual ~JackTripWorker();
76 
80  void run();
81 
85  bool isSpawning();
86 
91  void setJackTrip(int id, uint32_t client_address,
92  uint16_t server_port, uint16_t client_port,
93  int num_channels);
94 
95 
96 private slots:
97  void slotTest()
98  {
99  std::cout << "--- JackTripWorker TEST SLOT ---" << std::endl;
100  }
101 
102 
103 private:
104 
106  QHostAddress mClientAddress;
108 
111 
114  volatile bool mSpawning;
115  QMutex mMutex;
116 
117  int mID;
118  int mNumChans;
119 };
120 
121 
122 #endif //__JACKTRIPWORKER_H__
uint16_t mClientPort
Client Outgoing Port. By convention, the receving port will be mClientPort -1
Definition: JackTripWorker.h:110
bool isSpawning()
Check if the Thread is Spawning.
Definition: JackTripWorker.cpp:174
quint32 uint32_t
Typedef for unsigned int. This type is guaranteed to be 32-bit.
Definition: jacktrip_types.h:69
Master UDP listener on the Server.
Definition: UdpMasterListener.h:58
QHostAddress mClientAddress
Client Address.
Definition: JackTripWorker.h:106
int mNumChans
Number of Channels.
Definition: JackTripWorker.h:118
void run()
Implements the Thread Loop. To start the thread, call start() ( DO NOT CALL run() )...
Definition: JackTripWorker.cpp:100
QMutex mMutex
Mutex to protect mSpawning.
Definition: JackTripWorker.h:115
void slotTest()
Definition: JackTripWorker.h:97
virtual ~JackTripWorker()
The class destructor.
Definition: JackTripWorker.cpp:74
UdpMasterListener * mUdpMasterListener
Master Listener Socket.
Definition: JackTripWorker.h:105
volatile bool mSpawning
Definition: JackTripWorker.h:114
Prototype of the worker class that will be cloned through sending threads to the Thread Pool...
Definition: JackTripWorker.h:66
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:82
Main class to creates a SERVER (to listen) or a CLIENT (to connect to a listening server) to send aud...
Definition: JackTrip.h:59
uint16_t mServerPort
Server Ephemeral Incomming Port to use with Client.
Definition: JackTripWorker.h:107
JackTripWorker(UdpMasterListener *udpmasterlistener)
The class constructor.
Definition: JackTripWorker.cpp:53
quint16 uint16_t
Typedef for unsigned short. This type is guaranteed to be 16-bit.
Definition: jacktrip_types.h:67
int mID
ID thread number.
Definition: JackTripWorker.h:117