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::StopRecording(int RecordedId)
245 {
246  if (RecordedId <= 0)
247  throw QString("Recorded ID is invalid.");
248 
249  RecordingInfo ri = RecordingInfo(RecordedId);
250 
251  if (ri.GetChanID())
252  {
253  QString cmd = QString("STOP_RECORDING %1 %2")
254  .arg(ri.GetChanID())
256  MythEvent me(cmd);
257 
258  gCoreContext->dispatch(me);
259  return true;
260  }
261  else
262  throw QString("RecordID %1 not found").arg(RecordedId);
263 
264  return false;
265 }
266 
268 //
270 
271 bool Dvr::ReactivateRecording(int RecordedId)
272 {
273  if (RecordedId <= 0)
274  throw QString("Recorded ID is invalid.");
275 
276  RecordingInfo ri = RecordingInfo(RecordedId);
277 
278  ri.ReactivateRecording();
279 
280  return true;
281 }
282 
284 //
286 
288 {
289  QString cmd = QString("RESCHEDULE_RECORDINGS");
290  MythEvent me(cmd);
291 
292  gCoreContext->dispatch(me);
293  return true;
294 }
295 
297 //
299 
300 bool Dvr::UpdateRecordedWatchedStatus ( int RecordedId,
301  int chanid,
302  const QDateTime &recstarttsRaw,
303  bool watched)
304 {
305  if ((RecordedId <= 0) &&
306  (chanid <= 0 || !recstarttsRaw.isValid()))
307  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
308 
309  // TODO Should use RecordingInfo
310  ProgramInfo pi;
311  if (RecordedId > 0)
312  pi = ProgramInfo(RecordedId);
313  else
314  pi = ProgramInfo(chanid, recstarttsRaw.toUTC());
315 
316  if (pi.GetChanID() && pi.HasPathname())
317  {
318  pi.SaveWatched(watched);
319  return true;
320  }
321 
322  return false;
323 }
324 
326 //
328 
329 long Dvr::GetSavedBookmark( int RecordedId,
330  int chanid,
331  const QDateTime &recstarttsRaw,
332  const QString &offsettype )
333 {
334  if ((RecordedId <= 0) &&
335  (chanid <= 0 || !recstarttsRaw.isValid()))
336  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
337 
338  RecordingInfo ri;
339  if (RecordedId > 0)
340  ri = RecordingInfo(RecordedId);
341  else
342  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
343  uint64_t offset;
344  bool isend=true;
345  uint64_t position = ri.QueryBookmark();
346  if (offsettype.toLower() == "position"){
347  ri.QueryKeyFramePosition(&offset, position, isend);
348  return offset;
349  }
350  else if (offsettype.toLower() == "duration"){
351  ri.QueryKeyFrameDuration(&offset, position, isend);
352  return offset;
353  }
354  else
355  return position;
356 }
357 
359 //
361 
362 bool Dvr::SetSavedBookmark( int RecordedId,
363  int chanid,
364  const QDateTime &recstarttsRaw,
365  const QString &offsettype,
366  long Offset )
367 {
368  if ((RecordedId <= 0) &&
369  (chanid <= 0 || !recstarttsRaw.isValid()))
370  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
371 
372  if (Offset < 0)
373  throw QString("Offset must be >= 0.");
374 
375  RecordingInfo ri;
376  if (RecordedId > 0)
377  ri = RecordingInfo(RecordedId);
378  else
379  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
380  uint64_t position;
381  bool isend=true;
382  if (offsettype.toLower() == "position"){
383  if (!ri.QueryPositionKeyFrame(&position, Offset, isend))
384  return false;
385  }
386  else if (offsettype.toLower() == "duration"){
387  if (!ri.QueryDurationKeyFrame(&position, Offset, isend))
388  return false;
389  }
390  else
391  position = Offset;
392  ri.SaveBookmark(position);
393  return true;
394 }
395 
397 //
399 
401  int chanid,
402  const QDateTime &recstarttsRaw,
403  const QString &offsettype )
404 {
405  int marktype;
406  if ((RecordedId <= 0) &&
407  (chanid <= 0 || !recstarttsRaw.isValid()))
408  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
409 
410  RecordingInfo ri;
411  if (RecordedId > 0)
412  ri = RecordingInfo(RecordedId);
413  else
414  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
415 
416  DTC::CutList* pCutList = new DTC::CutList();
417  if (offsettype == "Position")
418  marktype = 1;
419  else if (offsettype == "Duration")
420  marktype = 2;
421  else
422  marktype = 0;
423 
424  FillCutList(pCutList, &ri, marktype);
425 
426  return pCutList;
427 }
428 
430 //
432 
434  int chanid,
435  const QDateTime &recstarttsRaw,
436  const QString &offsettype )
437 {
438  int marktype;
439  if ((RecordedId <= 0) &&
440  (chanid <= 0 || !recstarttsRaw.isValid()))
441  throw QString("Recorded ID or Channel ID and StartTime appears invalid.");
442 
443  RecordingInfo ri;
444  if (RecordedId > 0)
445  ri = RecordingInfo(RecordedId);
446  else
447  ri = RecordingInfo(chanid, recstarttsRaw.toUTC());
448 
449  DTC::CutList* pCutList = new DTC::CutList();
450  if (offsettype == "Position")
451  marktype = 1;
452  else if (offsettype == "Duration")
453  marktype = 2;
454  else
455  marktype = 0;
456 
457  FillCommBreak(pCutList, &ri, marktype);
458 
459  return pCutList;
460 }
461 
463 //
465 
467  const QString &offsettype )
468 {
469  MarkTypes marktype;
470  if (RecordedId <= 0)
471  throw QString("Recorded ID appears invalid.");
472 
473  RecordingInfo ri;
474  ri = RecordingInfo(RecordedId);
475 
476  DTC::CutList* pCutList = new DTC::CutList();
477  if (offsettype == "BYTES")
478  marktype = MARK_GOP_BYFRAME;
479  else if (offsettype == "DURATION")
480  marktype = MARK_DURATION_MS;
481  else
482  throw QString("Type must be 'BYTES' or 'DURATION'.");
483 
484  FillSeek(pCutList, &ri, marktype);
485 
486  return pCutList;
487 }
488 
490 //
492 
494  int nCount )
495 {
496  pginfolist_t infoList;
497 
498  if (expirer)
499  expirer->GetAllExpiring( infoList );
500 
501  // ----------------------------------------------------------------------
502  // Build Response
503  // ----------------------------------------------------------------------
504 
505  DTC::ProgramList *pPrograms = new DTC::ProgramList();
506 
507  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)infoList.size() ) : 0;
508  nCount = (nCount > 0) ? min( nCount, (int)infoList.size() ) : infoList.size();
509  int nEndIndex = min((nStartIndex + nCount), (int)infoList.size() );
510 
511  for( int n = nStartIndex; n < nEndIndex; n++)
512  {
513  ProgramInfo *pInfo = infoList[ n ];
514 
515  if (pInfo != NULL)
516  {
517  DTC::Program *pProgram = pPrograms->AddNewProgram();
518 
519  FillProgramInfo( pProgram, pInfo, true );
520 
521  delete pInfo;
522  }
523  }
524 
525  // ----------------------------------------------------------------------
526 
527  pPrograms->setStartIndex ( nStartIndex );
528  pPrograms->setCount ( nCount );
529  pPrograms->setTotalAvailable( infoList.size() );
530  pPrograms->setAsOf ( MythDate::current() );
531  pPrograms->setVersion ( MYTH_BINARY_VERSION );
532  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
533 
534  return pPrograms;
535 }
536 
538 //
540 
542 {
543 
544  DTC::EncoderList* pList = new DTC::EncoderList();
545 
546  QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo();
547  QMap<int, EncoderLink *>::Iterator iter = tvList.begin();
548 
549  for (; iter != tvList.end(); ++iter)
550  {
551  EncoderLink *elink = *iter;
552 
553  if (elink != NULL)
554  {
555  DTC::Encoder *pEncoder = pList->AddNewEncoder();
556 
557  pEncoder->setId ( elink->GetInputID() );
558  pEncoder->setState ( elink->GetState() );
559  pEncoder->setLocal ( elink->IsLocal() );
560  pEncoder->setConnected ( elink->IsConnected() );
561  pEncoder->setSleepStatus ( elink->GetSleepStatus() );
562  // pEncoder->setLowOnFreeSpace( elink->isLowOnFreeSpace());
563 
564  if (pEncoder->Local())
565  pEncoder->setHostName( gCoreContext->GetHostName() );
566  else
567  pEncoder->setHostName( elink->GetHostName() );
568 
569  QList<InputInfo>::iterator it = inputInfoList.begin();
570  for (; it < inputInfoList.end(); ++it)
571  {
572  InputInfo inputInfo = *it;
573  if (inputInfo.inputid == static_cast<uint>(elink->GetInputID()))
574  {
575  DTC::Input *input = pEncoder->AddNewInput();
576  FillInputInfo(input, inputInfo);
577  }
578  }
579 
580  switch ( pEncoder->State() )
581  {
585  {
586  ProgramInfo *pInfo = elink->GetRecording();
587 
588  if (pInfo)
589  {
590  DTC::Program *pProgram = pEncoder->Recording();
591 
592  FillProgramInfo( pProgram, pInfo, true, true );
593 
594  delete pInfo;
595  }
596 
597  break;
598  }
599 
600  default:
601  break;
602  }
603  }
604  }
605  return pList;
606 }
607 
609 //
611 
613 {
614  DTC::InputList *pList = new DTC::InputList();
615 
616  QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo();
617  QList<InputInfo>::iterator it = inputInfoList.begin();
618  for (; it < inputInfoList.end(); ++it)
619  {
620  InputInfo inputInfo = *it;
621  DTC::Input *input = pList->AddNewInput();
622  FillInputInfo(input, inputInfo);
623  }
624 
625  return pList;
626 }
627 
629 //
631 
632 QStringList Dvr::GetRecGroupList()
633 {
634  MSqlQuery query(MSqlQuery::InitCon());
635  query.prepare("SELECT recgroup FROM recgroups WHERE recgroup <> 'Deleted' "
636  "ORDER BY recgroup");
637 
638  QStringList result;
639  if (!query.exec())
640  {
641  MythDB::DBError("GetRecGroupList", query);
642  return result;
643  }
644 
645  while (query.next())
646  result << query.value(0).toString();
647 
648  return result;
649 }
650 
652 //
654 
656 {
658 }
659 
661 //
663 
665 {
666  return PlayGroup::GetNames();
667 }
668 
670 //
672 
674 {
676 
677  MSqlQuery query(MSqlQuery::InitCon());
678 
679  query.prepare("SELECT filterid, description, newruledefault "
680  "FROM recordfilter ORDER BY filterid");
681 
682  if (query.exec())
683  {
684  while (query.next())
685  {
686  DTC::RecRuleFilter* ruleFilter = filterList->AddNewRecRuleFilter();
687  ruleFilter->setId(query.value(0).toInt());
688  ruleFilter->setDescription(QObject::tr(query.value(1).toString()
689  .toUtf8().constData()));
690  }
691  }
692 
693  return filterList;
694 }
695 
697 //
699 
700 QStringList Dvr::GetTitleList(const QString& RecGroup)
701 {
702  MSqlQuery query(MSqlQuery::InitCon());
703 
704  QString querystr = "SELECT DISTINCT title FROM recorded "
705  "WHERE deletepending = 0";
706 
707  if (!RecGroup.isEmpty())
708  querystr += " AND recgroup = :RECGROUP";
709  else
710  querystr += " AND recgroup != 'Deleted'";
711 
712  querystr += " ORDER BY title";
713 
714  query.prepare(querystr);
715 
716  if (!RecGroup.isEmpty())
717  query.bindValue(":RECGROUP", RecGroup);
718 
719  QStringList result;
720  if (!query.exec())
721  {
722  MythDB::DBError("GetTitleList recorded", query);
723  return result;
724  }
725 
726  while (query.next())
727  result << query.value(0).toString();
728 
729  return result;
730 }
731 
733 //
735 
737 {
738  MSqlQuery query(MSqlQuery::InitCon());
739 
740  QString querystr = QString(
741  "SELECT title, inetref, count(title) as count "
742  " FROM recorded AS r "
743  " JOIN recgroups AS g ON r.recgroupid = g.recgroupid "
744  " WHERE g.recgroup != 'LiveTV' "
745  " AND r.deletepending = 0 "
746  " GROUP BY title, inetref "
747  " ORDER BY title");
748 
749  query.prepare(querystr);
750 
751  DTC::TitleInfoList *pTitleInfos = new DTC::TitleInfoList();
752  if (!query.exec())
753  {
754  MythDB::DBError("GetTitleList recorded", query);
755  return pTitleInfos;
756  }
757 
758  while (query.next())
759  {
760  DTC::TitleInfo *pTitleInfo = pTitleInfos->AddNewTitleInfo();
761 
762  pTitleInfo->setTitle(query.value(0).toString());
763  pTitleInfo->setInetref(query.value(1).toString());
764  pTitleInfo->setCount(query.value(2).toInt());
765  }
766 
767  return pTitleInfos;
768 }
769 
771 //
773 
775  int nCount,
776  bool bShowAll,
777  int nRecordId,
778  int nRecStatus )
779 {
780  RecordingList recordingList; // Auto-delete deque
781  RecList tmpList; // Standard deque, objects must be deleted
782 
783  if (nRecordId <= 0)
784  nRecordId = -1;
785 
786  // NOTE: Fetching this information directly from the schedule is
787  // significantly faster than using ProgramInfo::LoadFromScheduler()
788  Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
789  if (scheduler)
790  scheduler->GetAllPending(tmpList, nRecordId);
791 
792  // Sort the upcoming into only those which will record
793  RecList::iterator it = tmpList.begin();
794  for(; it < tmpList.end(); ++it)
795  {
796  if ((nRecStatus != 0) &&
797  ((*it)->GetRecordingStatus() != nRecStatus))
798  {
799  delete *it;
800  *it = NULL;
801  continue;
802  }
803 
804  if (!bShowAll && ((((*it)->GetRecordingStatus() >= RecStatus::Pending) &&
805  ((*it)->GetRecordingStatus() <= RecStatus::WillRecord)) ||
806  ((*it)->GetRecordingStatus() == RecStatus::Conflict)) &&
807  ((*it)->GetRecordingEndTime() > MythDate::current()))
808  {
809  recordingList.push_back(new RecordingInfo(**it));
810  }
811  else if (bShowAll &&
812  ((*it)->GetRecordingEndTime() > MythDate::current()))
813  {
814  recordingList.push_back(new RecordingInfo(**it));
815  }
816 
817  delete *it;
818  *it = NULL;
819  }
820 
821  // ----------------------------------------------------------------------
822  // Build Response
823  // ----------------------------------------------------------------------
824 
825  DTC::ProgramList *pPrograms = new DTC::ProgramList();
826 
827  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
828  nCount = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
829  int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
830 
831  for( int n = nStartIndex; n < nEndIndex; n++)
832  {
833  ProgramInfo *pInfo = recordingList[ n ];
834 
835  DTC::Program *pProgram = pPrograms->AddNewProgram();
836 
837  FillProgramInfo( pProgram, pInfo, true );
838  }
839 
840  // ----------------------------------------------------------------------
841 
842  pPrograms->setStartIndex ( nStartIndex );
843  pPrograms->setCount ( nCount );
844  pPrograms->setTotalAvailable( recordingList.size() );
845  pPrograms->setAsOf ( MythDate::current() );
846  pPrograms->setVersion ( MYTH_BINARY_VERSION );
847  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
848 
849  return pPrograms;
850 }
851 
853 //
855 
857  int nCount,
858  int nRecordId )
859 {
860  RecordingList recordingList; // Auto-delete deque
861  RecList tmpList; // Standard deque, objects must be deleted
862 
863  if (nRecordId <= 0)
864  nRecordId = -1;
865 
866  // NOTE: Fetching this information directly from the schedule is
867  // significantly faster than using ProgramInfo::LoadFromScheduler()
868  Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
869  if (scheduler)
870  scheduler->GetAllPending(tmpList, nRecordId);
871 
872  // Sort the upcoming into only those which are conflicts
873  RecList::iterator it = tmpList.begin();
874  for(; it < tmpList.end(); ++it)
875  {
876  if (((*it)->GetRecordingStatus() == RecStatus::Conflict) &&
877  ((*it)->GetRecordingStartTime() >= MythDate::current()))
878  {
879  recordingList.push_back(new RecordingInfo(**it));
880  }
881  delete *it;
882  *it = NULL;
883  }
884 
885  // ----------------------------------------------------------------------
886  // Build Response
887  // ----------------------------------------------------------------------
888 
889  DTC::ProgramList *pPrograms = new DTC::ProgramList();
890 
891  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
892  nCount = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
893  int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
894 
895  for( int n = nStartIndex; n < nEndIndex; n++)
896  {
897  ProgramInfo *pInfo = recordingList[ n ];
898 
899  DTC::Program *pProgram = pPrograms->AddNewProgram();
900 
901  FillProgramInfo( pProgram, pInfo, true );
902  }
903 
904  // ----------------------------------------------------------------------
905 
906  pPrograms->setStartIndex ( nStartIndex );
907  pPrograms->setCount ( nCount );
908  pPrograms->setTotalAvailable( recordingList.size() );
909  pPrograms->setAsOf ( MythDate::current() );
910  pPrograms->setVersion ( MYTH_BINARY_VERSION );
911  pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
912 
913  return pPrograms;
914 }
915 
917  QString sTitle,
918  QString sSubtitle,
919  QString sDescription,
920  QString sCategory,
921  QDateTime recstarttsRaw,
922  QDateTime recendtsRaw,
923  QString sSeriesId,
924  QString sProgramId,
925  int nChanId,
926  QString sStation,
927  int nFindDay,
928  QTime tFindTime,
929  int nParentId,
930  bool bInactive,
931  uint nSeason,
932  uint nEpisode,
933  QString sInetref,
934  QString sType,
935  QString sSearchType,
936  int nRecPriority,
937  uint nPreferredInput,
938  int nStartOffset,
939  int nEndOffset,
940  QString sDupMethod,
941  QString sDupIn,
942  uint nFilter,
943  QString sRecProfile,
944  QString sRecGroup,
945  QString sStorageGroup,
946  QString sPlayGroup,
947  bool bAutoExpire,
948  int nMaxEpisodes,
949  bool bMaxNewest,
950  bool bAutoCommflag,
951  bool bAutoTranscode,
952  bool bAutoMetaLookup,
953  bool bAutoUserJob1,
954  bool bAutoUserJob2,
955  bool bAutoUserJob3,
956  bool bAutoUserJob4,
957  int nTranscoder)
958 {
959  QDateTime recstartts = recstarttsRaw.toUTC();
960  QDateTime recendts = recendtsRaw.toUTC();
961  RecordingRule rule;
962  rule.LoadTemplate("Default");
963 
964  if (sType.isEmpty())
965  sType = "single";
966 
967  if (sSearchType.isEmpty())
968  sSearchType = "none";
969 
970  if (sDupMethod.isEmpty())
971  sDupMethod = "subtitleanddescription";
972 
973  if (sDupIn.isEmpty())
974  sDupIn = "all";
975 
976  rule.m_title = sTitle;
977  rule.m_subtitle = sSubtitle;
978  rule.m_description = sDescription;
979 
980  rule.m_startdate = recstartts.date();
981  rule.m_starttime = recstartts.time();
982  rule.m_enddate = recendts.date();
983  rule.m_endtime = recendts.time();
984 
985  rule.m_type = recTypeFromString(sType);
986  rule.m_searchType = searchTypeFromString(sSearchType);
987  rule.m_dupMethod = dupMethodFromString(sDupMethod);
988  rule.m_dupIn = dupInFromString(sDupIn);
989 
990  if (sRecProfile.isEmpty())
991  sRecProfile = "Default";
992 
993  if (sRecGroup.isEmpty())
994  sRecGroup = "Default";
995 
996  if (sStorageGroup.isEmpty())
997  sStorageGroup = "Default";
998 
999  if (sPlayGroup.isEmpty())
1000  sPlayGroup = "Default";
1001 
1002  rule.m_category = sCategory;
1003  rule.m_seriesid = sSeriesId;
1004  rule.m_programid = sProgramId;
1005 
1006  rule.m_channelid = nChanId;
1007  rule.m_station = sStation;
1008 
1009  rule.m_findday = nFindDay;
1010  rule.m_findtime = tFindTime;
1011 
1012  rule.m_recProfile = sRecProfile;
1013  rule.m_recGroupID = RecordingInfo::GetRecgroupID(sRecGroup);
1014  if (rule.m_recGroupID == 0)
1016  rule.m_storageGroup = sStorageGroup;
1017  rule.m_playGroup = sPlayGroup;
1018 
1019  rule.m_parentRecID = nParentId;
1020  rule.m_isInactive = bInactive;
1021 
1022  rule.m_season = nSeason;
1023  rule.m_episode = nEpisode;
1024  rule.m_inetref = sInetref;
1025 
1026  rule.m_recPriority = nRecPriority;
1027  rule.m_prefInput = nPreferredInput;
1028  rule.m_startOffset = nStartOffset;
1029  rule.m_endOffset = nEndOffset;
1030  rule.m_filter = nFilter;
1031 
1032  rule.m_autoExpire = bAutoExpire;
1033  rule.m_maxEpisodes = nMaxEpisodes;
1034  rule.m_maxNewest = bMaxNewest;
1035 
1036  rule.m_autoCommFlag = bAutoCommflag;
1037  rule.m_autoTranscode = bAutoTranscode;
1038  rule.m_autoMetadataLookup = bAutoMetaLookup;
1039 
1040  rule.m_autoUserJob1 = bAutoUserJob1;
1041  rule.m_autoUserJob2 = bAutoUserJob2;
1042  rule.m_autoUserJob3 = bAutoUserJob3;
1043  rule.m_autoUserJob4 = bAutoUserJob4;
1044 
1045  rule.m_transcoder = nTranscoder;
1046 
1047  QString msg;
1048  if (!rule.IsValid(msg))
1049  throw msg;
1050 
1051  rule.Save();
1052 
1053  uint recid = rule.m_recordID;
1054 
1055  return recid;
1056 }
1057 
1059  QString sTitle,
1060  QString sSubtitle,
1061  QString sDescription,
1062  QString sCategory,
1063  QDateTime dStartTimeRaw,
1064  QDateTime dEndTimeRaw,
1065  QString sSeriesId,
1066  QString sProgramId,
1067  int nChanId,
1068  QString sStation,
1069  int nFindDay,
1070  QTime tFindTime,
1071  bool bInactive,
1072  uint nSeason,
1073  uint nEpisode,
1074  QString sInetref,
1075  QString sType,
1076  QString sSearchType,
1077  int nRecPriority,
1078  uint nPreferredInput,
1079  int nStartOffset,
1080  int nEndOffset,
1081  QString sDupMethod,
1082  QString sDupIn,
1083  uint nFilter,
1084  QString sRecProfile,
1085  QString sRecGroup,
1086  QString sStorageGroup,
1087  QString sPlayGroup,
1088  bool bAutoExpire,
1089  int nMaxEpisodes,
1090  bool bMaxNewest,
1091  bool bAutoCommflag,
1092  bool bAutoTranscode,
1093  bool bAutoMetaLookup,
1094  bool bAutoUserJob1,
1095  bool bAutoUserJob2,
1096  bool bAutoUserJob3,
1097  bool bAutoUserJob4,
1098  int nTranscoder)
1099 {
1100  if (nRecordId <= 0 )
1101  throw QString("Record ID is invalid.");
1102 
1103  RecordingRule pRule;
1104  pRule.m_recordID = nRecordId;
1105  pRule.Load();
1106 
1107  if (!pRule.IsLoaded())
1108  throw QString("Record ID does not exist.");
1109 
1110  QDateTime recstartts = dStartTimeRaw.toUTC();
1111  QDateTime recendts = dEndTimeRaw.toUTC();
1112 
1113  pRule.m_isInactive = bInactive;
1114  if (sType.isEmpty())
1115  sType = "single";
1116 
1117  if (sSearchType.isEmpty())
1118  sSearchType = "none";
1119 
1120  if (sDupMethod.isEmpty())
1121  sDupMethod = "subtitleanddescription";
1122 
1123  if (sDupIn.isEmpty())
1124  sDupIn = "all";
1125 
1126  pRule.m_type = recTypeFromString(sType);
1127  pRule.m_searchType = searchTypeFromString(sSearchType);
1128  pRule.m_dupMethod = dupMethodFromString(sDupMethod);
1129  pRule.m_dupIn = dupInFromString(sDupIn);
1130 
1131  if (sRecProfile.isEmpty())
1132  sRecProfile = "Default";
1133 
1134  if (sRecGroup.isEmpty())
1135  sRecGroup = "Default";
1136 
1137  if (sStorageGroup.isEmpty())
1138  sStorageGroup = "Default";
1139 
1140  if (sPlayGroup.isEmpty())
1141  sPlayGroup = "Default";
1142 
1143  if (!sTitle.isEmpty())
1144  pRule.m_title = sTitle;
1145 
1146  if (!sSubtitle.isEmpty())
1147  pRule.m_subtitle = sSubtitle;
1148 
1149  if(!sDescription.isEmpty())
1150  pRule.m_description = sDescription;
1151 
1152  if (!sCategory.isEmpty())
1153  pRule.m_category = sCategory;
1154 
1155  if (!sSeriesId.isEmpty())
1156  pRule.m_seriesid = sSeriesId;
1157 
1158  if (!sProgramId.isEmpty())
1159  pRule.m_programid = sProgramId;
1160 
1161  if (nChanId)
1162  pRule.m_channelid = nChanId;
1163  if (!sStation.isEmpty())
1164  pRule.m_station = sStation;
1165 
1166  pRule.m_startdate = recstartts.date();
1167  pRule.m_starttime = recstartts.time();
1168  pRule.m_enddate = recendts.date();
1169  pRule.m_endtime = recendts.time();
1170 
1171  pRule.m_findday = nFindDay;
1172  pRule.m_findtime = tFindTime;
1173 
1174  pRule.m_recProfile = sRecProfile;
1175  pRule.m_recGroupID = RecordingInfo::GetRecgroupID(sRecGroup);
1176  if (pRule.m_recGroupID == 0)
1178  pRule.m_storageGroup = sStorageGroup;
1179  pRule.m_playGroup = sPlayGroup;
1180 
1181  pRule.m_isInactive = bInactive;
1182 
1183  pRule.m_season = nSeason;
1184  pRule.m_episode = nEpisode;
1185  pRule.m_inetref = sInetref;
1186 
1187  pRule.m_recPriority = nRecPriority;
1188  pRule.m_prefInput = nPreferredInput;
1189  pRule.m_startOffset = nStartOffset;
1190  pRule.m_endOffset = nEndOffset;
1191  pRule.m_filter = nFilter;
1192 
1193  pRule.m_autoExpire = bAutoExpire;
1194  pRule.m_maxEpisodes = nMaxEpisodes;
1195  pRule.m_maxNewest = bMaxNewest;
1196 
1197  pRule.m_autoCommFlag = bAutoCommflag;
1198  pRule.m_autoTranscode = bAutoTranscode;
1199  pRule.m_autoMetadataLookup = bAutoMetaLookup;
1200 
1201  pRule.m_autoUserJob1 = bAutoUserJob1;
1202  pRule.m_autoUserJob2 = bAutoUserJob2;
1203  pRule.m_autoUserJob3 = bAutoUserJob3;
1204  pRule.m_autoUserJob4 = bAutoUserJob4;
1205 
1206  pRule.m_transcoder = nTranscoder;
1207 
1208  QString msg;
1209  if (!pRule.IsValid(msg))
1210  throw msg;
1211 
1212  bool bResult = pRule.Save();
1213 
1214  return bResult;
1215 }
1216 
1218 {
1219  bool bResult = false;
1220 
1221  if (nRecordId <= 0 )
1222  throw QString("Record ID does not exist.");
1223 
1224  RecordingRule pRule;
1225  pRule.m_recordID = nRecordId;
1226 
1227  bResult = pRule.Delete();
1228 
1229  return bResult;
1230 }
1231 
1232 bool Dvr::AddDontRecordSchedule(int nChanId, const QDateTime &dStartTime,
1233  bool bNeverRecord)
1234 {
1235  bool bResult = true;
1236 
1237  if (nChanId <= 0 || !dStartTime.isValid())
1238  throw QString("Program does not exist.");
1239 
1240  ProgramInfo *pi = LoadProgramFromProgram(nChanId, dStartTime.toUTC());
1241 
1242  if (!pi)
1243  throw QString("Program does not exist.");
1244 
1245  // Why RecordingInfo instead of ProgramInfo? Good question ...
1246  RecordingInfo recInfo = RecordingInfo(*pi);
1247 
1248  delete pi;
1249 
1250  if (bNeverRecord)
1251  {
1252  recInfo.ApplyNeverRecord();
1253  }
1254  else
1256 
1257  return bResult;
1258 }
1259 
1261  int nCount,
1262  const QString &Sort,
1263  bool Descending )
1264 {
1265  Scheduler::SchedSortColumn sortingColumn;
1266  if (Sort.toLower() == "lastrecorded")
1267  sortingColumn = Scheduler::kSortLastRecorded;
1268  else if (Sort.toLower() == "nextrecording")
1269  sortingColumn = Scheduler::kSortNextRecording;
1270  else if (Sort.toLower() == "title")
1271  sortingColumn = Scheduler::kSortTitle;
1272  else if (Sort.toLower() == "priority")
1273  sortingColumn = Scheduler::kSortPriority;
1274  else if (Sort.toLower() == "type")
1275  sortingColumn = Scheduler::kSortType;
1276  else
1277  sortingColumn = Scheduler::kSortTitle;
1278 
1279  RecList recList;
1280  Scheduler::GetAllScheduled(recList, sortingColumn, !Descending);
1281 
1282  // ----------------------------------------------------------------------
1283  // Build Response
1284  // ----------------------------------------------------------------------
1285 
1286  DTC::RecRuleList *pRecRules = new DTC::RecRuleList();
1287 
1288  nStartIndex = (nStartIndex > 0) ? min( nStartIndex, (int)recList.size() ) : 0;
1289  nCount = (nCount > 0) ? min( nCount, (int)recList.size() ) : recList.size();
1290  int nEndIndex = min((nStartIndex + nCount), (int)recList.size() );
1291 
1292  for( int n = nStartIndex; n < nEndIndex; n++)
1293  {
1294  RecordingInfo *info = recList[n];
1295 
1296  if (info != NULL)
1297  {
1298  DTC::RecRule *pRecRule = pRecRules->AddNewRecRule();
1299 
1300  FillRecRuleInfo( pRecRule, info->GetRecordingRule() );
1301  }
1302  }
1303 
1304  // ----------------------------------------------------------------------
1305 
1306  pRecRules->setStartIndex ( nStartIndex );
1307  pRecRules->setCount ( nCount );
1308  pRecRules->setTotalAvailable( recList.size() );
1309  pRecRules->setAsOf ( MythDate::current() );
1310  pRecRules->setVersion ( MYTH_BINARY_VERSION );
1311  pRecRules->setProtoVer ( MYTH_PROTO_VERSION );
1312 
1313  while (!recList.empty())
1314  {
1315  delete recList.back();
1316  recList.pop_back();
1317  }
1318 
1319  return pRecRules;
1320 }
1321 
1323  QString sTemplate,
1324  int nRecordedId,
1325  int nChanId,
1326  QDateTime dStartTimeRaw,
1327  bool bMakeOverride )
1328 {
1329  RecordingRule rule;
1330  QDateTime dStartTime = dStartTimeRaw.toUTC();
1331 
1332  if (nRecordId > 0)
1333  {
1334  rule.m_recordID = nRecordId;
1335  if (!rule.Load())
1336  throw QString("Record ID does not exist.");
1337  }
1338  else if (!sTemplate.isEmpty())
1339  {
1340  if (!rule.LoadTemplate(sTemplate))
1341  throw QString("Template does not exist.");
1342  }
1343  else if (nRecordedId > 0) // Loads from the Recorded/Recorded Program Table
1344  {
1345  // Despite the use of ProgramInfo, this only applies to Recordings.
1346  ProgramInfo recInfo(nRecordedId);
1347  if (!rule.LoadByProgram(&recInfo))
1348  throw QString("Recording does not exist");
1349  }
1350  else if (nChanId > 0 && dStartTime.isValid()) // Loads from Program Table, should NOT be used with recordings
1351  {
1352  // Despite the use of RecordingInfo, this only applies to programs in the
1353  // present or future, not to recordings? Confused yet?
1355  RecordingInfo info(nChanId, dStartTime, false, 0, &status);
1356  if (status != RecordingInfo::kFoundProgram)
1357  throw QString("Program does not exist.");
1358  RecordingRule *pRule = info.GetRecordingRule();
1359  if (bMakeOverride && rule.m_type != kSingleRecord &&
1360  rule.m_type != kOverrideRecord && rule.m_type != kDontRecord)
1361  pRule->MakeOverride();
1362  rule = *pRule;
1363  }
1364  else
1365  {
1366  throw QString("Invalid request.");
1367  }
1368 
1369  DTC::RecRule *pRecRule = new DTC::RecRule();
1370  FillRecRuleInfo( pRecRule, &rule );
1371 
1372  return pRecRule;
1373 }
1374 
1376 {
1377  bool bResult = false;
1378 
1379  if (nRecordId <= 0 )
1380  throw QString("Record ID appears invalid.");
1381 
1382  RecordingRule pRule;
1383  pRule.m_recordID = nRecordId;
1384  pRule.Load();
1385 
1386  if (pRule.IsLoaded())
1387  {
1388  pRule.m_isInactive = false;
1389  bResult = pRule.Save();
1390  }
1391 
1392  return bResult;
1393 }
1394 
1396 {
1397  bool bResult = false;
1398 
1399  if (nRecordId <= 0 )
1400  throw QString("Record ID appears invalid.");
1401 
1402  RecordingRule pRule;
1403  pRule.m_recordID = nRecordId;
1404  pRule.Load();
1405 
1406  if (pRule.IsLoaded())
1407  {
1408  pRule.m_isInactive = true;
1409  bResult = pRule.Save();
1410  }
1411 
1412  return bResult;
1413 }
1414 
1415 int Dvr::RecordedIdForPathname(const QString & pathname)
1416 {
1417  uint recordedid;
1418 
1419  if (!ProgramInfo::QueryRecordedIdFromPathname(pathname, recordedid))
1420  return -1;
1421 
1422  return recordedid;
1423 }
1424 
1426 {
1427  RecStatus::Type type = static_cast<RecStatus::Type>(RecStatus);
1428  return RecStatus::toString(type);
1429 }
1430 
1431 QString Dvr::RecStatusToDescription(int RecStatus, int recType,
1432  const QDateTime &StartTime)
1433 {
1434  //if (!StartTime.isValid())
1435  // throw QString("StartTime appears invalid.");
1436  RecStatus::Type rsType = static_cast<RecStatus::Type>(RecStatus);
1437  RecordingType recordingType = static_cast<RecordingType>(recType);
1438  return RecStatus::toDescription(rsType, recordingType, StartTime);
1439 }
1440 
1441 QString Dvr::RecTypeToString(QString recType)
1442 {
1443  bool ok;
1444  RecordingType enumType = static_cast<RecordingType>(recType.toInt(&ok, 10));
1445  if (ok)
1446  return toString(enumType);
1447  // RecordingType type = static_cast<RecordingType>(recType);
1448  return toString(recTypeFromString(recType));
1449 }
1450 
1451 QString Dvr::RecTypeToDescription(QString recType)
1452 {
1453  bool ok;
1454  RecordingType enumType = static_cast<RecordingType>(recType.toInt(&ok, 10));
1455  if (ok)
1456  return toDescription(enumType);
1457  // RecordingType type = static_cast<RecordingType>(recType);
1458  return toDescription(recTypeFromString(recType));
1459 }
1460 
1461 QString Dvr::DupInToString(QString DupIn)
1462 {
1463  // RecordingDupInType type= static_cast<RecordingDupInType>(DupIn);
1464  // return toString(type);
1465  return toString(dupInFromString(DupIn));
1466 }
1467 
1468 QString Dvr::DupInToDescription(QString DupIn)
1469 {
1470  // RecordingDupInType type= static_cast<RecordingDupInType>(DupIn);
1471  //return toDescription(type);
1472  return toDescription(dupInFromString(DupIn));
1473 }
1474 
1475 QString Dvr::DupMethodToString(QString DupMethod)
1476 {
1477  // RecordingDupMethodType method = static_cast<RecordingDupMethodType>(DupMethod);
1478  return toString(dupMethodFromString(DupMethod));
1479 }
1480 
1481 QString Dvr::DupMethodToDescription(QString DupMethod)
1482 {
1483  // RecordingDupMethodType method = static_cast<RecordingDupMethodType>(DupMethod);
1484  return toDescription(dupMethodFromString(DupMethod));
1485 }
QString RecStatusToString(int RecStatus)
Definition: dvr.cpp:1425
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:856
Program * AddNewProgram()
Definition: programList.h:86
void bindValue(const QString &placeholder, const QVariant &val)
Definition: mythdbcon.cpp:884
AutoExpire * expirer
void ReactivateRecording(void)
Asks the scheduler to restart this recording if possible.
QString m_programid
Definition: recordingrule.h:88
DTC::RecRuleFilterList * GetRecRuleFilterList()
Definition: dvr.cpp:673
DTC::TitleInfoList * GetTitleInfoList()
Definition: dvr.cpp:736
SchedSortColumn
Definition: scheduler.h:90
ProgramInfo * LoadProgramFromProgram(const uint chanid, const QDateTime &starttime)
bool StopRecording(int RecordedId)
Definition: dvr.cpp:244
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:300
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)
RecSearchType searchTypeFromString(QString type)
QStringList GetPlayGroupList()
Definition: dvr.cpp:664
DTC::CutList * GetRecordedCutList(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:400
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
QString GetTitle(void) const
Definition: programinfo.h:342
RecordingType recTypeFromString(QString type)
static QString toDescription(Type, RecordingType, const QDateTime &recstartts)
Converts "recstatus" into a long human readable description.
Definition: recStatus.cpp:189
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:34
QString DupMethodToDescription(QString DupMethod)
Definition: dvr.cpp:1481
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:1461
AutoDeleteDeque< ProgramInfo * > ProgramList
Definition: programinfo.h:29
size_t size(void) const
DTC::CutList * GetRecordedCommBreak(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:433
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:1260
int RecordedIdForPathname(const QString &Filename)
Definition: dvr.cpp:1415
bool RescheduleRecordings(void)
Definition: dvr.cpp:287
DTC::ProgramList * GetExpiringList(int StartIndex, int Count)
Definition: dvr.cpp:493
bool SetSavedBookmark(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType, long Offset)
Definition: dvr.cpp:362
static uint GetRecgroupID(const QString &recGroup)
Temporary helper during transition from string to ID.
__u32 type
Definition: videodev2.h:1038
QString GetStorageGroup(void) const
Definition: programinfo.h:401
QVariant value(int i) const
Definition: mythdbcon.h:182
QStringList GetRecStorageGroupList()
Definition: dvr.cpp:655
bool Save(bool sendSig=true)
MarkTypes
Definition: programtypes.h:50
RecordingDupMethodType dupMethodFromString(QString type)
Holds information on recordings and videos.
Definition: programinfo.h:66
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:1861
static QMap< QString, uint32_t > QueryInUseMap(void)
DTC::CutList * GetRecordedSeek(int RecordedId, const QString &OffsetType)
Definition: dvr.cpp:466
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:1475
long GetSavedBookmark(int RecordedId, int ChanId, const QDateTime &StartTime, const QString &OffsetType)
Definition: dvr.cpp:329
Input * AddNewInput()
Definition: inputList.h:59
bool ReactivateRecording(int RecordedId)
Definition: dvr.cpp:271
QString GetRecordingGroup(void) const
Definition: programinfo.h:398
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:1431
QString RecTypeToString(QString RecType)
Definition: dvr.cpp:1441
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:542
bool IsDeletePending(void) const
Definition: programinfo.h:464
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:31
static QList< InputInfo > GetAllInputInfo()
Definition: cardutil.cpp:1012
bool QueryDurationKeyFrame(uint64_t *, uint64_t duration, bool backwards) const
uint64_t QueryBookmark(void) const
Gets any bookmark position in database, unless the ignore bookmark flag is set.
void GetAllExpiring(QStringList &strList)
Gets the full list of programs that can expire in expiration order.
Definition: autoexpire.cpp:837
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:1451
void dispatch(const MythEvent &event)
QString m_inetref
Definition: recordingrule.h:89
bool QueryKeyFramePosition(uint64_t *, uint64_t keyframe, bool backwards) const
void FillSeek(DTC::CutList *pCutList, RecordingInfo *rInfo, MarkTypes marktype)
static bool QueryRecordedIdFromPathname(const QString &pathname, uint &recordedid)
bool AddDontRecordSchedule(int ChanId, const QDateTime &StartTime, bool NeverRecord)
Definition: dvr.cpp:1232
Encoder * AddNewEncoder()
Definition: encoderList.h:59
DTC::ProgramList * GetUpcomingList(int StartIndex, int Count, bool ShowAll, int RecordId, int RecStatus)
Definition: dvr.cpp:774
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
bool IsLoaded() const
Definition: recordingrule.h:55
DTC::RecRule * GetRecordSchedule(uint RecordId, QString Template, int nRecordedId, int ChanId, QDateTime StartTime, bool MakeOverride)
Definition: dvr.cpp:1322
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
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:351
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:1468
DTC::Program * GetRecorded(int RecordedId, int ChanId, const QDateTime &StartTime)
Definition: dvr.cpp:145
static QMap< QString, bool > QueryJobsRunning(int type)
QString m_recProfile
void SaveWatched(bool watchedFlag)
Set "watched" field in recorded/videometadata to "watchedFlag".
DTC::EncoderList * GetEncoderList()
Definition: dvr.cpp:541
static QStringList GetNames(void)
Definition: playgroup.cpp:173
virtual QMap< QString, ProgramInfo * > GetRecording(void) const =0
bool RemoveRecordSchedule(uint RecordId)
Definition: dvr.cpp:1217
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:383
bool Load(bool asTemplate=false)
unsigned m_filter
QString m_category
Definition: recordingrule.h:80
bool LoadTemplate(QString category, QString categoryType="Default")
DTC::InputList * GetInputList()
Definition: dvr.cpp:612
bool LoadFromRecorded(ProgramList &destination, bool possiblyInProgressRecordingsOnly, const QMap< QString, uint32_t > &inUseMap, const QMap< QString, bool > &isJobRunning, const QMap< QString, ProgramInfo *> &recMap, int sort)
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:24
QStringList GetRecGroupList()
Definition: dvr.cpp:632
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:1395
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:1058
bool GetAllPending(RecList &retList, int recRuleId=0) const
Definition: scheduler.cpp:1766
Default UTC.
Definition: mythdate.h:14
bool HasPathname(void) const
Definition: programinfo.h:339
bool EnableRecordSchedule(uint RecordId)
Definition: dvr.cpp:1375
QStringList GetTitleList(const QString &RecGroup)
Definition: dvr.cpp:700
RecSearchType m_searchType
bool QueryKeyFrameDuration(uint64_t *, uint64_t keyframe, bool backwards) const
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:916
bool IsValid(QString &text)