Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
Movie.cpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: Movie.cpp * 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 /*********************************************************************** 00045 * Video Session Migration System, 2004 * 00046 * Author: Klaus Schoeffmann * 00047 ************************************************************************/ 00048 00049 00050 #include "Movie.hpp" 00051 #include "SemiGlobals.hpp" 00052 00053 00054 /***********************************************************************/ 00055 Movie::Movie() 00056 {} 00057 00058 /***********************************************************************/ 00059 Movie::~Movie() 00060 {} 00061 00062 /***********************************************************************/ 00063 Movie::Movie(string name, string id, string description, 00064 string image, string url) 00065 { 00066 this->name = name; 00067 this->id = id; 00068 this->description = description; 00069 this->image = image; 00070 this->url = url; 00071 } 00072 00073 /***********************************************************************/ 00074 string Movie::getName() 00075 { 00076 return name; 00077 } 00078 00079 /***********************************************************************/ 00080 string Movie::getId() 00081 { 00082 return id; 00083 } 00084 00085 /***********************************************************************/ 00086 string Movie::getDescription() 00087 { 00088 return description; 00089 } 00090 00091 /***********************************************************************/ 00092 string Movie::getImage() 00093 { 00094 return image; 00095 } 00096 00097 /***********************************************************************/ 00098 string Movie::getUrl(uint userId, uint profileId) 00099 { 00100 if (userId == 0 && profileId == 0) 00101 { 00102 return getUrl(); 00103 } 00104 else 00105 { 00106 // ostringstream str; 00107 unsigned int hostStart = url.find("rtsp://") + 7; 00108 unsigned int hostEnd = url.find("/", hostStart); 00109 // str << url.substr(0, hostEnd); 00110 00111 ostringstream strU; 00112 strU << "/uid=" << userId; 00113 url.insert(hostEnd, strU.str()); hostEnd += strU.str().length(); 00114 ostringstream strP; 00115 strP << "/proid=" << profileId; 00116 url.insert(hostEnd, strP.str()); hostEnd += strP.str().length(); 00117 ostringstream strI; 00118 strI << "/id=" << id; 00119 url.insert(hostEnd, strI.str()); hostEnd += strI.str().length(); 00120 00121 return url; 00122 00123 // str << strU.str() << strP.str() << strI.str(); 00124 00125 // str << url.substr(hostStart); 00126 00127 /* 00128 //= 00129 ostringstream str; 00130 str << url << "?uid=" << userId << "&proid=" << profileId << "&id=" << id ; 00131 00132 return str.str(); 00133 */ 00134 } 00135 } 00136 00137 /***********************************************************************/ 00138 string Movie::getUrl() 00139 { 00140 return this->url; 00141 } 00142 00143 /***********************************************************************/ 00144 void Movie::setName(string n) 00145 { 00146 this->name = n; 00147 } 00148 00149 /***********************************************************************/ 00150 void Movie::setId(string id) 00151 { 00152 this->id = id; 00153 } 00154 00155 /***********************************************************************/ 00156 void Movie::setDescription(string desc) 00157 { 00158 description = desc; 00159 } 00160 00161 /***********************************************************************/ 00162 void Movie::setImage(string img) 00163 { 00164 image = img; 00165 } 00166 00167 /***********************************************************************/ 00168 void Movie::setUrl(string u) 00169 { 00170 url.assign(u); 00171 } 00172 00173 00174 /***********************************************************************/ 00175 string Movie::getHTMLRepresentation(char *imgPath, uint userId, uint profileId, uint linktype, 00176 uint qtewidth, uint qteheight, bool fakeRtspServer, char *sphost, char *spport) 00177 { 00178 ostringstream buf; 00179 00180 //output image (must have a fixed size of 94 x 140 pixel) 00181 buf << "<tr>" << endl 00182 << "<td valign=\"top\">" << endl 00183 << "<img width=\"94\" height=\"140\" src=\"" << imgPath << this->getImage() << "\">" 00184 << "</td>" << endl; 00185 00186 //output name of movie 00187 buf << "<td valign=\"top\">" 00188 << "<a class=\"moviehdr\" name=\"" << this->getId() << "\">" << this->getName() << "</a><br>" << endl; 00189 00190 //output description 00191 buf << "<font class=\"moviedesc\">" << this->getDescription() << "</font><br><br>" << endl; 00192 00193 00194 string url = this->getUrl(userId, profileId); 00195 unsigned int hostStart = url.find("rtsp://") + 7; 00196 unsigned int hostEnd = url.find("/", hostStart); 00197 unsigned int filePathStart = hostEnd; 00198 unsigned int portStart = url.find(":", hostStart) + 1; 00199 if (portStart != string::npos && portStart < hostEnd) hostEnd = portStart-1; 00200 if (fakeRtspServer) { 00201 if (portStart != string::npos) { 00202 unsigned int slashPos = filePathStart; 00203 string portNr = url.substr(portStart, slashPos-portStart); 00204 url.insert(filePathStart,"/port="); 00205 url.insert(filePathStart+strlen("/port="),portNr); 00206 url.erase(portStart, slashPos-portStart); 00207 url.insert(portStart, spport); 00208 } 00209 00210 //change host 00211 string hostAdr = url.substr(hostStart, hostEnd-hostStart); 00212 if (hostAdr.compare(sphost) != 0) { 00213 url.erase(hostStart, hostEnd-hostStart); 00214 url.insert(hostStart, sphost); 00215 filePathStart = url.find("/", hostStart); //may have changed 00216 url.insert(filePathStart, "/host="); 00217 url.insert(filePathStart+strlen("/host="), hostAdr); 00218 } 00219 } 00220 00221 00222 00223 //output link 00224 if (linktype == LINK_RTSP) 00225 { 00226 //***common RTSP*** 00227 buf << "<a href=\"" << url << "\">Start</a>"; 00228 } 00229 else if (linktype == LINK_SDP) 00230 { 00231 //***for SDP files*** 00232 ostringstream tmpName; 00233 //add user_id and profile_id (otherwise files from different users would be overwritten) 00234 tmpName << "movie_" << this->getId() << "_u" << userId << "_p" << profileId; 00235 buf << "<a href=\"" 00236 << semifunc::createSDPFile(tmpName.str(), 00237 url, 00238 Globals::getRelativeSDPFilePath(), 00239 Globals::getAbsoluteSDPFilePath()) 00240 << "\">Start</a>" << endl; 00241 } 00242 else if (linktype == LINK_QTE) 00243 { 00244 //***for QuickTime embedded*** 00245 buf << "<form name=\"frmStart" << this->getId() << "\"" 00246 << " action=\"embedded.cgi\" method=\"post\" target=\"frmStart" << this->getId() << "\">" << endl 00247 << "<input type=\"hidden\" name=\"uri\" value=\"" << url << "\">" << endl 00248 << "<input type=\"hidden\" name=\"width\" value=\"" << qtewidth << "\">" << endl 00249 << "<input type=\"hidden\" name=\"height\" value=\"" << qteheight << "\">" << endl 00250 << "</form>" << endl 00251 << "<a href=\"javascript:submitFormInWindow('frmStart" << this->getId() << "');\">Start</a>"; 00252 } 00253 00254 buf << "</td></tr>" << endl; 00255 00256 return buf.str(); 00257 }