Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

RTSPCacheDir.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 00025 #ifndef RTSP_CACHE_DIR_H 00026 #define RTSP_CACHE_DIR_H 00027 00028 #include "mnstream.h" 00029 #include "MNdictionary.h" 00030 #include "MNString.h" 00031 #include "MNMutex.h" 00032 00033 class SDPSessionDescription; 00034 00035 struct SMPTE_t 00036 { 00037 int hours; 00038 int minutes; 00039 int seconds; 00040 int frames; 00041 }; 00042 00043 class CacheEntry 00044 { 00045 private: 00046 int _hits; 00047 int _misses; 00048 MNString _LocalFile; 00049 SDPSessionDescription* _sdp; 00050 int nb_Tokens; 00051 bool _is_completed; 00052 u_int64_t _fileSize; 00053 00054 CacheEntry( const CacheEntry& ); 00055 CacheEntry& operator= ( const CacheEntry& ); 00056 00057 00058 public: 00059 00060 CacheEntry(); 00061 CacheEntry( MNString& file, 00062 SDPSessionDescription* SDP, 00063 bool completed, 00064 u_int64_t file_size ); 00065 ~CacheEntry(); 00066 00067 SDPSessionDescription* getSDP() const; 00068 void getLocalFile( MNString& ); 00069 00070 void setSDP( SDPSessionDescription* SDP ); 00071 void setLocalFile( const MNString& LocalFile ); 00072 00075 void setFileSize( u_int64_t file_size ); 00076 const MNString& getLocalFile ( ); 00077 00078 void releaseToken( ); 00079 void getToken( ); 00080 void cacheHit( ); 00081 void cacheMiss( ); 00082 int get_nb_Tokens( ); 00083 u_int64_t getFileSize( ); 00084 void set_is_completed( bool is_completed ); 00085 bool get_is_completed( ); 00086 }; 00087 00088 class CacheDictionary : public MNdictionary<MNString, CacheEntry*> 00089 { 00090 public: 00091 virtual int compare( MNString const& x, MNString const& y) const; 00092 }; 00093 00094 00095 class RTSPCacheDir 00096 { 00097 00098 private: 00099 long _space; 00100 CacheDictionary _EntryList; 00101 MNMutex Mux; 00102 00103 /* Only for debugging -- MZ */ 00104 ofstream FileLogger; 00105 00106 RTSPCacheDir( const RTSPCacheDir& ); //forbidden 00107 RTSPCacheDir& operator= (const RTSPCacheDir&); //forbidden 00108 void remove_incomplete_files(); 00109 00110 00111 public: 00112 00113 RTSPCacheDir (); 00114 ~RTSPCacheDir (); 00115 00116 bool isCached( const MNString& URI ); 00117 00118 CacheEntry* getEntry( const MNString& URI ); 00119 00120 CacheEntry* getEntryWithToken( const MNString& URI ); 00121 00122 CacheEntry* getEntryByFile( const MNString& filename ); 00123 00124 bool releaseToken( const MNString& URI ); 00125 00126 bool addEntry( const MNString& URI, const MNString& lpmoc, CacheEntry* Entry, bool save = true ); 00127 00128 bool addEntry( const MNString& URI, 00129 const MNString& file, 00130 const MNString& lpmoc, 00131 SDPSessionDescription* SDP, 00132 bool save = true, long file_size = 0 ); 00133 00134 bool delEntry( const MNString& URI ); 00135 00136 bool setLocalFile( MNString file ); 00137 00138 bool setSDP( const SDPSessionDescription& SDP ); 00139 00140 bool setComplete( bool complete ); 00141 00157 bool checkSpace( int32_t bwidth, 00158 int32_t duration, 00159 int64_t& file_size ); 00160 00161 void setFileComplete( const char* filename, bool comp ); 00162 00163 void setSpaceBytes( u_int64_t space ); 00164 00165 bool removeFirstFile( ); 00166 00167 bool removeFirstUnusedFile( ); 00168 00169 u_int64_t getSpaceBytes( ) const; 00170 }; 00171 00172 #endif /* RTSP_CACHE_DIR_H */

Generated on Sun Mar 6 13:35:50 2005 for Komssys by doxygen 1.3.8