MythTV  0.28pre
dvr.cpp
Go to the documentation of this file.
1 // Program Name: dvr.cpp
3 // Created : Mar. 7, 2011
4 //
5 // Copyright (c) 2011 David Blain <dblain@mythtv.org>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //
25 
26 #include <QMap>
27 #include <QRegExp>
28 
29 #include "dvr.h"
30 
31 #include "compat.h"
32 #include "mythversion.h"
33 #include "mythcorecontext.h"
34 #include "mythevent.h"
35 #include "scheduler.h"
36 #include "autoexpire.h"
37 #include "jobqueue.h"
38 #include "encoderlink.h"
39 #include "remoteutil.h"
40 #include "mythdate.h"
41 #include "recordinginfo.h"
42 #include "cardutil.h"
43 #include "inputinfo.h"
44 #include "programtypes.h"
45 #include "recordingtypes.h"
46 
47 #include "serviceUtil.h"
48 #include "mythscheduler.h"
49 #include "storagegroup.h"
50 #include "playgroup.h"
51 #include "recordingprofile.h"
52 
53 #include "scheduler.h"
54 
55 extern QMap<int, EncoderLink *> tvList;
56 extern AutoExpire *expirer;
57 
59 //
61 
63  int nStartIndex,
64  int nCount,
65  const QString &sTitleRegEx,
66  const QString &sRecGroup,
67  const QString &sStorageGroup )
68 {
69  QMap< QString, ProgramInfo* > recMap;
70 
72  recMap = gCoreContext->GetScheduler()->GetRecording();
73 
74  QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap();
75  QMap< QString, bool > isJobRunning= ProgramInfo::QueryJobsRunning(JOB_COMMFLAG);
76 
77  ProgramList progList;
78 
79  int desc = 1;
80  if (bDescending)
81  desc = -1;
82 
83  LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, desc );
84 
85  QMap< QString, ProgramInfo* >::iterator mit = recMap.begin();
86 
87  for (; mit != recMap.end(); mit = recMap.erase(mit))
88  delete *mit;
89 
90  // ----------------------------------------------------------------------
91  // Build Response
92  // ----------------------------------------------------------------------
93 
94  DTC::ProgramList *pPrograms = new DTC::ProgramList();
95  int nAvailable = 0;
96 
97  int nMax = (nCount > 0) ? nCount : progList.size();
98 
99  nAvailable = 0;
100  nCount = 0;
101 
102  QRegExp rTitleRegEx = QRegExp(sTitleRegEx, Qt::CaseInsensitive);
103 
104  for( unsigned int n = 0; n < progList.size(); n++)
105  {
106  ProgramInfo *pInfo = progList[ n ];
107 
108  if (pInfo->IsDeletePending() ||
109  (!sTitleRegEx.isEmpty() && !pInfo->GetTitle().contains(rTitleRegEx)) ||
110  (!sRecGroup.isEmpty() && sRecGroup != pInfo->GetRecordingGroup()) ||
111  (!sStorageGroup.isEmpty() && sStorageGroup != pInfo->GetStorageGroup()))
112  continue;
113 
114  if ((nAvailable < nStartIndex) ||
115  (nCount >= nMax))
116  {
117  ++nAvailable;
118  continue;
119  }
120 
121  ++nAvailable;
122  ++nCount;
123 
124  DTC::Program *pProgram = pPrograms->AddNewProgram();
125 
126  FillProgramInfo( pProgram, pInfo, true );
127  }
128 
129  // ----------------------------------------------------------------------
130 
131  pPrograms->setStartIndex ( nStartIndex );
132  pPrograms->setCount ( nCount );
133  pPrograms->setTotalAvailable( nAvailable );
134  pPrograms->setAsOf ( MythDate::current() );
135  pPrograms->setVersion ( MYTH_BINARY_VERSION );
136  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
137 
138  return pPrograms;
139 }
140 
142 //
144 
146  int chanid, const QDateTime &recstarttsRaw)
147 {
148  if ((RecordedId <= 0) &&
149  (chanid <= 0 || !recstarttsRaw.isValid()))
150  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
151 
152  // TODO Should use RecordingInfo
153  ProgramInfo pi;
154  if (RecordedId > 0)
155  pi = ProgramInfo(RecordedId);
156  else
157  pi = ProgramInfo(chanid, recstarttsRaw.toUTC());
158 
159  DTC::Program *pProgram = new DTC::Program();
160  FillProgramInfo( pProgram, &pi, true );
161 
162  return pProgram;
163 }
164 
166 //
168 
169 bool Dvr::RemoveRecorded(int RecordedId,
170  int chanid, const QDateTime &recstarttsRaw,
171  bool forceDelete, bool allowRerecord)
172 {
173  return DeleteRecording(RecordedId, chanid, recstarttsRaw, forceDelete,
174  allowRerecord);
175 }
176 
177 
178 bool Dvr::DeleteRecording(int RecordedId,
179  int chanid, const QDateTime &recstarttsRaw,
180  bool forceDelete, bool allowRerecord)
181 {
182  if ((RecordedId <= 0) &&
183  (chanid <= 0 || !recstarttsRaw.isValid()))
184  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
185 
186  // TODO Should use RecordingInfo
187  ProgramInfo pi;
188  if (RecordedId > 0)
189  pi = ProgramInfo(RecordedId);
190  else
191  pi = ProgramInfo(chanid, recstarttsRaw.toUTC());
192 
193  if (pi.GetChanID() && pi.HasPathname())
194  {
195  QString cmd = QString("DELETE_RECORDING %1 %2 %3 %4")
196  .arg(pi.GetChanID())
198  .arg(forceDelete ? "FORCE" : "NO_FORCE")
199  .arg(allowRerecord ? "FORGET" : "NO_FORGET");
200  MythEvent me(cmd);
201 
202  gCoreContext->dispatch(me);
203  return true;
204  }
205 
206  return false;
207 }
208 
210 //
212 
213 bool Dvr::UnDeleteRecording(int RecordedId,
214  int chanid, const QDateTime &recstarttsRaw)
215 {
216  if ((RecordedId <= 0) &&
217  (chanid <= 0 || !recstarttsRaw.isValid()))
218  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
219 
220  RecordingInfo ri;
221  if (RecordedId > 0)
222  ri = RecordingInfo(RecordedId);
223  else
224  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
225 
226  if (ri.GetChanID() && ri.HasPathname())
227  {
228  QString cmd = QString("UNDELETE_RECORDING %1 %2")
229  .arg(ri.GetChanID())
231  MythEvent me(cmd);
232 
233  gCoreContext->dispatch(me);
234  return true;
235  }
236 
237  return false;
238 }
239 
241 //
243 
244 bool Dvr::UpdateRecordedWatchedStatus ( int RecordedId,
245  int chanid,
246  const QDateTime &recstarttsRaw,
247  bool watched)
248 {
249  if ((RecordedId <= 0) &&
250  (chanid <= 0 || !recstarttsRaw.isValid()))
251  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
252 
253  // TODO Should use RecordingInfo
254  ProgramInfo pi;
255  if (RecordedId > 0)
256  pi = ProgramInfo(RecordedId);
257  else
258  pi = ProgramInfo(chanid, recstarttsRaw.toUTC());
259 
260  if (pi.GetChanID() && pi.HasPathname())
261  {
262  pi.SaveWatched(watched);
263  return true;
264  }
265 
266  return false;
267 }
268 
270 //
272 
273 long Dvr::GetSavedBookmark( int RecordedId,
274  int chanid,
275  const QDateTime &recstarttsRaw,
276  const QString &offsettype )
277 {
278  if ((RecordedId <= 0) &&
279  (chanid <= 0 || !recstarttsRaw.isValid()))
280  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
281 
282  RecordingInfo ri;
283  if (RecordedId > 0)
284  ri = RecordingInfo(RecordedId);
285  else
286  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
287  uint64_t offset;
288  bool isend=true;
289  uint64_t position = ri.QueryBookmark();
290  if (offsettype.toLower() == "position"){
291  ri.QueryKeyFramePosition(&offset, position, isend);
292  return offset;
293  }
294  else if (offsettype.toLower() == "duration"){
295  ri.QueryKeyFrameDuration(&offset, position, isend);
296  return offset;
297  }
298  else
299  return position;
300 }
301 
303 //
305 
306 bool Dvr::SetSavedBookmark( int RecordedId,
307  int chanid,
308  const QDateTime &recstarttsRaw,
309  const QString &offsettype,
310  long Offset )
311 {
312  if ((RecordedId <= 0) &&
313  (chanid <= 0 || !recstarttsRaw.isValid()))
314  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
315 
316  if (Offset < 0)
317  throw QString("Offset must be >= 0.");
318 
319  RecordingInfo ri;
320  if (RecordedId > 0)
321  ri = RecordingInfo(RecordedId);
322  else
323  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
324  uint64_t position;
325  bool isend=true;
326  if (offsettype.toLower() == "position"){
327  if (!ri.QueryPositionKeyFrame(&position, Offset, isend))
328  return false;
329  }
330  else if (offsettype.toLower() == "duration"){
331  if (!ri.QueryDurationKeyFrame(&position, Offset, isend))
332  return false;
333  }
334  else
335  position = Offset;
336  ri.SaveBookmark(position);
337  return true;
338 }
339 
341 //
343 
345  int chanid,
346  const QDateTime &recstarttsRaw,
347  const QString &offsettype )
348 {
349  int marktype;
350  if ((RecordedId <= 0) &&
351  (chanid <= 0 || !recstarttsRaw.isValid()))
352  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
353 
354  RecordingInfo ri;
355  if (RecordedId > 0)
356  ri = RecordingInfo(RecordedId);
357  else
358  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
359 
360  DTC::CutList* pCutList = new DTC::CutList();
361  if (offsettype == "Position")
362  marktype = 1;
363  else if (offsettype == "Duration")
364  marktype = 2;
365  else
366  marktype = 0;
367 
368  FillCutList(pCutList, &ri, marktype);
369 
370  return pCutList;
371 }
372 
374 //
376 
378  int chanid,
379  const QDateTime &recstarttsRaw,
380  const QString &offsettype )
381 {
382  int marktype;
383  if ((RecordedId <= 0) &&
384  (chanid <= 0 || !recstarttsRaw.isValid()))
385  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
386 
387  RecordingInfo ri;
388  if (RecordedId > 0)
389  ri = RecordingInfo(RecordedId);
390  else
391  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
392 
393  DTC::CutList* pCutList = new DTC::CutList();
394  if (offsettype == "Position")
395  marktype = 1;
396  else if (offsettype == "Duration")
397  marktype = 2;
398  else
399  marktype = 0;
400 
401  FillCommBreak(pCutList, &ri, marktype);
402 
403  return pCutList;
404 }
405 
407 //
409 
411  int nCount )
412 {
413  pginfolist_t infoList;
414 
415  if (expirer)
416  expirer->GetAllExpiring( infoList );
417 
418  // ----------------------------------------------------------------------
419  // Build Response
420  // ----------------------------------------------------------------------
421 
422  DTC::ProgramList *pPrograms = new DTC::ProgramList();
423 
424  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)infoList.size() ) : 0;
425  nCount = (nCount > 0) ? min( nCount, (int)infoList.size() ) : infoList.size();
426  int nEndIndex = min((nStartIndex + nCount), (int)infoList.size() );
427 
428  for( int n = nStartIndex; n < nEndIndex; n++)
429  {
430  ProgramInfo *pInfo = infoList[ n ];
431 
432  if (pInfo != NULL)
433  {
434  DTC::Program *pProgram = pPrograms->AddNewProgram();
435 
436  FillProgramInfo( pProgram, pInfo, true );
437 
438  delete pInfo;
439  }
440  }
441 
442  // ----------------------------------------------------------------------
443 
444  pPrograms->setStartIndex ( nStartIndex );
445  pPrograms->setCount ( nCount );
446  pPrograms->setTotalAvailable( infoList.size() );
447  pPrograms->setAsOf ( MythDate::current() );
448  pPrograms->setVersion ( MYTH_BINARY_VERSION );
449  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
450 
451  return pPrograms;
452 }
453 
455 //
457 
459 {
460 
461  DTC::EncoderList* pList = new DTC::EncoderList();
462 
463  QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo();
464  QMap<int, EncoderLink *>::Iterator iter = tvList.begin();
465 
466  for (; iter != tvList.end(); ++iter)
467  {
468  EncoderLink *elink = *iter;
469 
470  if (elink != NULL)
471  {
472  DTC::Encoder *pEncoder = pList->AddNewEncoder();
473 
474  pEncoder->setId ( elink->GetInputID() );
475  pEncoder->setState ( elink->GetState() );
476  pEncoder->setLocal ( elink->IsLocal() );
477  pEncoder->setConnected ( elink->IsConnected() );
478  pEncoder->setSleepStatus ( elink->GetSleepStatus() );
479  // pEncoder->setLowOnFreeSpace( elink->isLowOnFreeSpace());
480 
481  if (pEncoder->Local())
482  pEncoder->setHostName( gCoreContext->GetHostName() );
483  else
484  pEncoder->setHostName( elink->GetHostName() );
485 
486  QList<InputInfo>::iterator it = inputInfoList.begin();
487  for (; it < inputInfoList.end(); ++it)
488  {
489  InputInfo inputInfo = *it;
490  if (inputInfo.inputid == static_cast<uint>(elink->GetInputID()))
491  {
492  DTC::Input *input = pEncoder->AddNewInput();
493  FillInputInfo(input, inputInfo);
494  }
495  }
496 
497  switch ( pEncoder->State() )
498  {
502  {
503  ProgramInfo *pInfo = elink->GetRecording();
504 
505  if (pInfo)
506  {
507  DTC::Program *pProgram = pEncoder->Recording();
508 
509  FillProgramInfo( pProgram, pInfo, true, true );
510 
511  delete pInfo;
512  }
513 
514  break;
515  }
516 
517  default:
518  break;
519  }
520  }
521  }
522  return pList;
523 }
524 
526 //
528 
530 {
531  DTC::InputList *pList = new DTC::InputList();
532 
533  QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo();
534  QList<InputInfo>::iterator it = inputInfoList.begin();
535  for (; it < inputInfoList.end(); ++it)
536  {
537  InputInfo inputInfo = *it;
538  DTC::Input *input = pList->AddNewInput();
539  FillInputInfo(input, inputInfo);
540  }
541 
542  return pList;
543 }
544 
546 //
548 
549 QStringList Dvr::GetRecGroupList()
550 {
551  MSqlQuery query(MSqlQuery::InitCon());
552  query.prepare("SELECT recgroup FROM recgroups WHERE recgroup <> 'Deleted' "
553  "ORDER BY recgroup");
554 
555  QStringList result;
556  if (!query.exec())
557  {
558  MythDB::DBError("GetRecGroupList", query);
559  return result;
560  }
561 
562  while (query.next())
563  result << query.value(0).toString();
564 
565  return result;
566 }
567 
569 //
571 
573 {
575 }
576 
578 //
580 
582 {
583  return PlayGroup::GetNames();
584 }
585 
587 //
589 
591 {
593 
594  MSqlQuery query(MSqlQuery::InitCon());
595 
596  query.prepare("SELECT filterid, description, newruledefault "
597  "FROM recordfilter ORDER BY filterid");
598 
599  if (query.exec())
600  {
601  while (query.next())
602  {
603  DTC::RecRuleFilter* ruleFilter = filterList->AddNewRecRuleFilter();
604  ruleFilter->setId(query.value(0).toInt());
605  ruleFilter->setDescription(QObject::tr(query.value(1).toString()
606  .toUtf8().constData()));
607  }
608  }
609 
610  return filterList;
611 }
612 
614 //
616 
617 QStringList Dvr::GetTitleList(const QString& RecGroup)
618 {
619  MSqlQuery query(MSqlQuery::InitCon());
620 
621  QString querystr = "SELECT DISTINCT title FROM recorded "
622  "WHERE deletepending = 0";
623 
624  if (!RecGroup.isEmpty())
625  querystr += " AND recgroup = :RECGROUP";
626  else
627  querystr += " AND recgroup != 'Deleted'";
628 
629  querystr += " ORDER BY title";
630 
631  query.prepare(querystr);
632 
633  if (!RecGroup.isEmpty())
634  query.bindValue(":RECGROUP", RecGroup);
635 
636  QStringList result;
637  if (!query.exec())
638  {
639  MythDB::DBError("GetTitleList recorded", query);
640  return result;
641  }
642 
643  while (query.next())
644  result << query.value(0).toString();
645 
646  return result;
647 }
648 
650 //
652 
654 {
655  MSqlQuery query(MSqlQuery::InitCon());
656 
657  QString querystr = QString(
658  "SELECT title, inetref, count(title) as count "
659  " FROM recorded AS r "
660  " JOIN recgroups AS g ON r.recgroupid = g.recgroupid "
661  " WHERE g.recgroup != 'LiveTV' "
662  " AND r.deletepending = 0 "
663  " GROUP BY title, inetref "
664  " ORDER BY title");
665 
666  query.prepare(querystr);
667 
668  DTC::TitleInfoList *pTitleInfos = new DTC::TitleInfoList();
669  if (!query.exec())
670  {
671  MythDB::DBError("GetTitleList recorded", query);
672  return pTitleInfos;
673  }
674 
675  while (query.next())
676  {
677  DTC::TitleInfo *pTitleInfo = pTitleInfos->AddNewTitleInfo();
678 
679  pTitleInfo->setTitle(query.value(0).toString());
680  pTitleInfo->setInetref(query.value(1).toString());
681  pTitleInfo->setCount(query.value(2).toInt());
682  }
683 
684  return pTitleInfos;
685 }
686 
688 //
690 
692  int nCount,
693  bool bShowAll,
694  int nRecordId,
695  int nRecStatus )
696 {
697  RecordingList recordingList; // Auto-delete deque
698  RecList tmpList; // Standard deque, objects must be deleted
699 
700  if (nRecordId <= 0)
701  nRecordId = -1;
702 
703  // NOTE: Fetching this information directly from the schedule is
704  // significantly faster than using ProgramInfo::LoadFromScheduler()
705  Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
706  if (scheduler)
707  scheduler->GetAllPending(tmpList, nRecordId);
708 
709  // Sort the upcoming into only those which will record
710  RecList::iterator it = tmpList.begin();
711  for(; it < tmpList.end(); ++it)
712  {
713  if ((nRecStatus != 0) &&
714  ((*it)->GetRecordingStatus() != nRecStatus))
715  {
716  delete *it;
717  *it = NULL;
718  continue;
719  }
720 
721  if (!bShowAll && ((((*it)->GetRecordingStatus() >= RecStatus::Failing) &&
722  ((*it)->GetRecordingStatus() <= RecStatus::WillRecord)) ||
723  ((*it)->GetRecordingStatus() == RecStatus::Conflict)) &&
724  ((*it)->GetRecordingEndTime() > MythDate::current()))
725  {
726  recordingList.push_back(new RecordingInfo(**it));
727  }
728  else if (bShowAll &&
729  ((*it)->GetRecordingEndTime() > MythDate::current()))
730  {
731  recordingList.push_back(new RecordingInfo(**it));
732  }
733 
734  delete *it;
735  *it = NULL;
736  }
737 
738  // ----------------------------------------------------------------------
739  // Build Response
740  // ----------------------------------------------------------------------
741 
742  DTC::ProgramList *pPrograms = new DTC::ProgramList();
743 
744  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
745  nCount = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
746  int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
747 
748  for( int n = nStartIndex; n < nEndIndex; n++)
749  {
750  ProgramInfo *pInfo = recordingList[ n ];
751 
752  DTC::Program *pProgram = pPrograms->AddNewProgram();
753 
754  FillProgramInfo( pProgram, pInfo, true );
755  }
756 
757  // ----------------------------------------------------------------------
758 
759  pPrograms->setStartIndex ( nStartIndex );
760  pPrograms->setCount ( nCount );
761  pPrograms->setTotalAvailable( recordingList.size() );
762  pPrograms->setAsOf ( MythDate::current() );
763  pPrograms->setVersion ( MYTH_BINARY_VERSION );
764  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
765 
766  return pPrograms;
767 }
768 
770 //
772 
774  int nCount,
775  int nRecordId )
776 {
777  RecordingList recordingList; // Auto-delete deque
778  RecList tmpList; // Standard deque, objects must be deleted
779 
780  if (nRecordId <= 0)
781  nRecordId = -1;
782 
783  // NOTE: Fetching this information directly from the schedule is
784  // significantly faster than using ProgramInfo::LoadFromScheduler()
785  Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
786  if (scheduler)
787  scheduler->GetAllPending(tmpList, nRecordId);
788 
789  // Sort the upcoming into only those which are conflicts
790  RecList::iterator it = tmpList.begin();
791  for(; it < tmpList.end(); ++it)
792  {
793  if (((*it)->GetRecordingStatus() == RecStatus::Conflict) &&
794  ((*it)->GetRecordingStartTime() >= MythDate::current()))
795  {
796  recordingList.push_back(new RecordingInfo(**it));
797  }
798  delete *it;
799  *it = NULL;
800  }
801 
802  // ----------------------------------------------------------------------
803  // Build Response
804  // ----------------------------------------------------------------------
805 
806  DTC::ProgramList *pPrograms = new DTC::ProgramList();
807 
808  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
809  nCount = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
810  int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
811 
812  for( int n = nStartIndex; n < nEndIndex; n++)
813  {
814  ProgramInfo *pInfo = recordingList[ n ];
815 
816  DTC::Program *pProgram = pPrograms->AddNewProgram();
817 
818  FillProgramInfo( pProgram, pInfo, true );
819  }
820 
821  // ----------------------------------------------------------------------
822 
823  pPrograms->setStartIndex ( nStartIndex );
824  pPrograms->setCount ( nCount );
825  pPrograms->setTotalAvailable( recordingList.size() );
826  pPrograms->setAsOf ( MythDate::current() );
827  pPrograms->setVersion ( MYTH_BINARY_VERSION );
828  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
829 
830  return pPrograms;
831 }
832 
834  QString sTitle,
835  QString sSubtitle,
836  QString sDescription,
837  QString sCategory,
838  QDateTime recstarttsRaw,
839  QDateTime recendtsRaw,
840  QString sSeriesId,
841  QString sProgramId,
842  int nChanId,
843  QString sStation,
844  int nFindDay,
845  QTime tFindTime,
846  int nParentId,
847  bool bInactive,
848  uint nSeason,
849  uint nEpisode,
850  QString sInetref,
851  QString sType,
852  QString sSearchType,
853  int nRecPriority,
854  uint nPreferredInput,
855  int nStartOffset,
856  int nEndOffset,
857  QString sDupMethod,
858  QString sDupIn,
859  uint nFilter,
860  QString sRecProfile,
861  QString sRecGroup,
862  QString sStorageGroup,
863  QString sPlayGroup,
864  bool bAutoExpire,
865  int nMaxEpisodes,
866  bool bMaxNewest,
867  bool bAutoCommflag,
868  bool bAutoTranscode,
869  bool bAutoMetaLookup,
870  bool bAutoUserJob1,
871  bool bAutoUserJob2,
872  bool bAutoUserJob3,
873  bool bAutoUserJob4,
874  int nTranscoder)
875 {
876  QDateTime recstartts = recstarttsRaw.toUTC();
877  QDateTime recendts = recendtsRaw.toUTC();
878  RecordingRule rule;
879  rule.LoadTemplate("Default");
880 
881  if (sType.isEmpty())
882  sType = "single";
883 
884  if (sSearchType.isEmpty())
885  sSearchType = "none";
886 
887  if (sDupMethod.isEmpty())
888  sDupMethod = "subtitleanddescription";
889 
890  if (sDupIn.isEmpty())
891  sDupIn = "all";
892 
893  rule.m_title = sTitle;
894  rule.m_subtitle = sSubtitle;
895  rule.m_description = sDescription;
896 
897  rule.m_startdate = recstartts.date();
898  rule.m_starttime = recstartts.time();
899  rule.m_enddate = recendts.date();
900  rule.m_endtime = recendts.time();
901 
902  rule.m_type = recTypeFromString(sType);
903  rule.m_searchType = searchTypeFromString(sSearchType);
904  rule.m_dupMethod = dupMethodFromString(sDupMethod);
905  rule.m_dupIn = dupInFromString(sDupIn);
906 
907  if (sRecProfile.isEmpty())
908  sRecProfile = "Default";
909 
910  if (sRecGroup.isEmpty())
911  sRecGroup = "Default";
912 
913  if (sStorageGroup.isEmpty())
914  sStorageGroup = "Default";
915 
916  if (sPlayGroup.isEmpty())
917  sPlayGroup = "Default";
918 
919  rule.m_category = sCategory;
920  rule.m_seriesid = sSeriesId;
921  rule.m_programid = sProgramId;
922 
923  rule.m_channelid = nChanId;
924  rule.m_station = sStation;
925 
926  rule.m_findday = nFindDay;
927  rule.m_findtime = tFindTime;
928 
929  rule.m_recProfile = sRecProfile;
930  rule.m_recGroupID = RecordingInfo::GetRecgroupID(sRecGroup);
931  if (rule.m_recGroupID == 0)
933  rule.m_storageGroup = sStorageGroup;
934  rule.m_playGroup = sPlayGroup;
935 
936  rule.m_parentRecID = nParentId;
937  rule.m_isInactive = bInactive;
938 
939  rule.m_season = nSeason;
940  rule.m_episode = nEpisode;
941  rule.m_inetref = sInetref;
942 
943  rule.m_recPriority = nRecPriority;
944  rule.m_prefInput = nPreferredInput;
945  rule.m_startOffset = nStartOffset;
946  rule.m_endOffset = nEndOffset;
947  rule.m_filter = nFilter;
948 
949  rule.m_autoExpire = bAutoExpire;
950  rule.m_maxEpisodes = nMaxEpisodes;
951  rule.m_maxNewest = bMaxNewest;
952 
953  rule.m_autoCommFlag = bAutoCommflag;
954  rule.m_autoTranscode = bAutoTranscode;
955  rule.m_autoMetadataLookup = bAutoMetaLookup;
956 
957  rule.m_autoUserJob1 = bAutoUserJob1;
958  rule.m_autoUserJob2 = bAutoUserJob2;
959  rule.m_autoUserJob3 = bAutoUserJob3;
960  rule.m_autoUserJob4 = bAutoUserJob4;
961 
962  rule.m_transcoder = nTranscoder;
963 
964  QString msg;
965  if (!rule.IsValid(msg))
966  throw msg;
967 
968  rule.Save();
969 
970  uint recid = rule.m_recordID;
971 
972  return recid;
973 }
974 
976  QString sTitle,
977  QString sSubtitle,
978  QString sDescription,
979  QString sCategory,
980  QDateTime dStartTimeRaw,
981  QDateTime dEndTimeRaw,
982  QString sSeriesId,
983  QString sProgramId,
984  int nChanId,
985  QString sStation,
986  int nFindDay,
987  QTime tFindTime,
988  bool bInactive,
989  uint nSeason,
990  uint nEpisode,
991  QString sInetref,
992  QString sType,
993  QString sSearchType,
994  int nRecPriority,
995  uint nPreferredInput,
996  int nStartOffset,
997  int nEndOffset,
998  QString sDupMethod,
999  QString sDupIn,
1000  uint nFilter,
1001  QString sRecProfile,
1002  QString sRecGroup,
1003  QString sStorageGroup,
1004  QString sPlayGroup,
1005  bool bAutoExpire,
1006  int nMaxEpisodes,
1007  bool bMaxNewest,
1008  bool bAutoCommflag,
1009  bool bAutoTranscode,
1010  bool bAutoMetaLookup,
1011  bool bAutoUserJob1,
1012  bool bAutoUserJob2,
1013  bool bAutoUserJob3,
1014  bool bAutoUserJob4,
1015  int nTranscoder)
1016 {
1017  if (nRecordId <= 0 )
1018  throw QString("Record ID is invalid.");
1019 
1020  RecordingRule pRule;
1021  pRule.m_recordID = nRecordId;
1022  pRule.Load();
1023 
1024  if (!pRule.IsLoaded())
1025  throw QString("Record ID does not exist.");
1026 
1027  QDateTime recstartts = dStartTimeRaw.toUTC();
1028  QDateTime recendts = dEndTimeRaw.toUTC();
1029 
1030  pRule.m_isInactive = bInactive;
1031  if (sType.isEmpty())
1032  sType = "single";
1033 
1034  if (sSearchType.isEmpty())
1035  sSearchType = "none";
1036 
1037  if (sDupMethod.isEmpty())
1038  sDupMethod = "subtitleanddescription";
1039 
1040  if (sDupIn.isEmpty())
1041  sDupIn = "all";
1042 
1043  pRule.m_type = recTypeFromString(sType);
1044  pRule.m_searchType = searchTypeFromString(sSearchType);
1045  pRule.m_dupMethod = dupMethodFromString(sDupMethod);
1046  pRule.m_dupIn = dupInFromString(sDupIn);
1047 
1048  if (sRecProfile.isEmpty())
1049  sRecProfile = "Default";
1050 
1051  if (sRecGroup.isEmpty())
1052  sRecGroup = "Default";
1053 
1054  if (sStorageGroup.isEmpty())
1055  sStorageGroup = "Default";
1056 
1057  if (sPlayGroup.isEmpty())
1058  sPlayGroup = "Default";
1059 
1060  if (!sTitle.isEmpty())
1061  pRule.m_title = sTitle;
1062 
1063  if (!sSubtitle.isEmpty())
1064  pRule.m_subtitle = sSubtitle;
1065 
1066  if(!sDescription.isEmpty())
1067  pRule.m_description = sDescription;
1068 
1069  if (!sCategory.isEmpty())
1070  pRule.m_category = sCategory;
1071 
1072  if (!sSeriesId.isEmpty())
1073  pRule.m_seriesid = sSeriesId;
1074 
1075  if (!sProgramId.isEmpty())
1076  pRule.m_programid = sProgramId;
1077 
1078  if (nChanId)
1079  pRule.m_channelid = nChanId;
1080  if (!sStation.isEmpty())
1081  pRule.m_station = sStation;
1082 
1083  pRule.m_startdate = recstartts.date();
1084  pRule.m_starttime = recstartts.time();
1085  pRule.m_enddate = recendts.date();
1086  pRule.m_endtime = recendts.time();
1087 
1088  pRule.m_findday = nFindDay;
1089  pRule.m_findtime = tFindTime;
1090 
1091  pRule.m_recProfile = sRecProfile;
1092  pRule.m_recGroupID = RecordingInfo::GetRecgroupID(sRecGroup);
1093  if (pRule.m_recGroupID == 0)
1095  pRule.m_storageGroup = sStorageGroup;
1096  pRule.m_playGroup = sPlayGroup;
1097 
1098  pRule.m_isInactive = bInactive;
1099 
1100  pRule.m_season = nSeason;
1101  pRule.m_episode = nEpisode;
1102  pRule.m_inetref = sInetref;
1103 
1104  pRule.m_recPriority = nRecPriority;
1105  pRule.m_prefInput = nPreferredInput;
1106  pRule.m_startOffset = nStartOffset;
1107  pRule.m_endOffset = nEndOffset;
1108  pRule.m_filter = nFilter;
1109 
1110  pRule.m_autoExpire = bAutoExpire;
1111  pRule.m_maxEpisodes = nMaxEpisodes;
1112  pRule.m_maxNewest = bMaxNewest;
1113 
1114  pRule.m_autoCommFlag = bAutoCommflag;
1115  pRule.m_autoTranscode = bAutoTranscode;
1116  pRule.m_autoMetadataLookup = bAutoMetaLookup;
1117 
1118  pRule.m_autoUserJob1 = bAutoUserJob1;
1119  pRule.m_autoUserJob2 = bAutoUserJob2;
1120  pRule.m_autoUserJob3 = bAutoUserJob3;
1121  pRule.m_autoUserJob4 = bAutoUserJob4;
1122 
1123  pRule.m_transcoder = nTranscoder;
1124 
1125  QString msg;
1126  if (!pRule.IsValid(msg))
1127  throw msg;
1128 
1129  bool bResult = pRule.Save();
1130 
1131  return bResult;
1132 }
1133 
1135 {
1136  bool bResult = false;
1137 
1138  if (nRecordId <= 0 )
1139  throw QString("Record ID does not exist.");
1140 
1141  RecordingRule pRule;
1142  pRule.m_recordID = nRecordId;
1143 
1144  bResult = pRule.Delete();
1145 
1146  return bResult;
1147 }
1148 
1149 bool Dvr::AddDontRecordSchedule(int nChanId, const QDateTime &dStartTime,
1150  bool bNeverRecord)
1151 {
1152  bool bResult = true;
1153 
1154  if (nChanId <= 0 || !dStartTime.isValid())
1155  throw QString("Program does not exist.");
1156 
1157  ProgramInfo *pi = LoadProgramFromProgram(nChanId, dStartTime.toUTC());
1158 
1159  if (!pi)
1160  throw QString("Program does not exist.");
1161 
1162  // Why RecordingInfo instead of ProgramInfo? Good question ...
1163  RecordingInfo recInfo = RecordingInfo(*pi);
1164 
1165  delete pi;
1166 
1167  if (bNeverRecord)
1168  {
1169  recInfo.ApplyNeverRecord();
1170  }
1171  else
1173 
1174  return bResult;
1175 }
1176 
1178  int nCount,
1179  const QString &Sort,
1180  bool Descending )
1181 {
1182  Scheduler::SchedSortColumn sortingColumn;
1183  if (Sort.toLower() == "lastrecorded")
1184  sortingColumn = Scheduler::kSortLastRecorded;
1185  else if (Sort.toLower() == "nextrecording")
1186  sortingColumn = Scheduler::kSortNextRecording;
1187  else if (Sort.toLower() == "title")
1188  sortingColumn = Scheduler::kSortTitle;
1189  else if (Sort.toLower() == "priority")
1190  sortingColumn = Scheduler::kSortPriority;
1191  else if (Sort.toLower() == "type")
1192  sortingColumn = Scheduler::kSortType;
1193  else
1194  sortingColumn = Scheduler::kSortTitle;
1195 
1196  RecList recList;
1197  Scheduler::GetAllScheduled(recList, sortingColumn, !Descending);
1198 
1199  // ----------------------------------------------------------------------
1200  // Build Response
1201  // ----------------------------------------------------------------------
1202 
1203  DTC::RecRuleList *pRecRules = new DTC::RecRuleList();
1204 
1205  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recList.size() ) : 0;
1206  nCount = (nCount > 0) ? min( nCount, (int)recList.size() ) : recList.size();
1207  int nEndIndex = min((nStartIndex + nCount), (int)recList.size() );
1208 
1209  for( int n = nStartIndex; n < nEndIndex; n++)
1210  {
1211  RecordingInfo *info = recList[n];
1212 
1213  if (info != NULL)
1214  {
1215  DTC::RecRule *pRecRule = pRecRules->AddNewRecRule();
1216 
1217  FillRecRuleInfo( pRecRule, info->GetRecordingRule() );
1218  }
1219  }
1220 
1221  // ----------------------------------------------------------------------
1222 
1223  pRecRules->setStartIndex ( nStartIndex );
1224  pRecRules->setCount ( nCount );
1225  pRecRules->setTotalAvailable( recList.size() );
1226  pRecRules->setAsOf ( MythDate::current() );
1227  pRecRules->setVersion ( MYTH_BINARY_VERSION );
1228  pRecRules->setProtoVer ( MYTH_PROTO_VERSION );
1229 
1230  while (!recList.empty())
1231  {
1232  delete recList.back();
1233  recList.pop_back();
1234  }
1235 
1236  return pRecRules;
1237 }
1238 
1240  QString sTemplate,
1241  int nRecordedId,
1242  int nChanId,
1243  QDateTime dStartTimeRaw,
1244  bool bMakeOverride )
1245 {
1246  RecordingRule rule;
1247  QDateTime dStartTime = dStartTimeRaw.toUTC();
1248 
1249  if (nRecordId > 0)
1250  {
1251  rule.m_recordID = nRecordId;
1252  if (!rule.Load())
1253  throw QString("Record ID does not exist.");
1254  }
1255  else if (!sTemplate.isEmpty())
1256  {
1257  if (!rule.LoadTemplate(sTemplate))
1258  throw QString("Template does not exist.");
1259  }
1260  else if (nRecordedId > 0) // Loads from the Recorded/Recorded Program Table
1261  {
1262  // Despite the use of ProgramInfo, this only applies to Recordings.
1263  ProgramInfo recInfo(nRecordedId);
1264  if (!rule.LoadByProgram(&recInfo))
1265  throw QString("Recording does not exist");
1266  }
1267  else if (nChanId > 0 && dStartTime.isValid()) // Loads from Program Table, should NOT be used with recordings
1268  {
1269  // Despite the use of RecordingInfo, this only applies to programs in the
1270  // present or future, not to recordings? Confused yet?
1272  RecordingInfo info(nChanId, dStartTime, false, 0, &status);
1273  if (status != RecordingInfo::kFoundProgram)
1274  throw QString("Program does not exist.");
1275  RecordingRule *pRule = info.GetRecordingRule();
1276  if (bMakeOverride && rule.m_type != kSingleRecord &&
1277  rule.m_type != kOverrideRecord && rule.m_type != kDontRecord)
1278  pRule->MakeOverride();
1279  rule = *pRule;
1280  }
1281  else
1282  {
1283  throw QString("Invalid request.");
1284  }
1285 
1286  DTC::RecRule *pRecRule = new DTC::RecRule();
1287  FillRecRuleInfo( pRecRule, &rule );
1288 
1289  return pRecRule;
1290 }
1291 
1293 {
1294  bool bResult = false;
1295 
1296  if (nRecordId <= 0 )
1297  throw QString("Record ID appears invalid.");
1298 
1299  RecordingRule pRule;
1300  pRule.m_recordID = nRecordId;
1301  pRule.Load();
1302 
1303  if (pRule.IsLoaded())
1304  {
1305  pRule.m_isInactive = false;
1306  bResult = pRule.Save();
1307  }
1308 
1309  return bResult;
1310 }
1311 
1313 {
1314  bool bResult = false;
1315 
1316  if (nRecordId <= 0 )
1317  throw QString("Record ID appears invalid.");
1318 
1319  RecordingRule pRule;
1320  pRule.m_recordID = nRecordId;
1321  pRule.Load();
1322 
1323  if (pRule.IsLoaded())
1324  {
1325  pRule.m_isInactive = true;
1326  bResult = pRule.Save();
1327  }
1328 
1329  return bResult;
1330 }
1331 
1333 {
1334  RecStatus::Type type = static_cast<RecStatus::Type>(RecStatus);
1335  return RecStatus::toString(type);
1336 }
1337 
1338 QString Dvr::RecStatusToDescription(int RecStatus, int recType,
1339  const QDateTime &StartTime)
1340 {
1341  //if (!StartTime.isValid())
1342  // throw QString("StartTime appears invalid.");
1343  RecStatus::Type rsType = static_cast<RecStatus::Type>(RecStatus);
1344  RecordingType recordingType = static_cast<RecordingType>(recType);
1345  return RecStatus::toDescription(rsType, recordingType, StartTime);
1346 }
1347 
1348 QString Dvr::RecTypeToString(QString recType)
1349 {
1350  bool ok;
1351  RecordingType enumType = static_cast<RecordingType>(recType.toInt(&ok, 10));
1352  if (ok)
1353  return toString(enumType);
1354  // RecordingType type = static_cast<RecordingType>(recType);
1355  return toString(recTypeFromString(recType));
1356 }
1357 
1358 QString Dvr::RecTypeToDescription(QString recType)
1359 {
1360  bool ok;
1361  RecordingType enumType = static_cast<RecordingType>(recType.toInt(&ok, 10));
1362  if (ok)
1363  return toDescription(enumType);
1364  // RecordingType type = static_cast<RecordingType>(recType);
1365  return toDescription(recTypeFromString(recType));
1366 }
1367 
1368 QString Dvr::DupInToString(QString DupIn)
1369 {
1370  // RecordingDupInType type= static_cast<RecordingDupInType>(DupIn);
1371  // return toString(type);
1372  return toString(dupInFromString(DupIn));
1373 }
1374 
1375 QString Dvr::DupInToDescription(QString DupIn)
1376 {
1377  // RecordingDupInType type= static_cast<RecordingDupInType>(DupIn);
1378  //return toDescription(type);
1379  return toDescription(dupInFromString(DupIn));
1380 }
1381 
1382 QString Dvr::DupMethodToString(QString DupMethod)
1383 {
1384  // RecordingDupMethodType method = static_cast<RecordingDupMethodType>(DupMethod);
1385  return toString(dupMethodFromString(DupMethod));
1386 }
1387 
1388 QString Dvr::DupMethodToDescription(QString DupMethod)
1389 {
1390  // RecordingDupMethodType method = static_cast<RecordingDupMethodType>(DupMethod);
1391  return toDescription(dupMethodFromString(DupMethod));
1392 }
QString RecStatusToString(int RecStatus)
Definition: dvr.cpp:1332
QString m_subtitle
Definition: recordingrule.h:76
bool DeleteRecording(int RecordedId, int ChanId, const QDateTime &StartTime, bool ForceDelete, bool AllowRerecord)
Definition: dvr.cpp:178
QTime m_findtime
Day of the week for once per week etc.
Definition: recordingrule.h:95
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:785
MythScheduler * GetScheduler(void)
DTC::ProgramList * GetConflictList(int StartIndex, int Count, int RecordId)
Definition: dvr.cpp:773
Program * AddNewProgram()
Definition: programList.h:86
void bindValue(const QString &placeholder, const QVariant &val)
Definition: mythdbcon.cpp:884
AutoExpire * expirer
QString m_programid
Definition: recordingrule.h:88
DTC::RecRuleFilterList * GetRecRuleFilterList()
Definition: dvr.cpp:590
DTC::TitleInfoList * GetTitleInfoList()
Definition: dvr.cpp:653
SchedSortColumn
Definition: scheduler.h:70
ProgramInfo * LoadProgramFromProgram(const uint chanid, const QDateTime &starttime)
Watching LiveTV is the state for when we are watching a recording and the user has control over the c...
Definition: tv.h:63
void push_back(T info)
bool UpdateRecordedWatchedStatus(int RecordedId, int ChanId, const QDateTime &StartTime, bool Watched)
Definition: dvr.cpp:244
QString toDescription(RecordingType rectype)
Converts "rectype" into a human readable description.
bool LoadByProgram(const ProgramInfo *proginfo)
void FillProgramInfo(DTC::Program *pProgram, ProgramInfo *pInfo, bool bIncChannel, bool bDetails, bool bIncCast)
Definition: serviceUtil.cpp:44
bool Delete(bool sendSig=true)
bool IsLoaded() const
Definition: recordingrule.h:55
RecSearchType searchTypeFromString(QString type)
QStringList GetPlayGroupList()
Definition: dvr.cpp:581
QVariant value(int i) const
Definition: mythdbcon.h:182
bool IsDeletePending(void) const
Definition: programinfo.h:463
DTC::CutList * GetRecordedCutList(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:344
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
void FillRecRuleInfo(DTC::RecRule *pRecRule, RecordingRule *pRule)
RecordingRule * GetRecordingRule(void)
Returns the "record" field, creating it if necessary.
TitleInfo * AddNewTitleInfo()
Definition: titleInfoList.h:57
RecordingType recTypeFromString(QString type)
static QString toDescription(Type, RecordingType, const QDateTime &recstartts)
Converts "recstatus" into a long human readable description.
QString m_storageGroup
static QStringList getRecordingsGroups(void)
QString m_station
Definition: recordingrule.h:93
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:33
QString DupMethodToDescription(QString DupMethod)
Definition: dvr.cpp:1388
Watching Recording is the state for when we are watching an in progress recording, but the user does not have control over the channel and recorder to use.
Definition: tv.h:80
unsigned int uint
Definition: compat.h:136
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QString DupInToString(QString DupIn)
Definition: dvr.cpp:1368
AutoDeleteDeque< ProgramInfo * > ProgramList
Definition: programinfo.h:28
DTC::CutList * GetRecordedCommBreak(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:377
RecordingType m_type
Definition: recordingrule.h:99
RecordingDupMethodType m_dupMethod
DTC::RecRuleList * GetRecordScheduleList(int StartIndex, int Count, const QString &Sort, bool Descending)
Definition: dvr.cpp:1177
bool QueryKeyFrameDuration(uint64_t *, uint64_t keyframe, bool backwards) const
DTC::ProgramList * GetExpiringList(int StartIndex, int Count)
Definition: dvr.cpp:410
bool SetSavedBookmark(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType, long Offset)
Definition: dvr.cpp:306
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:382
static uint GetRecgroupID(const QString &recGroup)
Temporary helper during transition from string to ID.
size_t size(void) const
QStringList GetRecStorageGroupList()
Definition: dvr.cpp:572
bool Save(bool sendSig=true)
uint64_t QueryBookmark(void) const
Gets any bookmark position in database, unless the ignore bookmark flag is set.
RecordingDupMethodType dupMethodFromString(QString type)
Holds information on recordings and videos.
Definition: programinfo.h:65
void ApplyRecordStateChange(RecordingType newstate, bool save=true)
Sets RecordingType of "record", creating "record" if it does not exist.
bool RemoveRecorded(int RecordedId, int ChanId, const QDateTime &StartTime, bool ForceDelete, bool AllowRerecord)
Definition: dvr.cpp:169
voidpf uLong offset
Definition: ioapi.h:142
Recording Only is a TVRec only state for when we are recording a program, but there is no one current...
Definition: tv.h:84
This class is used as a container for messages.
Definition: mythevent.h:15
RecRuleFilter * AddNewRecRuleFilter()
static QString toString(Type, uint id)
static void GetAllScheduled(QStringList &strList, SchedSortColumn sortBy=kSortTitle, bool ascending=true)
Returns all scheduled programs serialized into a QStringList.
Definition: scheduler.cpp:1812
static QMap< QString, uint32_t > QueryInUseMap(void)
bool m_autoMetadataLookup
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
int m_findday
callsign?
Definition: recordingrule.h:94
QMap< int, EncoderLink * > tvList
QString m_playGroup
void FillCutList(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
QString DupMethodToString(QString DupMethod)
Definition: dvr.cpp:1382
long GetSavedBookmark(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:273
Input * AddNewInput()
Definition: inputList.h:59
QString m_description
Definition: recordingrule.h:77
void SaveBookmark(uint64_t frame)
TODO Move to RecordingInfo.
QString RecStatusToDescription(int RecStatus, int RecType, const QDateTime &StartTime)
Definition: dvr.cpp:1338
bool GetAllPending(RecList &retList, int recRuleId=0) const
Definition: scheduler.cpp:1718
QString RecTypeToString(QString RecType)
Definition: dvr.cpp:1348
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:542
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:31
static QList< InputInfo > GetAllInputInfo()
Definition: cardutil.cpp:995
void GetAllExpiring(QStringList &strList)
Gets the full list of programs that can expire in expiration order.
Definition: autoexpire.cpp:841
uint inputid
unique key in DB for this input
Definition: inputinfo.h:72
QString m_seriesid
Definition: recordingrule.h:87
int m_parentRecID
Unique Recording Rule ID.
Definition: recordingrule.h:70
RecordingDupInType m_dupIn
QString RecTypeToDescription(QString RecType)
Definition: dvr.cpp:1358
void dispatch(const MythEvent &event)
QString m_inetref
Definition: recordingrule.h:89
bool AddDontRecordSchedule(int ChanId, const QDateTime &StartTime, bool NeverRecord)
Definition: dvr.cpp:1149
Encoder * AddNewEncoder()
Definition: encoderList.h:59
DTC::ProgramList * GetUpcomingList(int StartIndex, int Count, bool ShowAll, int RecordId, int RecStatus)
Definition: dvr.cpp:691
void FillCommBreak(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:810
RecRule * AddNewRecRule()
Definition: recRuleList.h:72
QString GetRecordingGroup(void) const
Definition: programinfo.h:397
DTC::RecRule * GetRecordSchedule(uint RecordId, QString Template, int nRecordedId, int ChanId, QDateTime StartTime, bool MakeOverride)
Definition: dvr.cpp:1239
bool UnDeleteRecording(int RecordedId, int ChanId, const QDateTime &StartTime)
Definition: dvr.cpp:213
QString m_title
Recording rule is enabled?
Definition: recordingrule.h:75
static const char * toString(OMX_AUDIO_DDPBITSTREAMID id)
Used to expire recordings to make space for new recordings.
Definition: autoexpire.h:62
void ApplyNeverRecord(void)
Set this program to never be recorded by inserting &#39;history&#39; for it into the database with a status o...
QString DupInToDescription(QString DupIn)
Definition: dvr.cpp:1375
bool QueryDurationKeyFrame(uint64_t *, uint64_t duration, bool backwards) const
DTC::Program * GetRecorded(int RecordedId, int ChanId, const QDateTime &StartTime)
Definition: dvr.cpp:145
static QMap< QString, bool > QueryJobsRunning(int type)
bool QueryKeyFramePosition(uint64_t *, uint64_t keyframe, bool backwards) const
QString m_recProfile
bool HasPathname(void) const
Definition: programinfo.h:338
GLint GLenum GLsizei GLint GLenum GLenum type
void SaveWatched(bool watchedFlag)
Set "watched" field in recorded/videometadata to "watchedFlag".
DTC::EncoderList * GetEncoderList()
Definition: dvr.cpp:458
static QStringList GetNames(void)
Definition: playgroup.cpp:173
virtual QMap< QString, ProgramInfo * > GetRecording(void) const =0
bool RemoveRecordSchedule(uint RecordId)
Definition: dvr.cpp:1134
bool Load(bool asTemplate=false)
unsigned m_filter
QString GetStorageGroup(void) const
Definition: programinfo.h:400
QString m_category
Definition: recordingrule.h:80
bool LoadFromRecorded(ProgramList &destination, bool possiblyInProgressRecordingsOnly, const QMap< QString, uint32_t > &inUseMap, const QMap< QString, bool > &isJobRunning, const QMap< QString, ProgramInfo * > &recMap, int sort)
bool LoadTemplate(QString category, QString categoryType="Default")
DTC::InputList * GetInputList()
Definition: dvr.cpp:529
DTC::ProgramList * GetRecordedList(bool Descending, int StartIndex, int Count, const QString &TitleRegEx, const QString &RecGroup, const QString &StorageGroup)
Definition: dvr.cpp:62
std::deque< RecordingInfo * > RecList
Definition: mythscheduler.h:10
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:610
vector< ProgramInfo * > pginfolist_t
Definition: autoexpire.h:23
QStringList GetRecGroupList()
Definition: dvr.cpp:549
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:350
RecordingDupInType dupInFromString(QString type)
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:181
bool QueryPositionKeyFrame(uint64_t *, uint64_t position, bool backwards) const
void FillInputInfo(DTC::Input *input, InputInfo inputInfo)
bool MakeOverride(void)
bool DisableRecordSchedule(uint RecordId)
Definition: dvr.cpp:1312
QString GetHostName(void)
bool UpdateRecordSchedule(uint RecordId, QString Title, QString Subtitle, QString Description, QString Category, QDateTime StartTime, QDateTime EndTime, QString SeriesId, QString ProgramId, int ChanId, QString Station, int FindDay, QTime FindTime, bool Inactive, uint Season, uint Episode, QString Inetref, QString Type, QString SearchType, int RecPriority, uint PreferredInput, int StartOffset, int EndOffset, QString DupMethod, QString DupIn, uint Filter, QString RecProfile, QString RecGroup, QString StorageGroup, QString PlayGroup, bool AutoExpire, int MaxEpisodes, bool MaxNewest, bool AutoCommflag, bool AutoTranscode, bool AutoMetaLookup, bool AutoUserJob1, bool AutoUserJob2, bool AutoUserJob3, bool AutoUserJob4, int Transcoder)
Definition: dvr.cpp:975
Default UTC.
Definition: mythdate.h:14
bool EnableRecordSchedule(uint RecordId)
Definition: dvr.cpp:1292
QStringList GetTitleList(const QString &RecGroup)
Definition: dvr.cpp:617
QString GetTitle(void) const
Definition: programinfo.h:341
RecSearchType m_searchType
uint AddRecordSchedule(QString Title, QString Subtitle, QString Description, QString Category, QDateTime StartTime, QDateTime EndTime, QString SeriesId, QString ProgramId, int ChanId, QString Station, int FindDay, QTime FindTime, int ParentId, bool Inactive, uint Season, uint Episode, QString Inetref, QString Type, QString SearchType, int RecPriority, uint PreferredInput, int StartOffset, int EndOffset, QString DupMethod, QString DupIn, uint Filter, QString RecProfile, QString RecGroup, QString StorageGroup, QString PlayGroup, bool AutoExpire, int MaxEpisodes, bool MaxNewest, bool AutoCommflag, bool AutoTranscode, bool AutoMetaLookup, bool AutoUserJob1, bool AutoUserJob2, bool AutoUserJob3, bool AutoUserJob4, int Transcoder)
Definition: dvr.cpp:833
bool IsValid(QString &text)