2 Copyright 2019 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.
20 //portions from vdr by Klaus Schmiding HSMF code
29 static const char* TAG = "RecInfo";
52 summaryWithDetails = NULL;
57 LogNT::getInstance()->info(TAG, "Deleting recinfo: {}, {}", numComponents, summary);
59 if (summary) delete[] summary;
61 for (ULONG i = 0; i < numComponents; i++)
63 LogNT::getInstance()->info(TAG, "i: {}, languages[i]={:p}:{}", i, static_cast<void*>(languages[i]), languages[i]);
64 LogNT::getInstance()->info(TAG, "i: {}, descripti[i]={:p}:{}", i, static_cast<void*>(descriptions[i]), descriptions[i]);
65 if (languages[i]) delete[] (languages[i]);
66 if (descriptions[i]) delete[] (descriptions[i]);
72 delete[] descriptions;
78 if (title) delete [] title;
91 // TODO: Investigate why this is clearing instance vars
93 if (channelName) delete[] channelName;
100 if (summaryWithDetails) delete[] summaryWithDetails;
101 summaryWithDetails = NULL;
104 void RecInfo::setNumComponents(ULONG tnumComponents)
106 numComponents = tnumComponents;
107 languages = new char*[numComponents];
108 descriptions = new char*[numComponents];
109 streams = new UCHAR[numComponents];
110 types = new UCHAR[numComponents];
113 void RecInfo::addComponent(ULONG componentNum, UCHAR tstream, UCHAR ttype, char* tlanguage, char* tdescription)
115 if (componentNum >= numComponents) return;
116 streams[componentNum] = tstream;
117 types[componentNum] = ttype;
118 languages[componentNum] = tlanguage;
119 descriptions[componentNum] = tdescription;
122 void RecInfo::print()
124 LogNT* logger = LogNT::getInstance();
126 logger->info(TAG, "timerStart {}", timerStart);
127 logger->info(TAG, "timerEnd {}", timerEnd);
128 logger->info(TAG, "resumePoint {}", resumePoint);
129 logger->info(TAG, "Summary: {}", summary);
130 logger->info(TAG, "numComponents: {}", numComponents);
132 for (ULONG i = 0; i < numComponents; i++)
134 logger->info(TAG, "streams[{}]: {}", i, streams[i]);
135 logger->info(TAG, "types[{}]: {}", i, types[i]);
136 logger->info(TAG, "languages[{}]: {}", i, languages[i]);
137 logger->info(TAG, "descriptions[{}]: {}", i, descriptions[i]);
140 logger->info(TAG, "Title: {}", title);
141 logger->info(TAG, "Channel: {}", channelName);
142 logger->info(TAG, "Duration: {}", duration);
143 logger->info(TAG, "Filesize: {}", fileSize);
144 logger->info(TAG, "Priority: {}", priority);
145 logger->info(TAG, "Lifetime: {}", lifetime);
148 bool RecInfo::hasNoVideo()
150 // If no info (numComponents == 0) assume there is video
151 if (!numComponents) return false;
153 // video = 1, audio = 2
155 for (ULONG i = 0; i < numComponents; i++)
156 if (streams[i] == 1) return false;
161 char* RecInfo::buildSummaryWithDetails(bool forceRefresh)
163 if (!summaryWithDetails || forceRefresh)
165 if (forceRefresh && summaryWithDetails) delete[] summaryWithDetails;
167 LogNT* logger = LogNT::getInstance();
169 int swdLength = strlen(summary) +
170 strlen(tr("Channel: ")) + strlen(channelName) +
171 strlen(tr("Duration: ")) + 5 + /* 'hh:mm' */
172 strlen(tr("Resume at: ")) + 5 + /* 'hh:mm' */
173 strlen(tr("Size: ")) + 8 + /* '12345 MB' */
174 6 + /* line endings */
175 40 /* just in case (translation of New?) */ ;
177 int mins = duration / 60;
178 int hours = mins / 60;
182 char resumePointText[30];
183 if (resumePoint == 0)
185 strncpy(resumePointText, tr("New"), 30);
186 resumePointText[29] = '\0';
190 hmsf resumeHMSF = framesToHMSF(resumePoint);
191 SNPRINTF(resumePointText, 30, "%01u:%02u", resumeHMSF.hours, resumeHMSF.minutes);
194 summaryWithDetails = new char[swdLength];
195 SNPRINTF(summaryWithDetails, swdLength, "%s\n\n%s%s\n%s%01i:%02i\n%s%s\n%s%lu MB", summary,
196 tr("Channel: "), channelName,
197 tr("Duration: "), hours, mins,
198 tr("Resume at: "), resumePointText,
199 tr("Size: "), fileSize
202 logger->info(TAG, "Build summary with details C: {}, A: {}", swdLength, strlen(summaryWithDetails));
204 return summaryWithDetails;
207 hmsf RecInfo::framesToHMSF(ULONG frames)
212 ret.frames = int(modf((frames + 0.5) / fps, &Seconds) * fps + 1);
213 int s = int(Seconds);
214 ret.seconds = s % 60;
215 ret.minutes = s / 60 % 60;
216 ret.hours = s / 3600;