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

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

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: sageTcpModule.h
5 * Author : Byungil Jeong, Rajvikram Singh
6 * Description:   This is the header file of the UDP code used for trasmitting graphics.
7 *                The template for the interface is given by the streamProtocol class.
8 *
9 * Copyright (C) 2004 Electronic Visualization Laboratory,
10 * University of Illinois at Chicago
11 *
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 *
17 *  * Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 *  * Redistributions in binary form must reproduce the above
20 *    copyright notice, this list of conditions and the following disclaimer
21 *    in the documentation and/or other materials provided with the distribution.
22 *  * Neither the name of the University of Illinois at Chicago nor
23 *    the names of its contributors may be used to endorse or promote
24 *    products derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
39 * http://www.evl.uic.edu/cavern/forum/
40 *
41 ***************************************************************************************************************************/
42
43#ifndef _SAGE_UDP_MODULE_H
44#define _SAGE_UDP_MODULE_H
45
46#include "streamProtocol.h"
47
48#define FLOW_WINDOW_NUM 5
49
50class sageBlockBuf;
51class sageCircBuf;
52class sageBlockGroup;
53class sageBlockFrame;
54
55class flowHistory {
56public:
57   double startTime;
58   double windowInterval;
59   
60   flowHistory() : startTime(0.0), windowInterval(0.0) {}
61};
62
63class streamFlowData {
64private:
65   flowHistory streamWindow[FLOW_WINDOW_NUM];
66   double nextWindowTime;
67   int totalSentSize;
68   int winIdx;
69   bool firstRound;
70   double startTime;
71   
72public:
73   double frameRate;
74   int nextFrameSize;
75   int frameSize;
76   int configID;
77   
78   int blockSize;
79   bool active;
80   bool closed;
81   
82   sageCircBuf *blockBuf;
83   sageBlockPool *returnPlace;
84   
85   streamFlowData(sageCircBuf *buf);
86   ~streamFlowData();
87
88   inline double elapsedTime(double time) { return time - startTime; }
89   inline double pastTime(double time)    { return time - nextWindowTime; }
90   void insertWindow(double sTime, int dataSize);
91};
92   
93class sageUdpModule : public streamProtocol{
94private:
95   int serverSockFd;
96         
97   std::vector<int> udpRcvList;
98   std::vector<int> udpSendList;
99   std::vector<streamFlowData*> flowList;
100
101   bool notStarted;
102   bool waitData;
103   bool closeFlag;
104
105   pthread_t thId;
106   static void* sendingThread(void *args);
107   int sendLoop();
108   bool setSockOpts(int fd, bool noDelay = false);
109   pthread_mutex_t connectionLock;
110   pthread_cond_t  streamStart;
111   pthread_cond_t  newData;
112   
113   int send(int id, sagePixelBlock *spb);
114   int recv(int id, sagePixelBlock *spb, int pidx);
115   int skipBlock(int id, int pidx);
116
117public:
118   sageUdpModule();
119   int init(sageStreamMode m, int p, sageNwConfig &c);
120   int checkConnections(char *msg = NULL, sageApiOption op = 0);
121   int connect(char* ip, char *msg = NULL);
122   int send(int id, sageBlock *sb, sageApiOption op);
123
124
125   /**
126    * sungwon experimental, swexp
127    */
128   int sendpixelonly(int id, sageBlockFrame *sb);
129
130   int recv(int id, sageBlock *sb, sageApiOption op);
131   int sendControl(int id, int frameID, int configID);
132   int sendGrp(int id, sagePixelBlock *sb, int configID);
133   int recvGrp(int id, sageBlockGroup *sbg);
134   int getRcvSockFd(int id) { return udpSendList[id]; }
135   int flush(int id, int configID);
136   void setupBlockPool(sageBlockPool *pool, int id = -1);
137   void setFrameSize(int id, int size);
138   void resetFrameSize(int id) { setFrameSize(id, 0); }
139   void setFrameRate(double rate, int id = -1);
140   
141   int close(int id, int mode = -1);
142   int close();
143   virtual ~sageUdpModule();
144};
145
146#endif
Note: See TracBrowser for help on using the repository browser.