2 Copyright 2004-2005 Chris Tallon, Andreas Vogel
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 Media* Media::recInfoFor = NULL;
35 mediaType=MEDIA_TYPE_UNKNOWN;
40 if (displayName) { delete[] displayName; displayName = NULL; }
41 if (fileName) { delete[] fileName; fileName = NULL; }
42 index = -1; // just in case
44 if (markList && markList->size())
46 for(UINT i = 0; i < markList->size(); i++)
48 delete (*markList)[i];
51 Log::getInstance()->log("Media", Log::DEBUG, "Media destructor, marks list deleted");
54 if (markList) delete markList;
57 ULONG Media::getTime() const
62 const char* Media::getDisplayName() const
64 if (displayName) return displayName;
68 const char* Media::getFileName() const
73 void Media::setTime(ULONG tstartTime)
78 void Media::setMediaType(int mtype)
83 int Media::getMediaType() const
88 void Media::setDisplayName(char* tDisplayName)
90 if (displayName) delete[] displayName;
92 displayName = new char[strlen(tDisplayName) + 1];
93 if (displayName) strcpy(displayName, tDisplayName);
96 void Media::setFileName(char* tFileName)
98 if (fileName) delete[] fileName;
100 fileName = new char[strlen(tFileName) + 1];
101 if (fileName) strcpy(fileName, tFileName);
104 char * Media::getTimeString(char * buffer) const {
105 if (! buffer) buffer=new char[TIMEBUFLEN];
107 time_t recStartTime = (time_t)getTime();
108 struct tm *btime = localtime(&recStartTime);
109 memcpy(<ime,btime, sizeof(struct tm));
111 if (btime && recStartTime != 0) {
113 strftime(buffer,TIMEBUFLEN, "%0g/%0m/%0d %0H:%0M ", btime);
115 strftime(buffer, TIMEBUFLEN, "%y/%m/%d %H:%M ", btime);
119 SNPRINTF(buffer,TIMEBUFLEN,"00/00/00 00:00 ");
124 void Media::loadMarks()
126 markList = VDR::getInstance()->getMarks(fileName);
131 int Media::getPrevMark(int currentFrame)
133 MarkList::reverse_iterator i;
134 Mark* loopMark = NULL;
136 if (!markList || !markList->size()) return 0;
138 for(i = markList->rbegin(); i != markList->rend(); i++)
141 Log::getInstance()->log("Media", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
143 if (loopMark->pos < currentFrame)
145 Log::getInstance()->log("Media", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
146 return loopMark->pos;
154 int Media::getNextMark(int currentFrame)
156 MarkList::iterator i;
157 Mark* loopMark = NULL;
159 if (!markList || !markList->size()) return 0;
161 for(i = markList->begin(); i != markList->end(); i++)
164 Log::getInstance()->log("Media", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
166 if (loopMark->pos > currentFrame)
168 Log::getInstance()->log("Media", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
169 return loopMark->pos;
177 bool Media::hasMarks()
179 return (markList && markList->size());
182 MarkList* Media::getMarkList()