[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Module: sageAudioReceiver.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 SAGEAUDIORECEIVER_H_ |
---|
| 42 | #define SAGEAUDIORECEIVER_H_ |
---|
| 43 | |
---|
| 44 | #include "sageReceiver.h" |
---|
| 45 | #include "sageBlock.h" |
---|
| 46 | |
---|
| 47 | class sageAudioCircBuf; |
---|
| 48 | class sageEventQueue; |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * \brief instantiated by initStream message in sageAudioManager |
---|
| 52 | */ |
---|
| 53 | class sageAudioReceiver : public sageReceiver { |
---|
| 54 | protected: |
---|
| 55 | |
---|
| 56 | int bytesPerSample; |
---|
| 57 | sageAudioBlock audioNBlock; |
---|
| 58 | sageAudioCircBuf* buffer; /**< sageAudioCircBuf */ |
---|
| 59 | |
---|
| 60 | int syncFrame; /**< sync frame number */ |
---|
| 61 | |
---|
| 62 | sageEventQueue *eventQueue; |
---|
| 63 | sageSampleFmt sampleFmt; |
---|
| 64 | streamData *streamList; /**< list of streams */ |
---|
| 65 | int streamIdx; |
---|
| 66 | |
---|
| 67 | int oldFrame; |
---|
| 68 | int updateFrame; |
---|
| 69 | int reportRate; |
---|
| 70 | sageTimer perfTimer; |
---|
| 71 | unsigned long bandWidth; |
---|
| 72 | unsigned packetLoss; |
---|
| 73 | |
---|
| 74 | bool activeRecv; |
---|
| 75 | bool masterFlag; |
---|
| 76 | bool resetFlag; |
---|
| 77 | int m_senderID; |
---|
| 78 | |
---|
| 79 | public: |
---|
| 80 | /** |
---|
| 81 | * starts sageReceiver::nwReadThread()<BR> |
---|
| 82 | * sageReceiver::readData() is pure virtual, so it should be overriden here.<BR> |
---|
| 83 | * sageReceiver::nwReadThread() is just calling sageReceiver::readData(). |
---|
| 84 | */ |
---|
| 85 | virtual int addStream(int senderID); |
---|
| 86 | |
---|
| 87 | sageAudioReceiver(char *msg, sageEventQueue *queue, streamProtocol *obj, sageAudioCircBuf *buff); |
---|
| 88 | //virtual int readAudioData(int senderID); |
---|
| 89 | //virtual int readData(int senderID, sageBlockQueue *queue); |
---|
| 90 | |
---|
| 91 | /** |
---|
| 92 | * It defines function body of sageReceiver::readData() which is pure virtual |
---|
| 93 | */ |
---|
| 94 | virtual int readData(); |
---|
| 95 | virtual ~sageAudioReceiver() {} |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | * just sets sageAudioReceiver::syncFrame = frame |
---|
| 99 | */ |
---|
| 100 | virtual void processSync(int frame); |
---|
| 101 | |
---|
| 102 | public: |
---|
| 103 | int getInstID(); |
---|
| 104 | int getSenderID(); |
---|
| 105 | bool isActive(); |
---|
| 106 | int getAudioId(); |
---|
| 107 | void setMaster(bool flag); |
---|
| 108 | bool isMaster(void); |
---|
| 109 | |
---|
| 110 | void setResetFlag(void); |
---|
| 111 | int evalPerformance(char **frameStr, char **bandStr); |
---|
| 112 | inline void setReportRate(int rate) { reportRate = rate; } |
---|
| 113 | inline void resetTimer() { perfTimer.reset(); } |
---|
| 114 | inline void resetBandWidth() { bandWidth = 0; } |
---|
| 115 | inline void resetFrame() { oldFrame = updateFrame; } |
---|
| 116 | |
---|
| 117 | }; |
---|
| 118 | |
---|
| 119 | inline int sageAudioReceiver::getInstID() |
---|
| 120 | { |
---|
| 121 | return instID; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | inline int sageAudioReceiver::getSenderID() |
---|
| 125 | { |
---|
| 126 | return m_senderID; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | #endif |
---|