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

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

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: sageAudioBridge.h
5 * Author : Hyejung Hur, 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_AUDIO_BRIDGE_H_
42#define _SAGE_AUDIO_BRIDGE_H_
43
44#include "streamProtocol.h"
45#include "sageBlock.h"
46
47class sageAudioBridge;
48class sageAudioDup;
49class sageTcpModule;
50class sageUdpModule;
51class messageInterface;
52class bridgeSharedData;
53
54typedef struct {
55   sageAudioBridge *This;
56   streamProtocol   *nwObj;
57} nwAudioCheckThreadParam;
58
59typedef struct {
60   sageAudioDup *This;
61   streamProtocol   *nwObj;
62} nwStreamThreadParam;
63
64typedef struct {
65        char* rcvIP;
66   int  rcvID;
67   int  nodeID;
68        int fsIdx;
69   bool active;
70   int sendPort;
71} streamBridgeParam;
72
73class sageAudioDup {
74private:
75   int sailNodeNum;
76        int streamType;
77        int blockSize;
78        int frameRate;
79        int syncType;
80        int keyframe;
81        int sampleFmt;
82        int samplingRate;
83        int channels;
84        int framePerBuffer;
85   
86   pthread_t thId;
87   
88protected:
89        std::vector<streamBridgeParam*> paramList;
90        int instID;
91        int senderID;
92        streamProtocol* instNWObj;
93
94   bool initialized;
95   bool bridgeEnd;
96
97        int rcvNodeNum;
98        sageAudioBlock audioNBlock;
99                       
100   static void* nwStreamThread(void *args);
101               
102public:
103   sageAudioDup(int appID);
104   ~sageAudioDup(void);
105
106        int init(void);
107        int addStream(char *msg, streamProtocol *nwObj);
108        int addReceiver(char *msg, int fsIdx);
109        void shutdownAllStreams(void);
110   void shutdownStreams(int fsIdx);   
111               
112   friend class sageAudioBridge;
113
114};
115
116class sageAudioBridge {
117private:
118   sageTcpModule *tcpObj;
119   sageUdpModule *udpObj;
120   sageNwConfig nwCfg;
121   
122   sageAudioDup *dupList[MAX_INST_NUM];
123   char audioIP[SAGE_IP_LEN];
124   int audioPort;
125   bool bridgeEnd;
126 
127   int initNetworks();
128   messageInterface *msgInf;
129   bridgeSharedData *shared;
130   
131   static void* nwCheckThread(void *args);
132   
133public:
134   // ip, port  : IP address and port number where listening audio stream connections
135   // inf  :  message communication object for sending messages to SAIL.
136   sageAudioBridge(char *ip, int port, messageInterface *inf, bridgeSharedData *sh);
137   
138   // send SAIL_CONNECT_TO_ARCV to SAIL
139   int startAudioStream(int instID, int sailClientID);
140
141   // accept streams from app
142   int initStreams(char *msg, streamProtocol *nwObj);   
143
144   // start audio stream from sageBridge to an endpoint (ARCV)
145   int duplicate(int instID, char *msg, int fsIdx);
146   
147   // delete a duplicator instance
148   int shutdownDup(int instID);
149   
150   // shutdown streams to an endpoint
151   int shutdownStreams(int instID, int fsIdx);
152   
153   ~sageAudioBridge();
154};
155
156#endif
Note: See TracBrowser for help on using the repository browser.