Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
AdmissionControl.hpp
00001 00002 /*********************************************************************** 00003 * * 00004 * ViTooKi * 00005 * * 00006 * title: AdmissionControl.hpp * 00007 * * 00008 * * 00009 * * 00010 * ITEC institute of the University of Klagenfurt (Austria) * 00011 * http://www.itec.uni-klu.ac.at * 00012 * * 00013 * * 00014 * For more information visit the ViTooKi homepage: * 00015 * http://ViTooKi.sourceforge.net * 00016 * vitooki-user@lists.sourceforge.net * 00017 * vitooki-devel@lists.sourceforge.net * 00018 * * 00019 * This file is part of ViTooKi, a free video toolkit. * 00020 * ViTooKi is free software; you can redistribute it and/or * 00021 * modify it under the terms of the GNU General Public License * 00022 * as published by the Free Software Foundation; either version 2 * 00023 * of the License, or (at your option) any later version. * 00024 * * 00025 * This program is distributed in the hope that it will be useful, * 00026 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00028 * GNU General Public License for more details. * 00029 * * 00030 * You should have received a copy of the GNU General Public License * 00031 * along with this program; if not, write to the Free Software * 00032 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00033 * MA 02111-1307, USA. * 00034 * * 00035 ***********************************************************************/ 00036 00037 /*********************************************************************** 00038 * * 00039 * REVISION HISTORY: * 00040 * * 00041 * * 00042 * * 00043 ***********************************************************************/ 00044 00045 #ifndef PS_VITOOKI_ADMISSIONCONTROL 00046 #define PS_VITOOKI_ADMISSIONCONTROL 00047 #include "cache/CostFunction.hpp" 00048 #include "global.hpp" 00049 #include "VMutex.hpp" 00050 00051 #define MAX_JOB_ENTRIES 1024 00052 00053 typedef struct Request{ 00054 UserPreferences up; 00055 Video sourceVideo; 00056 unsigned long startTime; 00057 unsigned long endTime; // calculated as video.duration+startTime 00058 Request(const UserPreferences& u, const Video& vid,unsigned long start,unsigned long end):up(u),sourceVideo(vid) 00059 { 00060 startTime=start; 00061 endTime=end; 00062 } 00063 ~Request() { 00064 }; 00065 } Request; 00066 00067 class AdmissionControl 00068 { 00069 protected: 00070 ResourceLimit* limit; 00071 ResourcePrices* prices; 00072 ResourceUsage currentUsage; 00073 VMutex lock; 00074 int activeRequests; 00075 00077 bool canAdmitRequest(const ResourceUsage* usage); 00078 public: 00079 AdmissionControl(const ResourceLimit* lim,const ResourcePrices* p); 00080 ~AdmissionControl(); 00081 00082 const ResourceLimit* getResourceLimit() const { 00083 return limit; 00084 } 00085 00086 00088 bool insertRequest(const ResourceUsage* usage); 00089 00091 bool freeRequest(const ResourceUsage* usage); 00092 00107 Adaptor* makeExactMatch(unsigned int dimX, unsigned int dimY, 00108 unsigned int bitRate, 00109 bool greyScale, float frameRate, 00110 ContainerInfo* stream,ResourceUsage* ru,bool allowHigherThanSrcBitRate=false); 00111 00121 Adaptor* makeBestMatch(const UserPreferences* up, 00122 int delayToServer, 00123 MetaObject* meta, 00124 /* out parameters */ 00125 ContainerInfo** outStream, ResourceUsage* ru); 00126 00127 }; 00128 00129 #endif 00130