source: trunk/src/testing/include/sageReceiver.h @ 4

Revision 4, 4.2 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: sageReceiver.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 SAGERECEIVER_H_
42#define SAGERECEIVER_H_
43
44#include "sage.h"
45
46#define STREAM_ACTIVE   1
47#define STREAM_INACTIVE 2
48#define STREAM_WAITING  3
49
50class sageReceiver;
51class sageBlockQueue;
52class rcvSharedData;
53class streamProtocol;
54
55/**
56 * class sageReceiver
57 */
58class sageReceiver {
59protected:
60   int instID, senderNum, blockSize;
61   streamProtocol *nwObj;
62   bool endFlag;
63   pthread_t thId;
64
65   /**
66    * It just calls virtual member function readData()<BR>
67    *
68    * This thread is started in the sageAudioReceiver::addStream()<BR>
69    * sagePixelReciever's Constructor
70    * <BR>
71    * So, when a pixelDownloader is instantiated and initiated, sagePixelReceiver starts<BR>
72    * then this network thread starts.
73    *
74    */
75   static void* nwReadThread(void *args);
76   virtual int readData() = 0; /**< pure virtual member function */
77
78public:
79   sageReceiver() : endFlag(false) {}
80
81   int getInstID() { return instID; }
82   virtual int addStream(int senderID) = 0; /**< pure virtual member function */
83
84   int getSenderNum() {return senderNum;}
85};
86
87class sageBlockGroup;
88class sageBlockBuf;
89
90/**
91 * class streamData
92 */
93class streamData {
94public:
95   int senderID;
96   int dataSockFd;
97   int curFrame;
98   bool dataReady;
99   sageBlockGroup* bGroup;
100
101   streamData() : curFrame(0), bGroup(NULL), dataReady(false) {}
102};
103
104/**
105 * class sagePixelReceiver
106 */
107class sagePixelReceiver : public sageReceiver {
108protected:
109   rcvSharedData *shared;
110   sageBlockBuf *blockBuf;
111   streamData *streamList;
112   int streamIdx;
113   int groupSize;
114   int configID;
115
116   pthread_mutex_t streamLock;
117   pthread_cond_t  connectionDone;
118   bool connecting;
119   int curFrame;
120   fd_set streamFds;
121   int maxSockFd;
122
123   /**
124    * Receiving pixel data from an application<BR>
125    * Generates EVENT_READ_BLOCK
126    */
127   int readData();
128   int checkStreams();
129
130public:
131        /**
132         * constructor starts nwReadThread of the super class<BR>
133         * This thread just calls virtual function readData()
134         */
135   sagePixelReceiver(char *msg, rcvSharedData *sh, streamProtocol *obj, sageBlockBuf *buf);
136
137   /**
138    * creates EVENT_APP_CONNECTED. This leads invoking fsClient::sendMessage() with the code DISP_APP_CONNECTED
139    */
140   int addStream(int senderID);
141   ~sagePixelReceiver();
142};
143
144#endif
Note: See TracBrowser for help on using the repository browser.