MythTV  master
v2serviceUtil.cpp
Go to the documentation of this file.
1 // Standard UNIX C headers
2 #include <unistd.h>
3 #include <fcntl.h>
4 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(_WIN32)
5 #include <sys/types.h>
6 #else
7 #include <sys/sysmacros.h>
8 #endif
9 #include <sys/stat.h>
10 
11 // Qt
12 #include <QDir>
13 #include <QFileInfoList>
14 #include <QJsonArray>
15 #include <QJsonObject>
16 
17 // MythTV
18 #include "libmythbase/compat.h"
24 #include "libmythtv/cardutil.h"
25 #include "libmythtv/channelgroup.h"
26 #include "libmythtv/channelinfo.h"
27 #include "libmythtv/channelutil.h"
30 #include "libmythtv/tv_rec.h"
31 
32 // MythBackend
33 #include "backendcontext.h"
34 #include "encoderlink.h"
35 #include "scheduler.h"
36 #include "v2encoder.h"
37 #include "v2frontend.h"
38 #include "v2serviceUtil.h"
39 
40 void V2FillProgramInfo( V2Program *pProgram,
41  ProgramInfo *pInfo,
42  bool bIncChannel /* = true */,
43  bool bDetails /* = true */,
44  bool bIncCast /* = true */,
45  bool bIncArtwork /* = true */,
46  bool bIncRecording /* = true */)
47 {
48  if ((pProgram == nullptr) || (pInfo == nullptr))
49  return;
50 
51  pProgram->setStartTime ( pInfo->GetScheduledStartTime());
52  pProgram->setEndTime ( pInfo->GetScheduledEndTime ());
53  pProgram->setTitle ( pInfo->GetTitle() );
54  pProgram->setSubTitle ( pInfo->GetSubtitle() );
55  pProgram->setCategory ( pInfo->GetCategory() );
56  pProgram->setCatType ( pInfo->GetCategoryTypeString());
57  pProgram->setRepeat ( pInfo->IsRepeat() );
58  pProgram->setVideoProps( pInfo->GetVideoProperties() );
59  pProgram->setVideoPropNames( pInfo->GetVideoPropertyNames() );
60  pProgram->setAudioProps( pInfo->GetAudioProperties() );
61  pProgram->setAudioPropNames( pInfo->GetAudioPropertyNames() );
62  pProgram->setSubProps ( pInfo->GetSubtitleType() );
63  pProgram->setSubPropNames( pInfo->GetSubtitleTypeNames() );
64 
65  if (bDetails)
66  {
67  pProgram->setSeriesId ( pInfo->GetSeriesID() );
68  pProgram->setProgramId ( pInfo->GetProgramID() );
69  pProgram->setStars ( pInfo->GetStars() );
70  pProgram->setLastModified( pInfo->GetLastModifiedTime() );
71  pProgram->setProgramFlags( pInfo->GetProgramFlags() );
72  pProgram->setProgramFlagNames( pInfo->GetProgramFlagNames() );
73 
74  // ----
75  // DEPRECATED - See RecordingInfo instead
76  pProgram->setFileName ( pInfo->GetPathname() );
77  pProgram->setFileSize ( pInfo->GetFilesize() );
78  pProgram->setHostName ( pInfo->GetHostname() );
79  // ----
80 
81  if (pInfo->GetOriginalAirDate().isValid())
82  pProgram->setAirdate( pInfo->GetOriginalAirDate() );
83  else if (pInfo->GetYearOfInitialRelease() > 0)
84  {
85  QDate year;
86  year.setDate(pInfo->GetYearOfInitialRelease(), 1, 1);
87  pProgram->setAirdate( year );
88  }
89 
90  pProgram->setDescription( pInfo->GetDescription() );
91  pProgram->setInetref ( pInfo->GetInetRef() );
92  pProgram->setSeason ( pInfo->GetSeason() );
93  pProgram->setEpisode ( pInfo->GetEpisode() );
94  pProgram->setTotalEpisodes( pInfo->GetEpisodeTotal() );
95  }
96 
97  if (bIncCast)
98  V2FillCastMemberList( pProgram->Cast(), pInfo );
99  else
100  pProgram->enableCast(false);
101 
102  if (bIncChannel)
103  {
104  // Build Channel Child Element
105  if (!V2FillChannelInfo( pProgram->Channel(), pInfo->GetChanID(), bDetails ))
106  {
107  // The channel associated with a given recording may no longer exist
108  // however the ChanID is one half of the unique identifier for the
109  // recording and therefore MUST be included in the return data
110  pProgram->Channel()->setChanId(pInfo->GetChanID());
111  }
112  }
113  else
114  pProgram->enableChannel(false);
115 
116  // Build Recording Child Element
117 
118  if ( bIncRecording && pInfo->GetRecordingStatus() != RecStatus::Unknown )
119  {
120  V2RecordingInfo *pRecording = pProgram->Recording();
121 
122  const RecordingInfo pRecInfo(*pInfo);
123 
124  pRecording->setRecordedId ( pRecInfo.GetRecordingID() );
125  pRecording->setStatus ( pRecInfo.GetRecordingStatus() );
126  pRecording->setStatusName ( pRecInfo.GetRecordingStatus() );
127  pRecording->setPriority( pRecInfo.GetRecordingPriority() );
128  pRecording->setStartTs ( pRecInfo.GetRecordingStartTime() );
129  pRecording->setEndTs ( pRecInfo.GetRecordingEndTime() );
130 
131  if (bDetails)
132  {
133  pRecording->setFileName ( pRecInfo.GetPathname() );
134  pRecording->setFileSize ( pRecInfo.GetFilesize() );
135  pRecording->setHostName ( pRecInfo.GetHostname() );
136  pRecording->setLastModified( pRecInfo.GetLastModifiedTime() );
137 
138  pRecording->setRecordId ( pRecInfo.GetRecordingRuleID() );
139  pRecording->setRecGroup ( pRecInfo.GetRecordingGroup() );
140  pRecording->setPlayGroup ( pRecInfo.GetPlaybackGroup() );
141  pRecording->setStorageGroup( pRecInfo.GetStorageGroup() );
142  pRecording->setRecType ( pRecInfo.GetRecordingRuleType() );
143  pRecording->setDupInType ( pRecInfo.GetDuplicateCheckSource() );
144  pRecording->setDupMethod ( pRecInfo.GetDuplicateCheckMethod() );
145  pRecording->setEncoderId ( pRecInfo.GetInputID() );
146  pRecording->setEncoderName ( pRecInfo.GetInputName() );
147  pRecording->setProfile ( pRecInfo.GetProgramRecordingProfile() );
148  }
149  }
150  else
151  pProgram->enableRecording(false);
152 
153  if ( bIncArtwork && !pInfo->GetInetRef().isEmpty() )
154  V2FillArtworkInfoList( pProgram->Artwork(), pInfo->GetInetRef(), pInfo->GetSeason());
155  else
156  pProgram->enableArtwork(false);
157 }
158 
160 //
162 
164  uint nChanID,
165  bool bDetails /* = true */ )
166 {
167  ChannelInfo channel;
168  if (channel.Load(nChanID))
169  {
170  return V2FillChannelInfo(pChannel, channel, bDetails);
171  }
172 
173  return false;
174 }
175 
177 //
179 
181  const ChannelInfo &channelInfo,
182  bool bDetails /* = true */ )
183 {
184 
185  // TODO update V2ChannelInfo to match functionality of ChannelInfo,
186  // ultimately replacing it's progenitor?
187  pChannel->setChanId(channelInfo.m_chanId);
188  pChannel->setChanNum(channelInfo.m_chanNum);
189  pChannel->setCallSign(channelInfo.m_callSign);
190  if (!channelInfo.m_icon.isEmpty())
191  {
192  QString sIconURL = QString( "/Guide/GetChannelIcon?FileName=%1")
193  .arg( channelInfo.m_icon );
194  pChannel->setIconURL( sIconURL );
195  pChannel->setIcon( channelInfo.m_icon );
196  }
197  pChannel->setChannelName(channelInfo.m_name);
198  pChannel->setVisible(channelInfo.m_visible > kChannelNotVisible);
199  pChannel->setExtendedVisible(toRawString(channelInfo.m_visible));
200 
201  if (bDetails)
202  {
203  pChannel->setMplexId(channelInfo.m_mplexId);
204  pChannel->setServiceId(channelInfo.m_serviceId);
205  pChannel->setATSCMajorChan(channelInfo.m_atscMajorChan);
206  pChannel->setATSCMinorChan(channelInfo.m_atscMinorChan);
207  pChannel->setFormat(channelInfo.m_tvFormat);
208  pChannel->setFineTune(channelInfo.m_fineTune);
209  pChannel->setFrequencyId(channelInfo.m_freqId);
210  pChannel->setChanFilters(channelInfo.m_videoFilters);
211  pChannel->setSourceId(channelInfo.m_sourceId);
212  pChannel->setCommFree(channelInfo.m_commMethod == -2);
213  pChannel->setUseEIT(channelInfo.m_useOnAirGuide);
214  pChannel->setXMLTVID(channelInfo.m_xmltvId);
215  pChannel->setDefaultAuth(channelInfo.m_defaultAuthority);
216  pChannel->setServiceType(channelInfo.m_serviceType);
217  pChannel->setRecPriority(channelInfo.m_recPriority);
218  pChannel->setTimeOffset(channelInfo.m_tmOffset);
219  pChannel->setCommMethod(channelInfo.m_commMethod);
220 
221  QList<uint> groupIds = channelInfo.GetGroupIds();
222  QString sGroupIds;
223  for (int x = 0; x < groupIds.size(); x++)
224  {
225  if (x > 0)
226  sGroupIds += ",";
227 
228  sGroupIds += QString::number(groupIds.at(x));
229  }
230  pChannel->setChannelGroups(sGroupIds);
231 
232  QList<uint> inputIds = channelInfo.GetInputIds();
233  QString sInputIds;
234  for (int x = 0; x < inputIds.size(); x++)
235  {
236  if (x > 0)
237  sInputIds += ",";
238 
239  sInputIds += QString::number(inputIds.at(x));
240  }
241  pChannel->setInputs(sInputIds);
242  }
243 
244  return true;
245 }
246 
247 void V2FillChannelGroup(V2ChannelGroup* pGroup, const ChannelGroupItem& pGroupItem)
248 {
249  if (!pGroup)
250  return;
251 
252  pGroup->setGroupId(pGroupItem.m_grpId);
253  pGroup->setName(pGroupItem.m_name);
254  pGroup->setPassword(""); // Not currently supported
255 }
256 
258 //
260 
261 void V2FillRecRuleInfo( V2RecRule *pRecRule,
262  RecordingRule *pRule )
263 {
264  if ((pRecRule == nullptr) || (pRule == nullptr))
265  return;
266 
267  pRecRule->setId ( pRule->m_recordID );
268  pRecRule->setParentId ( pRule->m_parentRecID );
269  pRecRule->setInactive ( pRule->m_isInactive );
270  pRecRule->setTitle ( pRule->m_title );
271  pRecRule->setSubTitle ( pRule->m_subtitle );
272  pRecRule->setDescription ( pRule->m_description );
273  pRecRule->setSeason ( pRule->m_season );
274  pRecRule->setEpisode ( pRule->m_episode );
275  pRecRule->setCategory ( pRule->m_category );
276  pRecRule->setStartTime ( QDateTime(pRule->m_startdate,
277  pRule->m_starttime, Qt::UTC));
278  pRecRule->setEndTime ( QDateTime(pRule->m_enddate,
279  pRule->m_endtime, Qt::UTC));
280  pRecRule->setSeriesId ( pRule->m_seriesid );
281  pRecRule->setProgramId ( pRule->m_programid );
282  pRecRule->setInetref ( pRule->m_inetref );
283  pRecRule->setChanId ( pRule->m_channelid );
284  pRecRule->setCallSign ( pRule->m_station );
285  pRecRule->setFindDay ( pRule->m_findday );
286  pRecRule->setFindTime ( pRule->m_findtime );
287  pRecRule->setType ( toRawString(pRule->m_type) );
288  pRecRule->setSearchType ( toRawString(pRule->m_searchType));
289  pRecRule->setRecPriority ( pRule->m_recPriority );
290  pRecRule->setPreferredInput ( pRule->m_prefInput );
291  pRecRule->setStartOffset ( pRule->m_startOffset );
292  pRecRule->setEndOffset ( pRule->m_endOffset );
293  pRecRule->setDupMethod ( toRawString(pRule->m_dupMethod) );
294  pRecRule->setDupIn ( toRawString(pRule->m_dupIn) );
295  pRecRule->setNewEpisOnly ( newEpifromDupIn(pRule->m_dupIn) );
296  pRecRule->setFilter ( pRule->m_filter );
297  pRecRule->setRecProfile ( pRule->m_recProfile );
298  pRecRule->setRecGroup ( RecordingInfo::GetRecgroupString(pRule->m_recGroupID) );
299  pRecRule->setStorageGroup ( pRule->m_storageGroup );
300  pRecRule->setPlayGroup ( pRule->m_playGroup );
301  pRecRule->setAutoExpire ( pRule->m_autoExpire );
302  pRecRule->setMaxEpisodes ( pRule->m_maxEpisodes );
303  pRecRule->setMaxNewest ( pRule->m_maxNewest );
304  pRecRule->setAutoCommflag ( pRule->m_autoCommFlag );
305  pRecRule->setAutoTranscode ( pRule->m_autoTranscode );
306  pRecRule->setAutoMetaLookup ( pRule->m_autoMetadataLookup );
307  pRecRule->setAutoUserJob1 ( pRule->m_autoUserJob1 );
308  pRecRule->setAutoUserJob2 ( pRule->m_autoUserJob2 );
309  pRecRule->setAutoUserJob3 ( pRule->m_autoUserJob3 );
310  pRecRule->setAutoUserJob4 ( pRule->m_autoUserJob4 );
311  pRecRule->setTranscoder ( pRule->m_transcoder );
312  pRecRule->setNextRecording ( pRule->m_nextRecording );
313  pRecRule->setLastRecorded ( pRule->m_lastRecorded );
314  pRecRule->setLastDeleted ( pRule->m_lastDeleted );
315  pRecRule->setAverageDelay ( pRule->m_averageDelay );
316  pRecRule->setAutoExtend ( toString(pRule->m_autoExtend) );
317 }
318 
319 void V2FillArtworkInfoList( V2ArtworkInfoList *pArtworkInfoList,
320  const QString &sInetref,
321  uint nSeason )
322 {
323  ArtworkMap map = GetArtwork(sInetref, nSeason);
324  for (auto i = map.cbegin(); i != map.cend(); ++i)
325  {
326  V2ArtworkInfo *pArtInfo = pArtworkInfoList->AddNewArtworkInfo();
327  pArtInfo->setFileName(i.value().url);
328  switch (i.key())
329  {
330  case kArtworkFanart:
331  pArtInfo->setStorageGroup("Fanart");
332  pArtInfo->setType("fanart");
333  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
334  "&FileName=%2")
335  .arg("Fanart",
336  QString(QUrl::toPercentEncoding(
337  QUrl(i.value().url).path()))));
338  break;
339  case kArtworkBanner:
340  pArtInfo->setStorageGroup("Banners");
341  pArtInfo->setType("banner");
342  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
343  "&FileName=%2")
344  .arg("Banners",
345  QString(QUrl::toPercentEncoding(
346  QUrl(i.value().url).path()))));
347  break;
348  case kArtworkCoverart:
349  default:
350  pArtInfo->setStorageGroup("Coverart");
351  pArtInfo->setType("coverart");
352  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
353  "&FileName=%2")
354  .arg("Coverart",
355  QString(QUrl::toPercentEncoding(
356  QUrl(i.value().url).path()))));
357  break;
358  }
359  }
360 }
361 
362 void V2FillGenreList(V2GenreList* pGenreList, int videoID)
363 {
364  if (!pGenreList)
365  return;
366 
367  MSqlQuery query(MSqlQuery::InitCon());
368  query.prepare("SELECT genre from videogenre "
369  "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
370  "WHERE idvideo = :ID "
371  "ORDER BY genre;");
372  query.bindValue(":ID", videoID);
373 
374  if (query.exec() && query.size() > 0)
375  {
376  while (query.next())
377  {
378  V2Genre *pGenre = pGenreList->AddNewGenre();
379  QString genre = query.value(0).toString();
380  pGenre->setName(genre);
381  }
382  }
383 }
384 
385 
387  V2VideoMetadataInfo *pVideoMetadataInfo,
389  bool bDetails)
390 {
391  pVideoMetadataInfo->setId(pMetadata->GetID());
392  pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
393  pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
394  pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
395  pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
396  pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
397  pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
398  pVideoMetadataInfo->setCertification(pMetadata->GetRating());
399  pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
400  pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
401  pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
402  pVideoMetadataInfo->setReleaseDate(
403  QDateTime(pMetadata->GetReleaseDate(),
404  QTime(0,0),Qt::LocalTime).toUTC());
405  pVideoMetadataInfo->setAddDate(
406  QDateTime(pMetadata->GetInsertdate(),
407  QTime(0,0),Qt::LocalTime).toUTC());
408  pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
409  pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
410  pVideoMetadataInfo->setLength(pMetadata->GetLength().count());
411  pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
412  pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
413  pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
414  pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
415  pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
416  pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
417  pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
418  pVideoMetadataInfo->setContentType(ContentTypeToString(
419  pMetadata->GetContentType()));
420  pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
421  pVideoMetadataInfo->setHash(pMetadata->GetHash());
422  pVideoMetadataInfo->setHostName(pMetadata->GetHost());
423  pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
424  pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
425  pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
426  pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
427  pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
428 
429  if (bDetails)
430  {
431  if (!pMetadata->GetFanart().isEmpty())
432  {
433  V2ArtworkInfo *pArtInfo =
434  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
435  pArtInfo->setStorageGroup("Fanart");
436  pArtInfo->setType("fanart");
437  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
438  "&FileName=%2")
439  .arg("Fanart",
440  QString(
441  QUrl::toPercentEncoding(pMetadata->GetFanart()))));
442  }
443  if (!pMetadata->GetCoverFile().isEmpty())
444  {
445  V2ArtworkInfo *pArtInfo =
446  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
447  pArtInfo->setStorageGroup("Coverart");
448  pArtInfo->setType("coverart");
449  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
450  "&FileName=%2")
451  .arg("Coverart",
452  QString(
453  QUrl::toPercentEncoding(pMetadata->GetCoverFile()))));
454  }
455  if (!pMetadata->GetBanner().isEmpty())
456  {
457  V2ArtworkInfo *pArtInfo =
458  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
459  pArtInfo->setStorageGroup("Banners");
460  pArtInfo->setType("banner");
461  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
462  "&FileName=%2")
463  .arg("Banners",
464  QString(
465  QUrl::toPercentEncoding(pMetadata->GetBanner()))));
466  }
467  if (!pMetadata->GetScreenshot().isEmpty())
468  {
469  V2ArtworkInfo *pArtInfo =
470  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
471  pArtInfo->setStorageGroup("Screenshots");
472  pArtInfo->setType("screenshot");
473  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
474  "&FileName=%2")
475  .arg("Screenshots",
476  QString(
477  QUrl::toPercentEncoding(pMetadata->GetScreenshot()))));
478  }
479  }
480 
481  V2FillGenreList(pVideoMetadataInfo->Genres(), pVideoMetadataInfo->GetId());
482 }
483 
485 //
487 
489  MusicMetadata *pMetadata, bool bDetails)
490 {
491  pVideoMetadataInfo->setId(pMetadata->ID());
492  pVideoMetadataInfo->setArtist(pMetadata->Artist());
493  pVideoMetadataInfo->setCompilationArtist(pMetadata->CompilationArtist());
494  pVideoMetadataInfo->setAlbum(pMetadata->Album());
495  pVideoMetadataInfo->setTitle(pMetadata->Title());
496  pVideoMetadataInfo->setTrackNo(pMetadata->Track());
497  pVideoMetadataInfo->setGenre(pMetadata->Genre());
498  pVideoMetadataInfo->setYear(pMetadata->Year());
499  pVideoMetadataInfo->setPlayCount(pMetadata->PlayCount());
500  pVideoMetadataInfo->setLength(pMetadata->Length().count());
501  pVideoMetadataInfo->setRating(pMetadata->Rating());
502  pVideoMetadataInfo->setFileName(pMetadata->Filename());
503  pVideoMetadataInfo->setHostName(pMetadata->Hostname());
504  pVideoMetadataInfo->setLastPlayed(pMetadata->LastPlay());
505  pVideoMetadataInfo->setCompilation(pMetadata->Compilation());
506 
507  if (bDetails)
508  {
509  //TODO add coverart here
510  }
511 }
512 
513 void V2FillInputInfo(V2Input* input, const InputInfo& inputInfo)
514 {
515  input->setId(inputInfo.m_inputId);
516  input->setInputName(inputInfo.m_name);
517  input->setCardId(inputInfo.m_inputId);
518  input->setSourceId(inputInfo.m_sourceId);
519  input->setDisplayName(inputInfo.m_displayName);
520  input->setLiveTVOrder(inputInfo.m_liveTvOrder);
521  input->setScheduleOrder(inputInfo.m_scheduleOrder);
522  input->setRecPriority(inputInfo.m_recPriority);
523  input->setQuickTune(inputInfo.m_quickTune);
524 }
525 
526 
527 
529  ProgramInfo* pInfo)
530 {
531  if (!pCastMemberList || !pInfo)
532  return;
533 
534  MSqlQuery query(MSqlQuery::InitCon());
535 
536  QString table;
537  if (pInfo->GetFilesize() > 0) // FIXME: This shouldn't be the way to determine what is or isn't a recording!
538  table = "recordedcredits";
539  else
540  table = "credits";
541 
542  query.prepare(QString("SELECT role, people.name, roles.name FROM %1"
543  " AS credits"
544  " LEFT JOIN people ON"
545  " credits.person = people.person"
546  " LEFT JOIN roles ON"
547  " credits.roleid = roles.roleid"
548  " WHERE credits.chanid = :CHANID"
549  " AND credits.starttime = :STARTTIME"
550  " ORDER BY role, priority;").arg(table));
551 
552  query.bindValue(":CHANID", pInfo->GetChanID());
553  query.bindValue(":STARTTIME", pInfo->GetScheduledStartTime());
554 
555  if (query.exec() && query.size() > 0)
556  {
557  QMap<QString, QString> translations;
558  translations["ACTOR"] = QObject::tr("Actors");
559  translations["DIRECTOR"] = QObject::tr("Director");
560  translations["PRODUCER"] = QObject::tr("Producer");
561  translations["EXECUTIVE_PRODUCER"] = QObject::tr("Executive Producer");
562  translations["WRITER"] = QObject::tr("Writer");
563  translations["GUEST_STAR"] = QObject::tr("Guest Star");
564  translations["HOST"] = QObject::tr("Host");
565  translations["ADAPTER"] = QObject::tr("Adapter");
566  translations["PRESENTER"] = QObject::tr("Presenter");
567  translations["COMMENTATOR"] = QObject::tr("Commentator");
568  translations["GUEST"] = QObject::tr("Guest");
569 
570  while (query.next())
571  {
572  V2CastMember *pCastMember = pCastMemberList->AddNewCastMember();
573 
574  QString role = query.value(0).toString();
575  pCastMember->setTranslatedRole(translations.value(role.toUpper()));
576  pCastMember->setRole(role); // role is invalid after this call.
577  /* The people.name column uses utf8_bin collation.
578  * Qt-MySQL drivers use QVariant::ByteArray for string-type
579  * MySQL fields marked with the BINARY attribute (those using a
580  * *_bin collation) and QVariant::String for all others.
581  * Since QVariant::toString() uses QString::fromAscii()
582  * (through QVariant::convert()) when the QVariant's type is
583  * QVariant::ByteArray, we have to use QString::fromUtf8()
584  * explicitly to prevent corrupting characters.
585  * The following code should be changed to use the simpler
586  * toString() approach, as above, if we do a DB update to
587  * coalesce the people.name values that differ only in case and
588  * change the collation to utf8_general_ci, to match the
589  * majority of other columns, or we'll have the same problem in
590  * reverse.
591  */
592  pCastMember->setName(QString::fromUtf8(query.value(1)
593  .toByteArray().constData()));
594  pCastMember->setCharacterName(QString::fromUtf8(query.value(2)
595  .toByteArray().constData()));
596  }
597  }
598 
599 }
600 
601 
602 void V2FillCutList(V2CutList* pCutList, ProgramInfo* rInfo, int marktype)
603 {
604  frm_dir_map_t markMap;
605  frm_dir_map_t::const_iterator it;
606 
607  if (rInfo && rInfo->GetChanID())
608  {
609  rInfo->QueryCutList(markMap);
610 
611  for (it = markMap.cbegin(); it != markMap.cend(); ++it)
612  {
613  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
614  if (marktype == 0)
615  {
616  V2Cutting *pCutting = pCutList->AddNewCutting();
617  pCutting->setMark(*it);
618  pCutting->setOffset(it.key());
619  }
620  else if (marktype == 1)
621  {
622  uint64_t offset = 0;
623  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
624  {
625  V2Cutting *pCutting = pCutList->AddNewCutting();
626  pCutting->setMark(*it);
627  pCutting->setOffset(offset);
628  }
629  }
630  else if (marktype == 2)
631  {
632  uint64_t offset = 0;
633  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
634  {
635  V2Cutting *pCutting = pCutList->AddNewCutting();
636  pCutting->setMark(*it);
637  pCutting->setOffset(offset);
638  }
639  }
640  }
641  }
642 }
643 
644 void V2FillCommBreak(V2CutList* pCutList, ProgramInfo* rInfo, int marktype)
645 {
646  frm_dir_map_t markMap;
647  frm_dir_map_t::const_iterator it;
648 
649  if (rInfo)
650  {
651  rInfo->QueryCommBreakList(markMap);
652 
653  for (it = markMap.cbegin(); it != markMap.cend(); ++it)
654  {
655  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
656  if (marktype == 0)
657  {
658  V2Cutting *pCutting = pCutList->AddNewCutting();
659  pCutting->setMark(*it);
660  pCutting->setOffset(it.key());
661  }
662  else if (marktype == 1)
663  {
664  uint64_t offset = 0;
665  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
666  {
667  V2Cutting *pCutting = pCutList->AddNewCutting();
668  pCutting->setMark(*it);
669  pCutting->setOffset(offset);
670  }
671  }
672  else if (marktype == 2)
673  {
674  uint64_t offset = 0;
675  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
676  {
677  V2Cutting *pCutting = pCutList->AddNewCutting();
678  pCutting->setMark(*it);
679  pCutting->setOffset(offset);
680  }
681  }
682  }
683  }
684 }
685 
687 //
689 
690 void V2FillSeek(V2CutList* pCutList, RecordingInfo* rInfo, MarkTypes marktype)
691 {
692  frm_pos_map_t markMap;
693  frm_pos_map_t::const_iterator it;
694 
695  if (rInfo && rInfo->GetChanID())
696  {
697  rInfo->QueryPositionMap(markMap, marktype);
698 
699  for (it = markMap.cbegin(); it != markMap.cend(); ++it)
700  {
701  V2Cutting *pCutting = pCutList->AddNewCutting();
702  pCutting->setMark(it.key());
703  pCutting->setOffset(it.value());
704  }
705  }
706 }
707 
708 void FillEncoderList(QVariantList &list, QObject* parent)
709 {
710  QReadLocker tvlocker(&TVRec::s_inputsLock);
711  QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo(true);
712  for (auto * elink : std::as_const(gTVList))
713  {
714  if (elink != nullptr)
715  {
716  // V2Encoder *pEncoder = list->AddNewEncoder();
717  auto *pEncoder = new V2Encoder( parent );
718  list.append( QVariant::fromValue<QObject *>( pEncoder ));
719 
720  pEncoder->setId ( elink->GetInputID() );
721  pEncoder->setState ( elink->GetState() );
722  pEncoder->setLocal ( elink->IsLocal() );
723  pEncoder->setConnected ( elink->IsConnected() );
724  pEncoder->setSleepStatus ( elink->GetSleepStatus() );
725 
726  if (pEncoder->GetLocal())
727  pEncoder->setHostName( gCoreContext->GetHostName() );
728  else
729  pEncoder->setHostName( elink->GetHostName() );
730 
731  for (const auto & inputInfo : std::as_const(inputInfoList))
732  {
733  if (inputInfo.m_inputId == static_cast<uint>(elink->GetInputID()))
734  {
735  V2Input *input = pEncoder->AddNewInput();
736  V2FillInputInfo(input, inputInfo);
737  }
738  }
739 
740  bool progFound = false;
741  V2Program *pProgram = pEncoder->Recording();
742  switch ( pEncoder->GetState() )
743  {
747  {
748  ProgramInfo *pInfo = elink->GetRecording();
749 
750  if (pInfo)
751  {
752  progFound= true;
753  V2FillProgramInfo( pProgram, pInfo, true, true );
754  delete pInfo;
755  }
756 
757  break;
758  }
759 
760  default:
761  break;
762  }
763  if (!progFound)
764  pProgram->setProperty("isNull",QVariant(true));
765  }
766  }
767 }
768 
769 // Note - special value -999 for nRecStatus means all values less than 0.
770 // This is needed by BackendStatus API
771 int FillUpcomingList(QVariantList &list, QObject* parent,
772  int& nStartIndex,
773  int& nCount,
774  bool bShowAll,
775  int nRecordId,
776  int nRecStatus,
777  const QString &Sort )
778 {
779  RecordingList recordingList; // Auto-delete deque
780  RecList tmpList; // Standard deque, objects must be deleted
781 
782  if (nRecordId <= 0)
783  nRecordId = -1;
784 
785  // For nRecStatus to be effective, showAll must be true.
786  if (nRecStatus != 0)
787  bShowAll = true;
788 
789  // NOTE: Fetching this information directly from the schedule is
790  // significantly faster than using ProgramInfo::LoadFromScheduler()
791  auto *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
792  if (scheduler)
793  scheduler->GetAllPending(tmpList, nRecordId);
794 
795  // Sort the upcoming into only those which will record
796  // NOLINTNEXTLINE(modernize-loop-convert)
797  for (auto it = tmpList.begin(); it < tmpList.end(); ++it)
798  {
799  if ((nRecStatus == -999
800  && (*it)->GetRecordingStatus() >= 0)
801  || (nRecStatus != 0 && nRecStatus != -999
802  && (*it)->GetRecordingStatus() != nRecStatus))
803  {
804  delete *it;
805  *it = nullptr;
806  continue;
807  }
808 
809  if (!bShowAll && ((((*it)->GetRecordingStatus() >= RecStatus::Pending) &&
810  ((*it)->GetRecordingStatus() <= RecStatus::WillRecord)) ||
811  ((*it)->GetRecordingStatus() == RecStatus::Offline) ||
812  ((*it)->GetRecordingStatus() == RecStatus::Conflict)) &&
813  ((*it)->GetRecordingEndTime() > MythDate::current()))
814  { // NOLINT(bugprone-branch-clone)
815  recordingList.push_back(new RecordingInfo(**it));
816  }
817  else if (bShowAll &&
818  ((*it)->GetRecordingEndTime() > MythDate::current()))
819  {
820  recordingList.push_back(new RecordingInfo(**it));
821  }
822 
823  delete *it;
824  *it = nullptr;
825  }
826 
827  // Sort the list
828 
829  int sortType = 0;
830  if (Sort.toLower().startsWith("channum"))
831  sortType = 10;
832  else if (Sort.toLower().startsWith("title"))
833  sortType = 20;
834  if (Sort.toLower().endsWith("desc"))
835  sortType += 1;
836 
837  auto comp = [sortType](const RecordingInfo *First, const RecordingInfo *Second)
838  {
839  switch (sortType)
840  {
841  case 0:
842  return First->GetScheduledStartTime() < Second->GetScheduledStartTime();
843  case 1:
844  return First->GetScheduledStartTime() > Second->GetScheduledStartTime();
845  case 10:
846  return First->GetChanNum().replace('-','.').toDouble() < Second->GetChanNum().replace('-','.').toDouble();
847  case 11:
848  return First->GetChanNum().replace('-','.').toDouble() > Second->GetChanNum().replace('-','.').toDouble();
849  case 20:
850  return QString::compare(First->GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) < 0 ;
851  case 21:
852  return QString::compare(First->GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) > 0 ;
853  }
854  return false;
855  };
856 
857  // no need to sort when zero because that is the default order from the scheduler
858  if (sortType > 0)
859  std::stable_sort(recordingList.begin(), recordingList.end(), comp);
860 
861  // ----------------------------------------------------------------------
862  // Build Response
863  // ----------------------------------------------------------------------
864 
865  nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, (int)recordingList.size() ) : 0;
866  nCount = (nCount > 0) ? std::min( nCount, (int)recordingList.size() ) : recordingList.size();
867  int nEndIndex = std::min((nStartIndex + nCount), (int)recordingList.size() );
868 
869  for( int n = nStartIndex; n < nEndIndex; n++)
870  {
871  ProgramInfo *pInfo = recordingList[ n ];
872  auto *pProgram = new V2Program( parent );
873  list.append( QVariant::fromValue<QObject *>( pProgram ));
874  V2FillProgramInfo( pProgram, pInfo, true );
875  }
876 
877  return recordingList.size();
878 }
879 
880 void FillFrontendList(QVariantList &list, QObject* parent, bool OnLine)
881 {
882  QMap<QString, Frontend*> frontends;
883  if (OnLine)
884  frontends = gBackendContext->GetConnectedFrontends();
885  else
886  frontends = gBackendContext->GetFrontends();
887 
888  for (auto * fe : std::as_const(frontends))
889  {
890  auto *pFrontend = new V2Frontend( parent );
891  list.append( QVariant::fromValue<QObject *>( pFrontend ));
892  pFrontend->setName(fe->m_name);
893  pFrontend->setIP(fe->m_ip.toString());
894  int port = gCoreContext->GetNumSettingOnHost("FrontendStatusPort",
895  fe->m_name, 6547);
896  pFrontend->setPort(port);
897  pFrontend->setOnLine(fe->m_connectionCount > 0);
898  }
899 }
900 
901 
902 int V2CreateRecordingGroup(const QString& groupName)
903 {
904  int groupID = -1;
905  MSqlQuery query(MSqlQuery::InitCon());
906 
907  query.prepare("INSERT INTO recgroups SET recgroup = :NAME, "
908  "displayname = :DISPLAYNAME");
909  query.bindValue(":NAME", groupName);
910  query.bindValue(":DISPLAYNAME", groupName);
911 
912  if (query.exec())
913  groupID = query.lastInsertId().toInt();
914 
915  if (groupID <= 0)
916  LOG(VB_GENERAL, LOG_ERR, QString("Could not create recording group (%1). "
917  "Does it already exist?").arg(groupName));
918 
919  return groupID;
920 }
921 
922 DBCredits * V2jsonCastToCredits(const QJsonObject &cast)
923 {
924  int priority = 1;
925  auto* credits = new DBCredits;
926 
927  QJsonArray members = cast["CastMembers"].toArray();
928  for (const auto & m : std::as_const(members))
929  {
930  QJsonObject actor = m.toObject();
931  QString name = actor.value("Name").toString("");
932  QString character = actor.value("CharacterName").toString("");
933  QString role = actor.value("Role").toString("");
934 
935  credits->emplace_back(role, name, priority++, character);
936  }
937 
938  return credits;
939 }
940 
941 // Code copied from class VideoDevice
942 V2CaptureDeviceList* getV4l2List ( const QRegularExpression &driver, const QString & cardType )
943 {
944  auto* pList = new V2CaptureDeviceList();
945  uint minor_min = 0;
946  uint minor_max = 15;
947  QString card = QString();
948 
949  // /dev/v4l/video*
950  QDir dev("/dev/v4l", "video*", QDir::Name, QDir::System);
951  fillSelectionsFromDir(dev, minor_min, minor_max,
952  card, driver, false, pList, cardType);
953 
954  // /dev/video*
955  dev.setPath("/dev");
956  fillSelectionsFromDir(dev, minor_min, minor_max,
957  card, driver, false, pList, cardType);
958 
959  // /dev/dtv/video*
960  dev.setPath("/dev/dtv");
961  fillSelectionsFromDir(dev, minor_min, minor_max,
962  card, driver, false, pList, cardType);
963 
964  // /dev/dtv*
965  dev.setPath("/dev");
966  dev.setNameFilters(QStringList("dtv*"));
967  fillSelectionsFromDir(dev, minor_min, minor_max,
968  card, driver, false, pList, cardType);
969 
970  return pList;
971 }
972 
973 uint fillSelectionsFromDir(const QDir& dir,
974  uint minor_min, uint minor_max,
975  const QString& card, const QRegularExpression& driver,
976  bool allow_duplicates, V2CaptureDeviceList *pList,
977  const QString & cardType)
978 {
979  uint cnt = 0;
980  QMap<uint, uint> minorlist;
981  QFileInfoList entries = dir.entryInfoList();
982  for (const auto & fi : std::as_const(entries))
983  {
984  struct stat st {};
985  QString filepath = fi.absoluteFilePath();
986  int err = lstat(filepath.toLocal8Bit().constData(), &st);
987 
988  if (err)
989  {
990  LOG(VB_GENERAL, LOG_ERR,
991  QString("Could not stat file: %1").arg(filepath));
992  continue;
993  }
994 
995  // is this is a character device?
996  if (!S_ISCHR(st.st_mode))
997  continue;
998 
999  // is this device is in our minor range?
1000  uint minor_num = minor(st.st_rdev);
1001  if (minor_min > minor_num || minor_max < minor_num)
1002  continue;
1003 
1004  // ignore duplicates if allow_duplicates not set
1005  if (!allow_duplicates && minorlist[minor_num])
1006  continue;
1007 
1008  // if the driver returns any info add this device to our list
1009  QByteArray tmp = filepath.toLatin1();
1010  int videofd = open(tmp.constData(), O_RDWR);
1011  if (videofd >= 0)
1012  {
1013  QString card_name;
1014  QString driver_name;
1015  if (CardUtil::GetV4LInfo(videofd, card_name, driver_name))
1016  {
1017  auto match = driver.match(driver_name);
1018  if ((!driver.pattern().isEmpty() || match.hasMatch()) &&
1019  (card.isEmpty() || (card_name == card)))
1020  {
1021  auto* pDev = pList->AddCaptureDevice();
1022  pDev->setCardType (cardType);
1023  pDev->setVideoDevice (filepath);
1024  pDev->setFrontendName(card_name);
1025  QStringList inputs;
1026  CardUtil::GetDeviceInputNames(filepath, cardType, inputs);
1027  pDev->setInputNames(inputs);
1028  inputs = CardUtil::ProbeAudioInputs(filepath);
1029  pDev->setAudioDevices(inputs);
1030  if (cardType == "HDPVR")
1031  pDev->setChannelTimeout ( 15000 );
1032  cnt++;
1033  }
1034  }
1035  close(videofd);
1036  }
1037  // add to list of minors discovered to avoid duplicates
1038  minorlist[minor_num] = 1;
1039  }
1040 
1041  return cnt;
1042 }
1043 
1044 V2CaptureDeviceList* getFirewireList (const QString & cardType)
1045 {
1046  auto* pList = new V2CaptureDeviceList();
1047 
1048 #ifdef USING_FIREWIRE
1049  std::vector<AVCInfo> list = FirewireDevice::GetSTBList();
1050  for (auto & info : list)
1051  {
1052  auto* pDev = pList->AddCaptureDevice();
1053  pDev->setCardType (cardType);
1054  QString guid = info.GetGUIDString();
1055  pDev->setVideoDevice (guid);
1056  QString model = FirewireDevice::GetModelName(info.m_vendorid, info.m_modelid);
1057  pDev->setFirewireModel(model);
1058  pDev->setDescription(info.m_product_name);
1059  pDev->setSignalTimeout ( 2000 );
1060  pDev->setChannelTimeout ( 9000 );
1061  }
1062 #endif // USING_FIREWIRE
1063  return pList;
1064 }
ChannelInfo
Definition: channelinfo.h:31
V2FillGenreList
void V2FillGenreList(V2GenreList *pGenreList, int videoID)
Definition: v2serviceUtil.cpp:362
ChannelGroupItem::m_grpId
uint m_grpId
Definition: channelgroup.h:28
RecordingRule::m_channelid
int m_channelid
callsign?
Definition: recordingrule.h:99
Scheduler
Definition: scheduler.h:45
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:813
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:127
V2CaptureDeviceList::AddCaptureDevice
V2CaptureDevice * AddCaptureDevice()
Definition: v2captureCardList.h:117
RecordingRule::m_autoTranscode
bool m_autoTranscode
Definition: recordingrule.h:132
ChannelInfo::m_serviceType
uint m_serviceType
Definition: channelinfo.h:112
RecordingRule::m_enddate
QDate m_enddate
Definition: recordingrule.h:90
MusicMetadata::Title
QString Title() const
Definition: musicmetadata.h:162
RecordingRule::m_playGroup
QString m_playGroup
Definition: recordingrule.h:122
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:84
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:214
RecordingRule::m_seriesid
QString m_seriesid
Definition: recordingrule.h:84
RecordingRule::m_parentRecID
int m_parentRecID
Definition: recordingrule.h:71
MusicMetadata::Filename
QString Filename(bool find=true)
Definition: musicmetadata.cpp:962
ProgramInfo::GetFilesize
virtual uint64_t GetFilesize(void) const
Definition: programinfo.cpp:6425
MARK_COMM_END
@ MARK_COMM_END
Definition: programtypes.h:60
backendcontext.h
V2FillProgramInfo
void V2FillProgramInfo(V2Program *pProgram, ProgramInfo *pInfo, bool bIncChannel, bool bDetails, bool bIncCast, bool bIncArtwork, bool bIncRecording)
Definition: v2serviceUtil.cpp:40
RecordingRule::m_description
QString m_description
Definition: recordingrule.h:81
MusicMetadata::Genre
QString Genre() const
Definition: musicmetadata.h:175
RecordingRule::m_autoCommFlag
bool m_autoCommFlag
Definition: recordingrule.h:131
RecordingRule::m_inetref
QString m_inetref
Definition: recordingrule.h:87
ProgramInfo::GetHostname
QString GetHostname(void) const
Definition: programinfo.h:421
ProgramInfo::GetInputName
QString GetInputName(void) const
Definition: programinfo.h:464
MythCoreContext::GetScheduler
MythScheduler * GetScheduler(void)
Definition: mythcorecontext.cpp:1905
RecordingRule::m_maxNewest
bool m_maxNewest
Definition: recordingrule.h:127
ProgramInfo::QueryPositionMap
void QueryPositionMap(frm_pos_map_t &posMap, MarkTypes type) const
Definition: programinfo.cpp:3762
RecordingRule::m_category
QString m_category
Definition: recordingrule.h:82
toRawString
QString toRawString(RecordingType rectype)
Converts "rectype" into an untranslated string.
Definition: recordingtypes.cpp:76
RecordingRule::m_nextRecording
QDateTime m_nextRecording
Definition: recordingrule.h:142
ChannelInfo::m_chanId
uint m_chanId
Definition: channelinfo.h:85
RecordingRule::m_starttime
QTime m_starttime
Definition: recordingrule.h:91
V2RecordingInfo
Definition: v2recording.h:23
V2ArtworkInfoList
Definition: v2artworkInfoList.h:22
V2Program::Recording
QObject Recording
Definition: v2programAndChannel.h:164
MusicMetadata::CompilationArtist
QString CompilationArtist() const
Definition: musicmetadata.h:138
V2FillCommBreak
void V2FillCommBreak(V2CutList *pCutList, ProgramInfo *rInfo, int marktype)
Definition: v2serviceUtil.cpp:644
simple_ref_ptr
Definition: quicksp.h:24
ChannelInfo::m_freqId
QString m_freqId
Definition: channelinfo.h:87
V2FillVideoMetadataInfo
void V2FillVideoMetadataInfo(V2VideoMetadataInfo *pVideoMetadataInfo, const VideoMetadataListManager::VideoMetadataPtr &pMetadata, bool bDetails)
Definition: v2serviceUtil.cpp:386
FirewireDevice::GetModelName
static QString GetModelName(uint vendor_id, uint model_id)
Definition: firewiredevice.cpp:350
ChannelGroupItem
Definition: channelgroup.h:15
RecordingInfo
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:35
newEpifromDupIn
bool newEpifromDupIn(RecordingDupInType recdupin)
Definition: recordingtypes.cpp:211
MARK_CUT_END
@ MARK_CUT_END
Definition: programtypes.h:55
RecordingInfo::GetFilesize
uint64_t GetFilesize(void) const override
Definition: recordinginfo.cpp:1755
ProgramInfo::GetRecordingID
uint GetRecordingID(void) const
Definition: programinfo.h:446
ProgramInfo::GetChanNum
QString GetChanNum(void) const
This is the channel "number", in the form 1, 1_2, 1-2, 1#1, etc.
Definition: programinfo.h:376
ChannelInfo::m_fineTune
int m_fineTune
Definition: channelinfo.h:95
MSqlQuery::lastInsertId
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:936
RecordingRule::m_title
QString m_title
Definition: recordingrule.h:77
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:204
V2ChannelGroup
Definition: v2channelGroup.h:19
ProgramInfo::GetCategory
QString GetCategory(void) const
Definition: programinfo.h:369
RecordingRule::m_averageDelay
int m_averageDelay
Definition: recordingrule.h:141
GetArtwork
ArtworkMap GetArtwork(const QString &inetref, uint season, bool strict)
Definition: metadataimagehelper.cpp:23
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:118
RecordingRule::m_lastDeleted
QDateTime m_lastDeleted
Definition: recordingrule.h:144
RecStatus::Unknown
@ Unknown
Definition: recordingstatus.h:31
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
RecordingRule::m_endOffset
int m_endOffset
Definition: recordingrule.h:110
ChannelInfo::m_atscMajorChan
uint m_atscMajorChan
Definition: channelinfo.h:113
MusicMetadata::ID
IdType ID() const
Definition: musicmetadata.h:218
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:619
V2Frontend
Definition: v2frontend.h:18
ChannelInfo::m_name
QString m_name
Definition: channelinfo.h:92
MusicMetadata::Track
int Track() const
Definition: musicmetadata.h:199
ContentTypeToString
QString ContentTypeToString(VideoContentType type)
Definition: videoutils.cpp:295
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
ProgramInfo::GetScheduledEndTime
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
Definition: programinfo.h:397
ProgramInfo::QueryKeyFrameDuration
bool QueryKeyFrameDuration(uint64_t *duration, uint64_t keyframe, bool backwards) const
Definition: programinfo.cpp:4216
firewiredevice.h
MusicMetadata
Definition: musicmetadata.h:80
MusicMetadata::Length
std::chrono::milliseconds Length() const
Definition: musicmetadata.h:205
gBackendContext
BackendContext * gBackendContext
Definition: backendcontext.cpp:9
recordingtypes.h
RecordingRule::m_dupIn
RecordingDupInType m_dupIn
Definition: recordingrule.h:114
RecordingRule::m_isInactive
bool m_isInactive
Recording rule is enabled?
Definition: recordingrule.h:74
ProgramInfo::GetRecordingEndTime
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
Definition: programinfo.h:412
ProgramInfo::GetProgramFlags
uint32_t GetProgramFlags(void) const
Definition: programinfo.h:470
ProgramInfo::GetRecordingGroup
QString GetRecordingGroup(void) const
Definition: programinfo.h:419
getV4l2List
V2CaptureDeviceList * getV4l2List(const QRegularExpression &driver, const QString &cardType)
Definition: v2serviceUtil.cpp:942
MusicMetadata::Artist
QString Artist() const
Definition: musicmetadata.h:126
ProgramInfo::GetRecordingPriority
int GetRecordingPriority(void) const
Definition: programinfo.h:440
V2CaptureDeviceList
Definition: v2captureCardList.h:97
RecordingRule::m_season
uint m_season
Definition: recordingrule.h:94
FirewireDevice::GetSTBList
static std::vector< AVCInfo > GetSTBList(void)
Definition: firewiredevice.cpp:363
V2Program::Channel
QObject Channel
Definition: v2programAndChannel.h:163
ChannelInfo::m_icon
QString m_icon
Definition: channelinfo.h:93
scheduler.h
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
ProgramInfo::GetRecordingStartTime
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:404
ProgramInfo::GetPathname
QString GetPathname(void) const
Definition: programinfo.h:343
FillFrontendList
void FillFrontendList(QVariantList &list, QObject *parent, bool OnLine)
Definition: v2serviceUtil.cpp:880
close
#define close
Definition: compat.h:43
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
programtypes.h
DBCredits
std::vector< DBPerson > DBCredits
Definition: programdata.h:73
kState_WatchingRecording
@ kState_WatchingRecording
Watching Recording is the state for when we are watching an in progress recording,...
Definition: tv.h:80
V2CutList::AddNewCutting
V2Cutting * AddNewCutting()
Definition: v2cutList.h:43
AutoDeleteDeque::begin
iterator begin(void)
Definition: autodeletedeque.h:50
ProgramInfo::IsRepeat
bool IsRepeat(void) const
Definition: programinfo.h:487
RecStatus::WillRecord
@ WillRecord
Definition: recordingstatus.h:30
RecordingInfo::GetProgramRecordingProfile
QString GetProgramRecordingProfile(void) const
Returns recording profile name that will be, or was used, for this program, creating "record" field i...
Definition: recordinginfo.cpp:492
ProgramInfo::GetInetRef
QString GetInetRef(void) const
Definition: programinfo.h:437
ProgramInfo::GetVideoPropertyNames
QString GetVideoPropertyNames(void) const
Definition: programinfo.cpp:1509
RecordingRule::m_startOffset
int m_startOffset
Definition: recordingrule.h:109
ProgramInfo::GetYearOfInitialRelease
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:423
ChannelInfo::m_commMethod
int m_commMethod
Definition: channelinfo.h:119
V2FillInputInfo
void V2FillInputInfo(V2Input *input, const InputInfo &inputInfo)
Definition: v2serviceUtil.cpp:513
ChannelInfo::m_useOnAirGuide
bool m_useOnAirGuide
Definition: channelinfo.h:108
RecordingRule::m_episode
uint m_episode
Definition: recordingrule.h:95
InputInfo::m_recPriority
int m_recPriority
Definition: inputinfo.h:53
minor
#define minor(X)
Definition: compat.h:78
programinfo.h
getFirewireList
V2CaptureDeviceList * getFirewireList(const QString &cardType)
Definition: v2serviceUtil.cpp:1044
ProgramInfo::GetScheduledStartTime
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Definition: programinfo.h:390
ProgramInfo::GetRecordingStatus
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:447
V2VideoMetadataInfo::Artwork
QObject Artwork
Definition: v2videoMetadataInfo.h:46
v2serviceUtil.h
InputInfo::m_liveTvOrder
uint m_liveTvOrder
order for live TV use
Definition: inputinfo.h:55
RecordingRule::m_autoUserJob4
bool m_autoUserJob4
Definition: recordingrule.h:136
CardUtil::GetV4LInfo
static bool GetV4LInfo(int videofd, QString &input, QString &driver, uint32_t &version, uint32_t &capabilities)
Definition: cardutil.cpp:2351
V2FillRecRuleInfo
void V2FillRecRuleInfo(V2RecRule *pRecRule, RecordingRule *pRule)
Definition: v2serviceUtil.cpp:261
ProgramInfo::GetProgramFlagNames
QString GetProgramFlagNames(void) const
Definition: programinfo.cpp:1498
ProgramInfo::GetSubtitleTypeNames
QString GetSubtitleTypeNames(void) const
Definition: programinfo.cpp:1503
ChannelInfo::GetGroupIds
QList< uint > GetGroupIds() const
Definition: channelinfo.h:57
v2encoder.h
FillEncoderList
void FillEncoderList(QVariantList &list, QObject *parent)
Definition: v2serviceUtil.cpp:708
ChannelInfo::m_atscMinorChan
uint m_atscMinorChan
Definition: channelinfo.h:114
RecordingInfo::GetRecgroupString
static QString GetRecgroupString(uint recGroupID)
Temporary helper during transition from string to ID.
Definition: recordinginfo.cpp:1705
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:551
ProgramInfo::GetTitle
QString GetTitle(void) const
Definition: programinfo.h:361
ProgramInfo::GetDescription
QString GetDescription(void) const
Definition: programinfo.h:365
compat.h
RecordingRule::m_autoUserJob2
bool m_autoUserJob2
Definition: recordingrule.h:134
BackendContext::GetFrontends
QMap< QString, Frontend * > GetFrontends() const
Definition: backendcontext.h:43
V2FillSeek
void V2FillSeek(V2CutList *pCutList, RecordingInfo *rInfo, MarkTypes marktype)
Definition: v2serviceUtil.cpp:690
ProgramInfo::GetEpisodeTotal
uint GetEpisodeTotal(void) const
Definition: programinfo.h:368
RecordingRule::m_findtime
QTime m_findtime
Time for timeslot rules.
Definition: recordingrule.h:101
V2FillCastMemberList
void V2FillCastMemberList(V2CastMemberList *pCastMemberList, ProgramInfo *pInfo)
Definition: v2serviceUtil.cpp:528
RecordingRule::m_lastRecorded
QDateTime m_lastRecorded
Definition: recordingrule.h:143
RecordingRule::m_autoExpire
bool m_autoExpire
Definition: recordingrule.h:126
V2Encoder
Definition: v2encoder.h:23
RecordingRule::m_recProfile
QString m_recProfile
Definition: recordingrule.h:120
ChannelInfo::m_chanNum
QString m_chanNum
Definition: channelinfo.h:86
ProgramInfo::QueryCutList
bool QueryCutList(frm_dir_map_t &delMap, bool loadAutosave=false) const
Definition: programinfo.cpp:3464
kArtworkFanart
@ kArtworkFanart
Definition: metadataimagehelper.h:12
RecordingRule::m_searchType
RecSearchType m_searchType
Definition: recordingrule.h:112
RecordingRule::m_type
RecordingType m_type
Definition: recordingrule.h:111
RecStatus::Conflict
@ Conflict
Definition: recordingstatus.h:38
MythCoreContext::GetNumSettingOnHost
int GetNumSettingOnHost(const QString &key, const QString &host, int defaultval=0)
Definition: mythcorecontext.cpp:943
RecordingRule::m_subtitle
QString m_subtitle
Definition: recordingrule.h:79
V2FillChannelGroup
void V2FillChannelGroup(V2ChannelGroup *pGroup, const ChannelGroupItem &pGroupItem)
Definition: v2serviceUtil.cpp:247
ProgramInfo::GetAudioProperties
uint GetAudioProperties(void) const
Definition: programinfo.h:497
V2CutList
Definition: v2cutList.h:21
ProgramInfo::GetPlaybackGroup
QString GetPlaybackGroup(void) const
Definition: programinfo.h:420
V2Genre
Definition: v2genre.h:21
RecordingRule::m_findday
int m_findday
Day of the week for once per week etc.
Definition: recordingrule.h:104
V2FillChannelInfo
bool V2FillChannelInfo(V2ChannelInfo *pChannel, uint nChanID, bool bDetails)
Definition: v2serviceUtil.cpp:163
ChannelInfo::m_tmOffset
int m_tmOffset
Definition: channelinfo.h:120
RecordingRule::m_filter
unsigned m_filter
Definition: recordingrule.h:115
V2Program::Artwork
QObject Artwork
Definition: v2programAndChannel.h:165
TVRec::s_inputsLock
static QReadWriteLock s_inputsLock
Definition: tv_rec.h:432
uint
unsigned int uint
Definition: compat.h:81
gTVList
QMap< int, EncoderLink * > gTVList
Definition: backendcontext.cpp:7
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
ProgramInfo::GetSeriesID
QString GetSeriesID(void) const
Definition: programinfo.h:435
ChannelGroupItem::m_name
QString m_name
Definition: channelgroup.h:29
V2ArtworkInfoList::AddNewArtworkInfo
V2ArtworkInfo * AddNewArtworkInfo()
Definition: v2artworkInfoList.h:46
AutoDeleteDeque::end
iterator end(void)
Definition: autodeletedeque.h:51
V2CreateRecordingGroup
int V2CreateRecordingGroup(const QString &groupName)
Definition: v2serviceUtil.cpp:902
ProgramInfo::GetStorageGroup
QString GetStorageGroup(void) const
Definition: programinfo.h:422
RecordingRule::m_maxEpisodes
int m_maxEpisodes
Definition: recordingrule.h:125
RecStatus::Offline
@ Offline
Definition: recordingstatus.h:43
ProgramInfo::GetOriginalAirDate
QDate GetOriginalAirDate(void) const
Definition: programinfo.h:428
RecordingRule::m_programid
QString m_programid
Definition: recordingrule.h:85
channelutil.h
frm_pos_map_t
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:45
InputInfo::m_inputId
uint m_inputId
unique key in DB for this input
Definition: inputinfo.h:49
ProgramInfo::GetVideoProperties
uint GetVideoProperties(void) const
Definition: programinfo.h:495
RecStatus::Pending
@ Pending
Definition: recordingstatus.h:16
RecordingRule::m_recGroupID
uint m_recGroupID
Definition: recordingrule.h:123
RecordingRule::m_endtime
QTime m_endtime
Definition: recordingrule.h:92
MusicMetadata::Album
QString Album() const
Definition: musicmetadata.h:150
InputInfo::m_quickTune
bool m_quickTune
Definition: inputinfo.h:56
BackendContext::GetConnectedFrontends
QMap< QString, Frontend * > GetConnectedFrontends() const
Definition: backendcontext.h:42
ProgramInfo::GetDuplicateCheckMethod
RecordingDupMethodType GetDuplicateCheckMethod(void) const
What should be compared to determine if two programs are the same?
Definition: programinfo.h:459
AutoDeleteDeque
Definition: autodeletedeque.h:8
channelinfo.h
ProgramInfo::GetInputID
uint GetInputID(void) const
Definition: programinfo.h:463
V2MusicMetadataInfo
Definition: v2musicMetadataInfo.h:22
InputInfo::m_scheduleOrder
uint m_scheduleOrder
Definition: inputinfo.h:54
InputInfo::m_sourceId
uint m_sourceId
associated channel listings source
Definition: inputinfo.h:48
recordinginfo.h
lstat
#define lstat
Definition: compat.h:121
RecordingRule::m_storageGroup
QString m_storageGroup
Definition: recordingrule.h:121
ProgramInfo::GetChanID
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:372
ProgramInfo::GetRecordingRuleType
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:451
ProgramInfo::GetEpisode
uint GetEpisode(void) const
Definition: programinfo.h:367
RecordingRule::m_transcoder
int m_transcoder
Definition: recordingrule.h:130
RecordingRule::m_autoUserJob1
bool m_autoUserJob1
Definition: recordingrule.h:133
AutoDeleteDeque::push_back
void push_back(T info)
Definition: autodeletedeque.h:69
V2Program::Cast
QObject Cast
Definition: v2programAndChannel.h:166
ChannelInfo::m_serviceId
uint m_serviceId
Definition: channelinfo.h:111
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
channelgroup.h
RecordingRule::m_recordID
int m_recordID
Unique Recording Rule ID.
Definition: recordingrule.h:70
ProgramInfo::GetAudioPropertyNames
QString GetAudioPropertyNames(void) const
Definition: programinfo.cpp:1514
ProgramInfo::QueryKeyFramePosition
bool QueryKeyFramePosition(uint64_t *position, uint64_t keyframe, bool backwards) const
Definition: programinfo.cpp:4198
MusicMetadata::Hostname
QString Hostname(void)
Definition: musicmetadata.h:230
ProgramInfo::GetLastModifiedTime
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:429
mythscheduler.h
V2CastMember
Definition: v2castMember.h:19
ProgramInfo::GetSeason
uint GetSeason(void) const
Definition: programinfo.h:366
cardutil.h
v2frontend.h
RecordingRule::m_dupMethod
RecordingDupMethodType m_dupMethod
Definition: recordingrule.h:113
ProgramInfo::GetCategoryTypeString
QString GetCategoryTypeString(void) const
Returns catType as a string.
Definition: programinfo.cpp:1887
V2FillMusicMetadataInfo
void V2FillMusicMetadataInfo(V2MusicMetadataInfo *pVideoMetadataInfo, MusicMetadata *pMetadata, bool bDetails)
Definition: v2serviceUtil.cpp:488
ChannelInfo::Load
bool Load(uint lchanid=-1)
Definition: channelinfo.cpp:131
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:889
MarkTypes
MarkTypes
Definition: programtypes.h:47
MusicMetadata::LastPlay
QDateTime LastPlay() const
Definition: musicmetadata.h:244
V2FillCutList
void V2FillCutList(V2CutList *pCutList, ProgramInfo *rInfo, int marktype)
Definition: v2serviceUtil.cpp:602
MusicMetadata::Compilation
bool Compilation() const
Definition: musicmetadata.h:252
ChannelInfo::m_sourceId
uint m_sourceId
Definition: channelinfo.h:89
CardUtil::ProbeAudioInputs
static QStringList ProbeAudioInputs(const QString &device, const QString &inputtype=QString())
Definition: cardutil.cpp:2538
RecList
std::deque< RecordingInfo * > RecList
Definition: mythscheduler.h:12
ChannelInfo::m_tvFormat
QString m_tvFormat
Definition: channelinfo.h:105
V2Program
Definition: v2programAndChannel.h:121
RecordingRule::m_autoExtend
AutoExtendType m_autoExtend
Definition: recordingrule.h:116
ChannelInfo::m_recPriority
int m_recPriority
Definition: channelinfo.h:98
tv_rec.h
kState_WatchingLiveTV
@ kState_WatchingLiveTV
Watching LiveTV is the state for when we are watching a recording and the user has control over the c...
Definition: tv.h:63
ProgramInfo::GetDuplicateCheckSource
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:455
MusicMetadata::PlayCount
int PlayCount() const
Definition: musicmetadata.h:248
InputInfo
Definition: inputinfo.h:14
kArtworkBanner
@ kArtworkBanner
Definition: metadataimagehelper.h:13
V2CastMemberList
Definition: v2castMemberList.h:13
ChannelInfo::m_xmltvId
QString m_xmltvId
Definition: channelinfo.h:97
V2CastMemberList::AddNewCastMember
V2CastMember * AddNewCastMember()
Definition: v2castMemberList.h:37
ArtworkMap
QMultiMap< VideoArtworkType, ArtworkInfo > ArtworkMap
Definition: metadataimagehelper.h:31
ProgramInfo::QueryCommBreakList
void QueryCommBreakList(frm_dir_map_t &frames) const
Definition: programinfo.cpp:3550
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:838
ChannelInfo::m_videoFilters
QString m_videoFilters
Definition: channelinfo.h:96
Scheduler::GetAllPending
bool GetAllPending(RecList &retList, int recRuleId=0) const
Definition: scheduler.cpp:1741
MusicMetadata::Rating
int Rating() const
Definition: musicmetadata.h:239
V2GenreList
Definition: v2genreList.h:22
ProgramInfo::GetProgramID
QString GetProgramID(void) const
Definition: programinfo.h:436
ChannelInfo::GetInputIds
QList< uint > GetInputIds() const
Definition: channelinfo.h:67
RecordingRule::m_station
QString m_station
Definition: recordingrule.h:98
ProgramInfo::GetRecordingRuleID
uint GetRecordingRuleID(void) const
Definition: programinfo.h:449
fillSelectionsFromDir
uint fillSelectionsFromDir(const QDir &dir, uint minor_min, uint minor_max, const QString &card, const QRegularExpression &driver, bool allow_duplicates, V2CaptureDeviceList *pList, const QString &cardType)
Definition: v2serviceUtil.cpp:973
V2VideoMetadataInfo::Genres
QObject Genres
Definition: v2videoMetadataInfo.h:48
CardUtil::GetAllInputInfo
static QList< InputInfo > GetAllInputInfo(bool virtTuners)
Definition: cardutil.cpp:1733
RecordingRule::m_recPriority
int m_recPriority
Definition: recordingrule.h:107
CardUtil::GetDeviceInputNames
static void GetDeviceInputNames(const QString &device, const QString &inputtype, QStringList &inputs)
Definition: cardutil.cpp:2656
V2GenreList::AddNewGenre
V2Genre * AddNewGenre()
Definition: v2genreList.h:48
ProgramInfo::GetSubtitleType
uint GetSubtitleType(void) const
Definition: programinfo.h:493
RecordingRule::m_autoUserJob3
bool m_autoUserJob3
Definition: recordingrule.h:135
ChannelInfo::m_mplexId
uint m_mplexId
Definition: channelinfo.h:110
ChannelInfo::m_visible
ChannelVisibleType m_visible
Definition: channelinfo.h:106
V2FillArtworkInfoList
void V2FillArtworkInfoList(V2ArtworkInfoList *pArtworkInfoList, const QString &sInetref, uint nSeason)
Definition: v2serviceUtil.cpp:319
V2ArtworkInfo
Definition: v2artworkInfo.h:21
InputInfo::m_displayName
QString m_displayName
Definition: inputinfo.h:52
kArtworkCoverart
@ kArtworkCoverart
Definition: metadataimagehelper.h:11
kState_RecordingOnly
@ kState_RecordingOnly
Recording Only is a TVRec only state for when we are recording a program, but there is no one current...
Definition: tv.h:84
V2Input
Definition: v2input.h:20
videoutils.h
MusicMetadata::Year
int Year() const
Definition: musicmetadata.h:196
RecordingRule::m_startdate
QDate m_startdate
Definition: recordingrule.h:89
ChannelInfo::m_defaultAuthority
QString m_defaultAuthority
Definition: channelinfo.h:118
ChannelInfo::m_callSign
QString m_callSign
Definition: channelinfo.h:91
RecordingRule::m_autoMetadataLookup
bool m_autoMetadataLookup
Definition: recordingrule.h:137
V2ChannelInfo
Definition: v2programAndChannel.h:27
AutoDeleteDeque::size
size_t size(void) const
Definition: autodeletedeque.h:67
V2Cutting
Definition: v2cutting.h:19
RecordingRule::m_prefInput
int m_prefInput
Definition: recordingrule.h:108
kChannelNotVisible
@ kChannelNotVisible
Definition: channelinfo.h:24
V2jsonCastToCredits
DBCredits * V2jsonCastToCredits(const QJsonObject &cast)
Definition: v2serviceUtil.cpp:922
V2VideoMetadataInfo
Definition: v2videoMetadataInfo.h:9
InputInfo::m_name
QString m_name
input name
Definition: inputinfo.h:47
FillUpcomingList
int FillUpcomingList(QVariantList &list, QObject *parent, int &nStartIndex, int &nCount, bool bShowAll, int nRecordId, int nRecStatus, const QString &Sort)
Definition: v2serviceUtil.cpp:771
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:838
V2RecRule
Definition: v2recRule.h:12
ProgramInfo::GetSubtitle
QString GetSubtitle(void) const
Definition: programinfo.h:363
ProgramInfo::GetStars
float GetStars(void) const
Definition: programinfo.h:442