IncompleteIO.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: IncompleteIO.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_MEG4ITEC_INCOMPLETEIO_HPP 00045 #define _PS_MEG4ITEC_INCOMPLETEIO_HPP 00046 #include "IO.hpp" 00047 #include "global.hpp" 00048 00049 00050 class MPGStreamIO; 00051 class SimpleRtp; 00052 class Session; 00053 class ESInfo; 00054 class PacketizationLayer; 00055 class TerminalCapabilities; 00056 class GlobalTimer; 00057 class Statistics; 00058 class Frame; 00059 00060 #include "PointerRingBuffer.hpp" 00061 00073 class IncompleteIO: public IO 00074 { 00076 #define INCOMPLETEIO__MAX_FRAMES 64 00077 #define INCOMPLETEIO__MAX_FRAME_LOOK_AHEAD 10 00078 public: 00092 IncompleteIO(const char* localFile, const char *url, int remotePrt, 00093 const char *address, int localPrt, 00094 ESInfo * es, PacketizationLayer * packetization, bool writeOnly, 00095 GlobalTimer * globalTimer, Statistics *stats); 00096 virtual ~IncompleteIO(); 00101 Frame * getFrame(); 00103 int writeFrame(Frame * frm, ESInfo *out_es = NULL); 00107 bool open(); 00112 bool close(bool immediate=false); 00116 bool destroy(); 00117 State getState() const; 00119 State setState(State s); 00121 int getBufferFillLevel() const; 00127 int flushBuffer(long from_ts = 0, long to_ts = -1); 00129 const char *getURL() const; 00137 bool setToFrameNumber(u32 frameNumber); 00138 00139 long setToClosestIFrame(u32 frameNumber, bool backwards); 00140 00143 void setResendFrameHeader(bool set); 00144 void run(); 00145 00147 void setRtxInfo(const rtx_info* rtx); 00148 State play(double prefetchTime=0.0); 00149 State pause(); 00150 State mute(); 00151 void setESInfo(ESInfo * es); 00152 const ESInfo* const getESInfo() const; 00153 protected: 00154 void flushLocalCache(); 00156 Frame* findAndUnlinkFrame(u32 cts); 00157 void setFrame(Frame* frm); 00158 protected: 00159 MPGStreamIO* localInput; 00160 SimpleRtp* remoteInput; 00162 u32 vopTimeIncrement; 00163 /* maps cts to frames, a INCOMPLETEIO__SETS-associative frame cache with pseudo LRU, we delete the one with the oldest CTS*/ 00164 PointerRingBuffer<Frame*> frameCache; 00166 int cacheUsage; 00167 u32 lastCTS; 00168 ESInfo* es; 00169 }; 00170 00171 #endif 00172