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"
28 Recording* Recording::recInfoFor = NULL;
29 RecInfo* Recording::recInfo = NULL;
31 Recording::Recording()
33 logger = Log::getInstance();
34 vdr = VDR::getInstance();
43 Recording::~Recording()
45 if (progName) { delete[] progName; progName = NULL; }
46 if (fileName) { delete[] fileName; fileName = NULL; }
47 index = -1; // just in case
49 if (markList && markList->size())
51 for(UINT i = 0; i < markList->size(); i++)
53 delete (*markList)[i];
56 Log::getInstance()->log("Recording", Log::DEBUG, "Recording destructor, marks list deleted");
59 if (markList) delete markList;
62 ULONG Recording::getStartTime() const
67 char* Recording::getProgName() const
72 char* Recording::getFileName() const
77 void Recording::setStartTime(ULONG tstartTime)
82 void Recording::setProgName(char* tProgName)
84 if (progName) delete[] progName;
86 progName = new char[strlen(tProgName) + 1];
87 if (progName) strcpy(progName, tProgName);
90 void Recording::setFileName(char* tFileName)
92 if (fileName) delete[] fileName;
94 fileName = new char[strlen(tFileName) + 1];
95 if (fileName) strcpy(fileName, tFileName);
98 void Recording::loadRecInfo()
100 if (recInfoFor == this) return; // it already is loaded
102 if (recInfo) delete recInfo;
104 recInfo = vdr->getRecInfo(fileName);
105 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
108 void Recording::dropRecInfo()
110 if (recInfo) delete recInfo;
115 void Recording::loadMarks()
117 markList = vdr->getMarks(fileName);
120 bool Recording::isRadio()
122 ULONG lengthFrames = 0;
123 ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames);
124 if (!lengthBytes || !lengthFrames) return false;
127 UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
128 if (!buffer) return false;
136 bool hasVideo = Demuxer::scanForVideo(buffer, thisRead);
141 vdr->stopStreaming();
142 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
145 if (!hasVideo) return true;
149 int Recording::getPrevMark(int currentFrame)
151 MarkList::reverse_iterator i;
152 Mark* loopMark = NULL;
154 if (!markList || !markList->size()) return 0;
156 for(i = markList->rbegin(); i != markList->rend(); i++)
159 logger->log("Recording", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
161 if (loopMark->pos < currentFrame)
163 logger->log("Recording", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
164 return loopMark->pos;
172 int Recording::getNextMark(int currentFrame)
174 MarkList::iterator i;
175 Mark* loopMark = NULL;
177 if (!markList || !markList->size()) return 0;
179 for(i = markList->begin(); i != markList->end(); i++)
182 logger->log("Recording", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
184 if (loopMark->pos > currentFrame)
186 logger->log("Recording", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
187 return loopMark->pos;
195 bool Recording::hasMarks()
197 return (markList && markList->size());
200 MarkList* Recording::getMarkList()