2 Copyright 2004-2005 Chris Tallon
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "recording.h"
23 Recording* Recording::recInfoFor = NULL;
24 RecInfo* Recording::recInfo = NULL;
26 Recording::Recording()
28 logger = Log::getInstance();
29 vdr = VDR::getInstance();
38 Recording::~Recording()
40 if (progName) { delete[] progName; progName = 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("Recording", Log::DEBUG, "Recording destructor, marks list deleted");
54 if (markList) delete markList;
57 ULONG Recording::getStartTime() const
62 char* Recording::getProgName() const
67 char* Recording::getFileName() const
72 void Recording::setStartTime(ULONG tstartTime)
77 void Recording::setProgName(char* tProgName)
79 if (progName) delete[] progName;
81 progName = new char[strlen(tProgName) + 1];
82 if (progName) strcpy(progName, tProgName);
85 void Recording::setFileName(char* tFileName)
87 if (fileName) delete[] fileName;
89 fileName = new char[strlen(tFileName) + 1];
90 if (fileName) strcpy(fileName, tFileName);
93 void Recording::loadRecInfo()
95 if (recInfoFor == this) return; // it already is loaded
97 if (recInfo) delete recInfo;
99 recInfo = vdr->getRecInfo(fileName);
100 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
103 void Recording::dropRecInfo()
105 if (recInfo) delete recInfo;
110 void Recording::loadMarks()
112 markList = vdr->getMarks(fileName);
115 bool Recording::isRadio()
117 ULONG lengthFrames = 0;
118 ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames);
119 if (!lengthBytes || !lengthFrames) return false;
122 UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
123 if (!buffer) return false;
131 bool hasVideo = Demuxer::scanForVideo(buffer, thisRead);
136 vdr->stopStreaming();
137 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
140 if (!hasVideo) return true;
144 int Recording::getPrevMark(int currentFrame)
146 MarkList::reverse_iterator i;
147 Mark* loopMark = NULL;
149 if (!markList || !markList->size()) return 0;
151 for(i = markList->rbegin(); i != markList->rend(); i++)
154 logger->log("Recording", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
156 if (loopMark->pos < currentFrame)
158 logger->log("Recording", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
159 return loopMark->pos;
167 int Recording::getNextMark(int currentFrame)
169 MarkList::iterator i;
170 Mark* loopMark = NULL;
172 if (!markList || !markList->size()) return 0;
174 for(i = markList->begin(); i != markList->end(); i++)
177 logger->log("Recording", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
179 if (loopMark->pos > currentFrame)
181 logger->log("Recording", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
182 return loopMark->pos;
190 bool Recording::hasMarks()
192 return (markList && markList->size());
195 MarkList* Recording::getMarkList()