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"
27 #include "demuxerts.h"
30 Recording* Recording::recInfoFor = NULL;
31 RecInfo* Recording::recInfo = NULL;
33 Recording::Recording()
35 logger = Log::getInstance();
36 vdr = VDR::getInstance();
46 Recording::~Recording()
48 if (progName) { delete[] progName; progName = NULL; }
49 if (fileName) { delete[] fileName; fileName = NULL; }
50 index = -1; // just in case
52 if (markList && markList->size())
54 for(UINT i = 0; i < markList->size(); i++)
56 delete (*markList)[i];
59 Log::getInstance()->log("Recording", Log::DEBUG, "Recording destructor, marks list deleted");
62 if (markList) delete markList;
65 ULONG Recording::getStartTime() const
70 char* Recording::getProgName() const
75 char* Recording::getFileName() const
80 void Recording::setNew(bool param)
85 void Recording::setStartTime(ULONG tstartTime)
90 void Recording::setProgName(char* tProgName)
92 if (progName) delete[] progName;
94 progName = new char[strlen(tProgName) + 1];
95 if (progName) strcpy(progName, tProgName);
98 void Recording::setFileName(char* tFileName)
100 if (fileName) delete[] fileName;
102 fileName = new char[strlen(tFileName) + 1];
103 if (fileName) strcpy(fileName, tFileName);
106 void Recording::loadRecInfo()
108 if (recInfoFor == this) return; // it already is loaded
110 if (recInfo) delete recInfo;
112 recInfo = vdr->getRecInfo(fileName);
113 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
115 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
118 void Recording::dropRecInfo()
120 if (recInfo) delete recInfo;
125 void Recording::loadMarks()
127 markList = vdr->getMarks(fileName);
128 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
131 bool Recording::isRadio(bool &h264)
133 ULONG lengthFrames = 0;
134 ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames, &IsPesRecording);
135 if (!lengthBytes || !lengthFrames) return false;
138 UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
139 if (!buffer) return false;
147 bool hasVideo = false;
150 hasVideo = Demuxer::scanForVideo(buffer, thisRead, ish264);
152 hasVideo = DemuxerTS::scanForVideo(buffer, thisRead,ish264);
158 vdr->stopStreaming();
159 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
161 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
164 if (!hasVideo) return true;
168 int Recording::getPrevMark(int currentFrame)
170 MarkList::reverse_iterator i;
171 Mark* loopMark = NULL;
173 if (!markList || !markList->size()) return 0;
175 for(i = markList->rbegin(); i != markList->rend(); i++)
178 logger->log("Recording", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
180 if (loopMark->pos < currentFrame)
182 logger->log("Recording", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
183 return loopMark->pos;
191 int Recording::getNextMark(int currentFrame)
193 MarkList::iterator i;
194 Mark* loopMark = NULL;
196 if (!markList || !markList->size()) return 0;
198 for(i = markList->begin(); i != markList->end(); i++)
201 logger->log("Recording", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
203 if (loopMark->pos > currentFrame)
205 logger->log("Recording", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
206 return loopMark->pos;
214 bool Recording::hasMarks()
216 return (markList && markList->size());
219 MarkList* Recording::getMarkList()