DataChannel.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: DataChannel.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef _PS_DATACHANNEL_HPP_ 00045 #define _PS_DATACHANNEL_HPP_ 00046 00047 #include "global.hpp" 00048 #include "VMutex.hpp" 00049 #include "ESInfo.hpp" 00050 #include "Statistics.hpp" 00051 00052 class IO; 00053 class DataSink; 00054 class Adaptor; 00055 class Frame; 00056 class Url; 00057 00074 class DataChannel:public VThread { 00075 public: 00077 DataChannel(IO * input, ESInfo * es); 00078 00085 DataChannel(IO * input, ESInfo * es, Adaptor * adapt); 00086 00087 ~DataChannel(); 00088 00089 00094 void setAdaptor(Adaptor * adapt); 00095 00098 void setESInfo(ESInfo *new_es); 00099 00103 void setFinalFrameNumber(long frameNumber); 00104 00109 void initiateThreadStop(bool forceTearDown); 00110 00111 /* changes the connected input IO 00112 * @param new_es: the new ESInfo, that fits the according IO *new_io 00113 */ 00114 void setInput(IO *new_io); 00115 00124 bool play(u32 clientId,double prefetch); 00125 00132 bool mute(u32 clientId); 00133 00136 bool unmute(u32 clientId); 00137 00144 bool pause(u32 clientId); 00145 00149 bool insert(DataSink* c); 00150 00158 char *enableCaching(bool omitHeader, const char* outDir, bool proxyMode=true, const Url* url=NULL); 00159 00163 void visualizeCaching(); 00164 00167 bool teardown(u32 clientId, bool immediate=false); 00168 00169 bool tearDownFlagSet() const { return tearDown; }; 00170 00172 int getNumberOfActiveDataSinks(); 00173 00174 IO* getInput() { return input;}; 00175 00176 Adaptor *getAdaptor() const { return adaptor; } 00177 00183 void run(); 00184 00185 void setSessionId(int i) { 00186 sessionId = i; 00187 }; 00188 00189 uint getSessionId() const { 00190 return sessionId; 00191 }; 00192 00193 const ESInfo *getESInfo() const { 00194 return es; 00195 }; 00196 00200 DataSink* getDataSink(u32 clientId); 00201 00202 const DataSink* getActiveDataSink(u32 clientId); 00203 00204 list <u32> getListOfActiveClientIds(); 00205 00206 list <u32> getListOfPausedClientIds(); 00207 00208 00212 void setOutputStatistics(Statistics *stats); 00213 00217 Statistics *getOutputStatistics(); 00218 00219 private: 00220 void init(IO * &input, ESInfo * &es, Adaptor * &adapt); 00221 void deleteInput(); 00222 void closeAllClients(bool immediateClose); 00223 00224 protected: 00225 int sessionId; 00226 00227 IO *input; 00228 00230 list < DataSink * >active; 00231 00233 list < DataSink * >paused; 00234 00236 DataSink *localViewer; 00237 00239 VMutex lockDataSink; 00240 00242 VMutex lockInput; 00243 00245 VMutex lockAdaptor; 00246 00247 00249 Adaptor *adaptor; 00250 00251 list < Frame * >sendQueue; 00252 00254 bool channelOpen; 00255 00256 bool tearDown; 00257 bool immediateClose; 00258 ESInfo *es; 00259 Statistics *outstats; 00260 00261 long currentFrameNumber; 00262 long finalFrameNumber; 00263 }; 00264 00265 00266 #endif