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();
45 Recording::~Recording()
47 if (progName) { delete[] progName; progName = NULL; }
48 if (fileName) { delete[] fileName; fileName = NULL; }
49 index = -1; // just in case
51 if (markList && markList->size())
53 for(UINT i = 0; i < markList->size(); i++)
55 delete (*markList)[i];
58 Log::getInstance()->log("Recording", Log::DEBUG, "Recording destructor, marks list deleted");
61 if (markList) delete markList;
64 ULONG Recording::getStartTime() const
69 char* Recording::getProgName() const
74 char* Recording::getFileName() const
79 void Recording::setStartTime(ULONG tstartTime)
84 void Recording::setProgName(char* tProgName)
86 if (progName) delete[] progName;
88 progName = new char[strlen(tProgName) + 1];
89 if (progName) strcpy(progName, tProgName);
92 void Recording::setFileName(char* tFileName)
94 if (fileName) delete[] fileName;
96 fileName = new char[strlen(tFileName) + 1];
97 if (fileName) strcpy(fileName, tFileName);
100 void Recording::loadRecInfo()
102 if (recInfoFor == this) return; // it already is loaded
104 if (recInfo) delete recInfo;
106 recInfo = vdr->getRecInfo(fileName);
107 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
109 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
112 void Recording::dropRecInfo()
114 if (recInfo) delete recInfo;
119 void Recording::loadMarks()
121 markList = vdr->getMarks(fileName);
122 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
125 bool Recording::isRadio(bool &h264)
127 ULONG lengthFrames = 0;
128 ULLONG lengthBytes = vdr->streamRecording(getFileName(), &lengthFrames, &IsPesRecording);
129 if (!lengthBytes || !lengthFrames) return false;
132 UCHAR* buffer = vdr->getBlock(0ULL, 10000U, &thisRead);
133 if (!buffer) return false;
141 bool hasVideo = false;
144 hasVideo = Demuxer::scanForVideo(buffer, thisRead, ish264);
146 hasVideo = DemuxerTS::scanForVideo(buffer, thisRead,ish264);
152 vdr->stopStreaming();
153 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
155 Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
158 if (!hasVideo) return true;
162 int Recording::getPrevMark(int currentFrame)
164 MarkList::reverse_iterator i;
165 Mark* loopMark = NULL;
167 if (!markList || !markList->size()) return 0;
169 for(i = markList->rbegin(); i != markList->rend(); i++)
172 logger->log("Recording", Log::NOTICE, "findprev:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
174 if (loopMark->pos < currentFrame)
176 logger->log("Recording", Log::NOTICE, "findprev:setting pos %i to jumpframe_target",loopMark->pos);
177 return loopMark->pos;
185 int Recording::getNextMark(int currentFrame)
187 MarkList::iterator i;
188 Mark* loopMark = NULL;
190 if (!markList || !markList->size()) return 0;
192 for(i = markList->begin(); i != markList->end(); i++)
195 logger->log("Recording", Log::NOTICE, "findnext:comparing Frame %i with current Frame %i",loopMark->pos,currentFrame);
197 if (loopMark->pos > currentFrame)
199 logger->log("Recording", Log::NOTICE, "findnext:setting pos %i to jumpframe_target",loopMark->pos);
200 return loopMark->pos;
208 bool Recording::hasMarks()
210 return (markList && markList->size());
213 MarkList* Recording::getMarkList()