1 | /******************************************************************************
|
---|
2 | * SAGE - Scalable Adaptive Graphics Environment
|
---|
3 | *
|
---|
4 | * Module: sageAudioManager.h
|
---|
5 | * Author : Byungil Jeong, Rajvikram Singh
|
---|
6 | *
|
---|
7 | * Copyright (C) 2004 Electronic Visualization Laboratory,
|
---|
8 | * University of Illinois at Chicago
|
---|
9 | *
|
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * Redistribution and use in source and binary forms, with or without |
---|
13 | * modification, are permitted provided that the following conditions are met: |
---|
14 | * |
---|
15 | * * Redistributions of source code must retain the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer. |
---|
17 | * * Redistributions in binary form must reproduce the above |
---|
18 | * copyright notice, this list of conditions and the following disclaimer |
---|
19 | * in the documentation and/or other materials provided with the distribution. |
---|
20 | * * Neither the name of the University of Illinois at Chicago nor |
---|
21 | * the names of its contributors may be used to endorse or promote |
---|
22 | * products derived from this software without specific prior written permission. |
---|
23 | * |
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
28 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
30 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
31 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
35 | *
|
---|
36 | * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
|
---|
37 | * http://www.evl.uic.edu/cavern/forum/
|
---|
38 | *
|
---|
39 | *****************************************************************************/
|
---|
40 |
|
---|
41 | #ifndef _SAGE_AUDIO_MANAGER_H_
|
---|
42 | #define _SAGE_AUDIO_MANAGER_H_
|
---|
43 |
|
---|
44 | #include "fsClient.h"
|
---|
45 | #include "streamProtocol.h"
|
---|
46 | #include "sageAudioModule.h"
|
---|
47 |
|
---|
48 | class sageAudioManager;
|
---|
49 | class sageEvent;
|
---|
50 | class sageAudioReceiver;
|
---|
51 | class sageTcpModule;
|
---|
52 | class sageUdpModule;
|
---|
53 | class sageEventQueue;
|
---|
54 | class sageSyncClient;
|
---|
55 |
|
---|
56 | typedef struct {
|
---|
57 | sageAudioManager *This;
|
---|
58 | streamProtocol *nwObj;
|
---|
59 | } nwCheckThreadParam;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * \brief The binary of this class is executed by sageVirtualDesktop.launchAudioReceiver()
|
---|
63 | *
|
---|
64 | * This class is very similar to the class sageDisplayManager |
---|
65 | */
|
---|
66 | class sageAudioManager : public fsClient {
|
---|
67 | private:
|
---|
68 | int nodeID;
|
---|
69 | sageTcpModule *tcpObj; /**< TCP module */
|
---|
70 | sageUdpModule *udpObj; /**< UDP module */
|
---|
71 | sageNwConfig nwCfg;
|
---|
72 | sageEventQueue *eventQueue; /**< event queue. continuously checked in the mainLoop() */
|
---|
73 | sageSyncClient *syncClientObj; /**< sageSyncClient object*/
|
---|
74 |
|
---|
75 | sageAudioModule *audioModule; /**< sageAudioModule */
|
---|
76 | sageAudioConfig audioCfg;
|
---|
77 |
|
---|
78 |
|
---|
79 | std::vector<sageAudioReceiver *> receiverList; /**< a list of sageAudioReceiver object. It responsible for receiving streams from sageAudioStreamer */
|
---|
80 |
|
---|
81 | int syncPort, streamPort;
|
---|
82 | int totalRcvNum;
|
---|
83 | int memSize;
|
---|
84 | bool rcvEnd;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * handles below events <BR>
|
---|
88 | * EVENT_NEW_CONNECTION -> initStreams()<BR>
|
---|
89 | * EVENT_NEW_MESSAGE -> parseMessage()<BR>
|
---|
90 | * EVENT_SYNC_MESSAGE -> processSync() |
---|
91 | */
|
---|
92 | int parseEvent(sageEvent *event);
|
---|
93 | int parseMessage(sageMessage *msg);
|
---|
94 | int perfReport();
|
---|
95 | int startPerformanceReport(sageMessage *msg);
|
---|
96 | int stopPerformanceReport(sageMessage *msg);
|
---|
97 | int shutdownApp(int appId);
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * sets tcpObj, udpObj and starts nwCheckThread() for each protocol |
---|
101 | */
|
---|
102 | int initNetworks();
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * This function is called when EVENT_NEW_CONNECTION arrives<BR>
|
---|
106 | * sageAudioCircBuffer is created and passed to sageAudioReceiver::sageAudioReceiver<BR>
|
---|
107 | * sageAudioReceiver::addStream() is called for each element in the receiverList.<BR>
|
---|
108 | * The first receiver object becomes Master
|
---|
109 | * |
---|
110 | */
|
---|
111 | int initStreams(char *msg, streamProtocol *nwObj);
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * calls sageAudioReceiver.processSync() for each element in the receiverList |
---|
115 | */
|
---|
116 | int processSync(char *msg);
|
---|
117 | int checkConnection();
|
---|
118 |
|
---|
119 | static void* nwCheckThread(void *args); /**< keeps checking connection, if one has found, then generates EVENT_NEW_CONNECTION */
|
---|
120 | static void* msgCheckThread(void *args); /**< receives new message and generates EVENT_NEW_MESSAGE */
|
---|
121 | static void* syncCheckThread(void *args); /**< calls sageSyncClient::waitForSync() then generates EVENT_SYNC_MESSAGE */
|
---|
122 | static void* perfReportThread(void *args);
|
---|
123 | static void* refreshThread(void *args);
|
---|
124 |
|
---|
125 | public:
|
---|
126 | sageAudioManager(int argc, char **argv);
|
---|
127 | ~sageAudioManager();
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * creates sageAudioModule object and sageSyncClient object. calls sageSyncClient::connectToServer()<BR>
|
---|
131 | * starts syncCheckThread() and refreshThread() |
---|
132 | */
|
---|
133 | int init(char *msg);
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * keeps getting new event from the eventQueue then calls parseEvent() |
---|
137 | */
|
---|
138 | void mainLoop();
|
---|
139 | };
|
---|
140 |
|
---|
141 | #endif
|
---|