[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Module: sageBase.h |
---|
| 5 | * Author : Byungil Jeong |
---|
| 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_BASE_H |
---|
| 42 | #define _SAGE_BASE_H |
---|
| 43 | |
---|
| 44 | #include <iostream> |
---|
| 45 | #include <stdlib.h> |
---|
| 46 | #include <stdio.h> |
---|
| 47 | #include <math.h> |
---|
| 48 | #include <vector> |
---|
| 49 | #include <deque> |
---|
| 50 | #include <algorithm> |
---|
| 51 | #include <numeric> |
---|
| 52 | #include <pthread.h> |
---|
| 53 | #include <string.h> |
---|
| 54 | #include <time.h> |
---|
| 55 | #include <assert.h> |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | #if defined(WIN32) |
---|
| 59 | #include <io.h> |
---|
| 60 | #include <process.h> |
---|
| 61 | |
---|
| 62 | #define _WIN32_WINNT 0x0501 // Macro for getting the switchToThread() to work |
---|
| 63 | #if defined(N_PLAT_NLM) |
---|
| 64 | #include <ws2nlm.h> |
---|
| 65 | #else |
---|
| 66 | #include <winsock2.h> |
---|
| 67 | #endif |
---|
| 68 | #include <ws2tcpip.h> |
---|
| 69 | #define WIN32_LEAN_AND_MEAN |
---|
| 70 | #include <windows.h> |
---|
| 71 | #else |
---|
| 72 | #include <strings.h> |
---|
| 73 | #include <sys/time.h> |
---|
| 74 | #include <unistd.h> |
---|
| 75 | #include <sys/types.h> |
---|
| 76 | #include <sys/wait.h> |
---|
| 77 | #include <sys/socket.h> |
---|
| 78 | #include <netinet/in.h> |
---|
| 79 | #include <arpa/inet.h> |
---|
| 80 | #include <netinet/tcp.h> |
---|
| 81 | #include <sys/stat.h> |
---|
| 82 | #include <sys/uio.h> |
---|
| 83 | #include <sys/select.h> |
---|
| 84 | #endif |
---|
| 85 | |
---|
| 86 | #include <fcntl.h> |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | #define SAGE_IP_LEN 128 |
---|
| 90 | #define SAGE_MAX_DOMAIN 10 |
---|
| 91 | #define SAGE_CMD_LEN 1024 |
---|
| 92 | #define SAGE_NAME_LEN 256 |
---|
| 93 | #define MAX_TILES_PER_NODE 100 |
---|
| 94 | #define TRACKING_DATA_SIZE 256 |
---|
| 95 | #define SAGE_PERF_START 10 |
---|
| 96 | #define CMAN_MSG_SIZE 2048 |
---|
| 97 | #define DISPLAY_BUF_NUM 2 |
---|
| 98 | #define BRIDGE_BUF_NUM 5 |
---|
| 99 | #define MAX_ENDPOINT_NUM 100 |
---|
| 100 | #define MAX_INST_NUM 100 |
---|
| 101 | #define MAX_FRAME_RATE 120 |
---|
| 102 | #define DEFAULT_IMAGE_SIZE 3145728 |
---|
| 103 | |
---|
| 104 | #define MESSAGE_HEADER_SIZE 36 |
---|
| 105 | #define MESSAGE_FIELD_SIZE 9 |
---|
| 106 | |
---|
| 107 | #define TOP_TO_BOTTOM 0 |
---|
| 108 | #define BOTTOM_TO_TOP 1 |
---|
| 109 | |
---|
| 110 | typedef unsigned sageApiOption; |
---|
| 111 | #define SAGE_BLOCKING 1 |
---|
| 112 | #define SAGE_NON_BLOCKING 2 |
---|
| 113 | #define SAGE_BACKWARD 4 |
---|
| 114 | #define SAGE_CONTROL 8 |
---|
| 115 | |
---|
| 116 | #define SAGE_TIMEOUT 1 |
---|
| 117 | #define SAGE_INT_MAX 2147483647 |
---|
| 118 | |
---|
| 119 | enum nwProtocol {SAGE_TCP, SAGE_UDP, LAMBDA_STREAM}; |
---|
| 120 | enum sageStreamMode {SAGE_RCV, SAGE_ARCV, SAGE_SEND, SAGE_BRIDGE}; |
---|
| 121 | enum sagePixFmt {PIXFMT_NULL, PIXFMT_555, PIXFMT_555_INV, PIXFMT_565, PIXFMT_565_INV, |
---|
| 122 | PIXFMT_888, PIXFMT_888_INV, PIXFMT_8888, PIXFMT_8888_INV, PIXFMT_RLE, PIXFMT_LUV, |
---|
| 123 | PIXFMT_DXT, PIXFMT_YUV}; |
---|
| 124 | enum sageCompressType {NO_COMP, RLE_COMP, LUV_COMP, DXT_COMP}; |
---|
| 125 | |
---|
| 126 | enum sageSampleFmt {SAGE_SAMPLE_FLOAT32, SAGE_SAMPLE_INT16, SAGE_SAMPLE_INT8, SAGE_SAMPLE_UINT8}; |
---|
| 127 | enum sageAudioMode {SAGE_AUDIO_CAPTURE = 1, SAGE_AUDIO_PLAY = 2, SAGE_AUDIO_READ = 4, SAGE_AUDIO_WRITE = 8, SAGE_AUDIO_APP = 16, SAGE_AUDIO_FWCAPTURE = 32}; |
---|
| 128 | enum sageAudioSyncType {SAGE_SYNC_NONE, SAGE_SYNC_AUDIO_DRIVEN, SAGE_SYNC_GRAPHIC_DRIVEN}; |
---|
| 129 | |
---|
| 130 | class sageMessage { |
---|
| 131 | private: |
---|
| 132 | char *dest; |
---|
| 133 | char *code; |
---|
| 134 | char *appCode; |
---|
| 135 | char *size; |
---|
| 136 | |
---|
| 137 | void *data; |
---|
| 138 | char *buffer; |
---|
| 139 | int bufSize; |
---|
| 140 | int clientID; |
---|
| 141 | |
---|
| 142 | public: |
---|
| 143 | sageMessage(); |
---|
| 144 | ~sageMessage(); |
---|
| 145 | // init by message contents |
---|
| 146 | int init(int dst, int co, int app, int sz, const void *dat); |
---|
| 147 | // init by message buffer size |
---|
| 148 | //void init(); |
---|
| 149 | int init(int); |
---|
| 150 | int destroy(); |
---|
| 151 | int set(int dst, int co, int app, int sz, const void *dat); |
---|
| 152 | int getDest(); |
---|
| 153 | int getCode(); |
---|
| 154 | int getAppCode(); |
---|
| 155 | int getSize(); |
---|
| 156 | int getBufSize() { return bufSize; } |
---|
| 157 | void* getData(); |
---|
| 158 | char* getBuffer(); |
---|
| 159 | int getClientID() { return clientID; } |
---|
| 160 | |
---|
| 161 | int setDest(int); |
---|
| 162 | int setCode(int); |
---|
| 163 | int setAppCode(int); |
---|
| 164 | int setSize(int s); |
---|
| 165 | int setData(int, void*); |
---|
| 166 | void setClientID(int id) { clientID = id; } |
---|
| 167 | }; |
---|
| 168 | |
---|
| 169 | #include "misc.h" |
---|
| 170 | #include "sageRect.h" |
---|
| 171 | |
---|
| 172 | #endif |
---|