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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "recording.h"
29 Recording* Recording::recInfoFor = NULL;
30 RecInfo* Recording::recInfo = NULL;
32 Recording::Recording()
34 logger = Log::getInstance();
35 vdr = VDR::getInstance();
44 Recording::~Recording()
46 if (progName) { delete[] progName; progName = NULL; }
47 if (fileName) { delete[] fileName; fileName = NULL; }
48 index = -1; // just in case
50 if (markList && markList->size())
52 for(UINT i = 0; i < markList->size(); i++)
54 delete (*markList)[i];
57 Log::getInstance()->log("Recording", Log::DEBUG, "Recording destructor, marks list deleted");
60 if (markList) delete markList;
63 ULONG Recording::getStartTime() const
68 char* Recording::getProgName() const
73 char* Recording::getFileName() const
78 void Recording::setStartTime(ULONG tstartTime)
83 void Recording::setProgName(char* tProgName)
85 if (progName) delete[] progName;
87 progName = new char[strlen(tProgName) + 1];
88 if (progName) strcpy(progName, tProgName);
91 void Recording::setFileName(char* tFileName)
93 if (fileName) delete[] fileName;
95 fileName = new char[strlen(tFileName) + 1];
96 if (fileName) strcpy(fileName, tFileName);
99 void Recording::loadRecInfo()
101 if (recInfoFor == this) return; // it already is loaded
103 if (recInfo) delete recInfo;
105 recInfo = vdr->getRecInfo(fileName);
106 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
108 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
111 void Recording::dropRecInfo()
113 if (recInfo) delete recInfo;
118 void Recording::loadMarks()
120 markList = vdr->getMarks(fileName);
121 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
124 bool Recording::isRadio()
126 ULONG lengthFrames = 0;
127 ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames);
128 if (!lengthBytes || !lengthFrames) return false;
131 UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
132 if (!buffer) return false;
140 bool hasVideo = Demuxer::scanForVideo(buffer, thisRead);
144 vdr->stopStreaming();
145 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
147 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
150 if (!hasVideo) return true;
154 int Recording::getPrevMark(int currentFrame)
156 MarkList::reverse_iterator i;
157 Mark* loopMark = NULL;
159 if (!markList || !markList->size()) return 0;
161 for(i = markList->rbegin(); i != markList->rend(); i++)
164 logger->log("Recording", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
166 if (loopMark->pos < currentFrame)
168 logger->log("Recording", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
169 return loopMark->pos;
177 int Recording::getNextMark(int currentFrame)
179 MarkList::iterator i;
180 Mark* loopMark = NULL;
182 if (!markList || !markList->size()) return 0;
184 for(i = markList->begin(); i != markList->end(); i++)
187 logger->log("Recording", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
189 if (loopMark->pos > currentFrame)
191 logger->log("Recording", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
192 return loopMark->pos;
200 bool Recording::hasMarks()
202 return (markList && markList->size());
205 MarkList* Recording::getMarkList()