Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
ClientSession.hpp
00001 00002 00003 /*********************************************************************** 00004 * * 00005 * ViTooKi * 00006 * * 00007 * title: ClientSession.hpp * 00008 * * 00009 * * 00010 * * 00011 * ITEC institute of the University of Klagenfurt (Austria) * 00012 * http://www.itec.uni-klu.ac.at * 00013 * * 00014 * * 00015 * For more information visit the ViTooKi homepage: * 00016 * http://ViTooKi.sourceforge.net * 00017 * vitooki-user@lists.sourceforge.net * 00018 * vitooki-devel@lists.sourceforge.net * 00019 * * 00020 * This file is part of ViTooKi, a free video toolkit. * 00021 * ViTooKi is free software; you can redistribute it and/or * 00022 * modify it under the terms of the GNU General Public License * 00023 * as published by the Free Software Foundation; either version 2 * 00024 * of the License, or (at your option) any later version. * 00025 * * 00026 * This program is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00029 * GNU General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public License * 00032 * along with this program; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00034 * MA 02111-1307, USA. * 00035 * * 00036 ***********************************************************************/ 00037 00038 /*********************************************************************** 00039 * * 00040 * REVISION HISTORY: * 00041 * * 00042 * * 00043 * * 00044 ***********************************************************************/ 00045 00046 #ifndef _MPEG4ITEC_CLIENTSESSION 00047 #define _MPEG4ITEC_CLIENTSESSION 00048 00049 #ifdef ISOMP4 00050 #include "ISOMovies.h" 00051 #endif 00052 00053 #include "global.hpp" 00054 #include "Protocol.hpp" 00055 #include "ContainerInfo.hpp" 00056 #include "PortGenerator.hpp" 00057 #include "../metadata/TerminalCapabilities.hpp" 00058 #include "../metadata/UserPreferences.hpp" 00059 #include "../cache/CacheManager.hpp" 00060 00061 struct rtx_group; 00062 struct rtx_info; 00063 class DataChannel; 00064 class DataSink; 00065 class RTSP; 00066 00067 00079 class ClientSession: public VThread { 00080 public: 00081 enum ClientSessionState { SESSION_ERR, SESSION_CLOSED, SESSION_CONNECTED, SESSION_INITIALIZED, SESSION_PLAYING, SESSION_PAUSED }; 00082 00086 ClientSession(const char* uri, IO* videoOutput, IO* audioOutput, 00087 TerminalCapabilities* tc,bool enableRtx,bool visualize=false); 00088 00089 ClientSession(const char* uri, IO* vout, IO* aout, UserPreferences* up, 00090 bool enableRtx,bool visualize=false); 00091 00092 ClientSession(const char* videoUri, const char* proxyUri, IO* vout, IO* aout, 00093 UserPreferences* up, bool enableRtx,bool visualize=false); 00094 00097 ClientSession(int socket, const struct sockaddr_in *server, const char* uri, 00098 IO* vout, IO* aout, TerminalCapabilities* c, bool enableRtx,bool visualize=false); 00099 00100 void construct(const char* uri); 00101 00102 00103 ~ClientSession(); 00105 bool sendResponse(const char *str, int bytes); 00112 int readRequest(char* str, const int MAX_BYTES); 00113 bool connect(); 00114 bool play( bool with_caching=false); 00115 bool pause(u32 sessionKey); 00116 bool tearDown(u32 sessionKey); 00117 void run(); 00120 void setUrl(const char *&uri, bool makeExactMatch = true); 00121 //void setPort(int port); 00122 const ContainerInfo *getContainerInfo() const { 00123 return mp4Stream; 00124 }; 00125 const list < DataChannel * >&getDataChannels() const { 00126 return channels; 00127 }; 00130 DataChannel *getDataChannel(int esId); 00133 void setDataChannel(DataChannel * dc) { 00134 dprintf_full("\033[31mAdded DataChannel !\033[0m\n"); 00135 channels.push_front(dc); 00136 } 00137 00138 ClientSessionState getState() const { 00139 return state; 00140 }; 00141 const char *getUrl() const { 00142 return url; 00143 }; 00144 int getControlSocket() const { 00145 return sessionControlChannel; 00146 }; 00147 sockaddr_in *getDestInfo() { 00148 return server; 00149 }; 00151 void setOutput(IO * out); 00152 00154 bool setRtxInfoForES(u32 esId, rtx_info* rtx); 00156 rtx_group* getRtxGroup(u32 esId); 00157 00158 private: 00160 DataChannel * find(int esId); 00162 KnownProtocols determineProtocol(char *request); 00163 00164 protected: 00166 char *url; 00167 00171 int sessionControlChannel; 00175 list<DataChannel*> channels; 00177 ContainerInfo *mp4Stream; 00179 ClientSessionState state; 00182 RTSP *protocol; 00183 sockaddr_in *server; 00186 TerminalCapabilities* termCap; 00187 00188 UserPreferences* usrPref; 00189 00191 std::map<u32,DataSink*,struct intCompare> clientObj; 00192 00193 // FIXME: for each DC one output needed! 00194 IO* videoOut; 00195 IO* audioOut; 00197 list < rtx_group* > rtxInfo; 00198 bool rtxEnabled; 00199 bool decodeData; 00200 }; 00201 #endif 00202