MythTV
master
|
#include <recordingextender.h>
Public Member Functions | |
void | run (void) override |
The main execution loop for the Recording Extender. More... | |
~RecordingExtender () override | |
![]() | |
MThread (const QString &objectName) | |
Standard constructor. More... | |
MThread (const QString &objectName, QRunnable *runnable) | |
Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More... | |
virtual | ~MThread () |
MThread (const MThread &)=delete | |
MThread & | operator= (const MThread &)=delete |
void | RunProlog (void) |
Sets up a thread, call this if you reimplement run(). More... | |
void | RunEpilog (void) |
Cleans up a thread's resources, call this if you reimplement run(). More... | |
QThread * | qthread (void) |
Returns the thread, this will always return the same pointer no matter how often you restart the thread. More... | |
void | setObjectName (const QString &name) |
QString | objectName (void) const |
void | setPriority (QThread::Priority priority) |
QThread::Priority | priority (void) const |
bool | isFinished (void) const |
bool | isRunning (void) const |
void | setStackSize (uint stackSize) |
uint | stackSize (void) const |
void | exit (int retcode=0) |
Use this to exit from the thread if you are using a Qt event loop. More... | |
void | start (QThread::Priority p=QThread::InheritPriority) |
Tell MThread to start running the thread in the near future. More... | |
void | terminate (void) |
Kill a thread unsafely. More... | |
void | quit (void) |
calls exit(0) More... | |
bool | wait (std::chrono::milliseconds time=std::chrono::milliseconds::max()) |
Wait for the MThread to exit, with a maximum timeout. More... | |
Static Public Member Functions | |
static void | create (Scheduler *scheduler, RecordingInfo &ri) |
Create an instance of the RecordingExtender if necessary, and add this recording to the list of new recordings. More... | |
static void | nameCleanup (const SportInfo &info, QString &name1, QString &name2) |
Clean up two team names for comparison against the ESPN API. More... | |
![]() | |
static void | ThreadSetup (const QString &name) |
This is to be called on startup in those few threads that haven't been ported to MThread. More... | |
static void | ThreadCleanup (void) |
This is to be called on exit in those few threads that haven't been ported to MThread. More... | |
static void | Cleanup (void) |
This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More... | |
static void | GetAllThreadNames (QStringList &list) |
static void | GetAllRunningThreadNames (QStringList &list) |
Private Member Functions | |
RecordingExtender () | |
void | addNewRecording (int recordedID) |
Add an item to the list of new recordings. More... | |
bool | findKnownSport (const QString &_title, AutoExtendType type, SportInfoList &info) const |
Retrieve the db record for a sporting event on a specific provider. More... | |
virtual RecExtDataSource * | createDataSource (AutoExtendType type) |
Create a RecExtDataSource object for the specified service. More... | |
void | extendRecording (const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game) |
Extend the current recording by XX minutes. More... | |
void | processNewRecordings () |
Process the list of newly started sports recordings. More... | |
void | processActiveRecordings () |
Process the currently active sports recordings. More... | |
void | checkDone () |
Is there any remaining work? Check for both newly created recording and for active recordings. More... | |
void | expireOverrides () |
Delete the list of the override rules that have been created by this instance of RecordingExtender. More... | |
Static Private Member Functions | |
static void | clearDownloadedInfo () |
Clear all downloaded info. More... | |
static bool | parseProgramInfo (const QString &subtitle, const QString &description, QString &team1, QString &team2) |
Parse a RecordingInfo to find the team names. More... | |
static QString | ruleIdAsString (const RecordingRule *rr) |
Quick helper function for printing recording rule numbers. More... | |
static void | finishRecording (const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game) |
Stop the current recording early. More... | |
static void | unchangedRecording (const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game) |
Log that this recording hasn't changed. More... | |
static void | nameCleanup (const SportInfo &info, QString &name) |
Clean up a single team name for comparison against the ESPN API. More... | |
Private Attributes | |
bool | m_running {true} |
Whether the RecordingExtender process is running. More... | |
Scheduler * | m_scheduler {nullptr} |
Pointer to the scheduler. More... | |
QMutex | m_newRecordingsLock |
New recordings are added by the scheduler process and removed by this process. More... | |
QList< int > | m_newRecordings |
Newly started recordings to process. More... | |
QList< ActiveGame > | m_activeGames |
Currently ongoing games to track. More... | |
QList< int > | m_overrideRules |
Recordings that have had an override rule creates. More... | |
uint | m_forcedYearforTesting {0} |
Testing data. More... | |
Static Private Attributes | |
static RecordingExtender * | s_singleton {nullptr} |
The single instance of a RecordingExtender. More... | |
static QMutex | s_createLock {} |
Interlock the scheduler thread crating this process, and this process determining whether it should continue running. More... | |
Friends | |
class | TestRecordingExtender |
Additional Inherited Members | |
![]() | |
int | exec (void) |
Enters the qt event loop. call exit or quit to exit thread. More... | |
![]() | |
static void | setTerminationEnabled (bool enabled=true) |
static void | usleep (std::chrono::microseconds time) |
template<typename R , typename P > | |
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > | usleep (std::chrono::duration< R, P > time) |
![]() | |
MThreadInternal * | m_thread {nullptr} |
QRunnable * | m_runnable {nullptr} |
bool | m_prologExecuted {true} |
bool | m_epilogExecuted {true} |
Definition at line 307 of file recordingextender.h.
|
override |
Definition at line 1060 of file recordingextender.cpp.
|
inlineprivate |
Definition at line 319 of file recordingextender.h.
Referenced by create().
|
static |
Create an instance of the RecordingExtender if necessary, and add this recording to the list of new recordings.
This function is called by the scheduler for all new recordings, but only does anything if the recording is marked to be auto extended.
scheduler | A pointer to the scheduler object. |
ri | The recording that just started. |
Definition at line 1075 of file recordingextender.cpp.
Referenced by Scheduler::HandleRecording().
|
overridevirtual |
The main execution loop for the Recording Extender.
Reimplemented from MThread.
Definition at line 1671 of file recordingextender.cpp.
|
static |
Clean up two team names for comparison against the ESPN API.
[in] | info | A data structure defining the current sport. |
[in,out] | name1 | The first sports team name to clean up. |
[in,out] | name2 | The second sports team name to clean up. |
Definition at line 1342 of file recordingextender.cpp.
Referenced by RecExtEspnDataPage::findGameInfo(), RecExtMlbDataPage::parseGameObject(), and processNewRecordings().
|
private |
Add an item to the list of new recordings.
Handles locking of the new recordings list.
recordedID | The recording ID of the recording that just started. |
Definition at line 1104 of file recordingextender.cpp.
Referenced by create().
|
private |
Retrieve the db record for a sporting event on a specific provider.
This function handles regex matching between program listings and database entries.
If the title contains a year (i.e. four consecutive digits) then the year must be this year in order to match. Handling the year this way simplifies all the regular expressions, eliminating the need for each one to allow for a starting or ending year.
title | The program title of the sporting event. I.E. "MLB Baseball", "2021 World Series", or "Superbowl LVI". |
type | An identifier for the service used to check the game status. |
infoList | If the function returns true, this contains a list of the databases record for the specified sporting event and provider. Unchanged otherwise. Everything other than FIFA Soccer Qualification Matches will likely return a single entry. |
Definition at line 1150 of file recordingextender.cpp.
Referenced by processNewRecordings().
|
staticprivate |
Clear all downloaded info.
Definition at line 1206 of file recordingextender.cpp.
Referenced by run(), and ~RecordingExtender().
|
privatevirtual |
Create a RecExtDataSource object for the specified service.
This will never produce the base class object, but will only produce one of the subclass objects.
[in] | parent | A pointer to the RecordingExtender object that created this data source. |
[in] | type | An identifier for the service used to check the game status. |
Definition at line 1118 of file recordingextender.cpp.
Referenced by processActiveRecordings(), and processNewRecordings().
|
staticprivate |
Parse a RecordingInfo to find the team names.
Depending on the guide data source, this can be found either in the subtitle or in the description field.
[in] | ri | The RecordingInfo to parse. |
[out] | team1 | The name of the first team. |
[out] | team2 | The name of the second team. |
Definition at line 1240 of file recordingextender.cpp.
Referenced by processNewRecordings().
|
staticprivate |
Quick helper function for printing recording rule numbers.
If there is a parent rule this prints two numbers, otherwise it prints one.
[in] | rr | The recording rule to print. |
Definition at line 1258 of file recordingextender.cpp.
Referenced by extendRecording(), finishRecording(), and unchangedRecording().
|
staticprivate |
Stop the current recording early.
The main idea behind having this function is to catch games that are called on account of rain, etc, and not record whatever random programming the network shows after the game is postponed.
ri | A pointer to the RecordingInfo for the recording to be extended. |
rr | A pointer to the RecordingRule for the recording to be extended. |
game | A reference to the current sporting event. |
Definition at line 1359 of file recordingextender.cpp.
Referenced by processActiveRecordings().
|
private |
Extend the current recording by XX minutes.
The first time this is done it creates a new override recording.
ri | A pointer to the RecordingInfo for the recording to be extended. |
rr | A pointer to the RecordingRule for the recording to be extended. |
game | A reference to the current sporting event. |
Definition at line 1381 of file recordingextender.cpp.
Referenced by processActiveRecordings().
|
staticprivate |
Log that this recording hasn't changed.
ri | A pointer to the RecordingInfo for the recording to be extended. |
rr | A pointer to the RecordingRule for the recording to be extended. |
game | A reference to the current sporting event. |
Definition at line 1441 of file recordingextender.cpp.
Referenced by processActiveRecordings().
|
private |
Process the list of newly started sports recordings.
Create an ActiveGame structure for this recording, and determine the URL to get data for this particular game.
Definition at line 1462 of file recordingextender.cpp.
Referenced by run().
|
private |
Process the currently active sports recordings.
Query provider for current game status. If the game finished early, stop it. If the game is still going and the recording is about to end, extend the recording. get data for this particular game.
Definition at line 1563 of file recordingextender.cpp.
Referenced by run().
|
private |
Is there any remaining work? Check for both newly created recording and for active recordings.
Definition at line 1650 of file recordingextender.cpp.
Referenced by run().
|
staticprivate |
Clean up a single team name for comparison against the ESPN API.
This means normalizing the Unicode, removing any diacritical marks, and removing any extraneous white space. For soccer, however, it also means removing a bunch of common sets of initials like "FC (Football Club)", "SC (Sports Club)", etc. that don't appear in the ESPN API.
[in] | info | A data structure defining the current sport. |
[in,out] | name | The sports team name to clean up. |
Definition at line 1274 of file recordingextender.cpp.
|
private |
Delete the list of the override rules that have been created by this instance of RecordingExtender.
No need to delete the actual rules, as they'll be cleaned up by the housekeeping code.
Definition at line 1454 of file recordingextender.cpp.
Referenced by run().
|
friend |
Definition at line 309 of file recordingextender.h.
|
staticprivate |
The single instance of a RecordingExtender.
Definition at line 346 of file recordingextender.h.
Referenced by checkDone(), and create().
|
staticprivate |
Interlock the scheduler thread crating this process, and this process determining whether it should continue running.
RecordingExtender ///.
Definition at line 349 of file recordingextender.h.
Referenced by checkDone(), and create().
Whether the RecordingExtender process is running.
Definition at line 351 of file recordingextender.h.
Referenced by checkDone(), and run().
|
private |
Pointer to the scheduler.
Needed to retrieve the scheduler's view of ongoing recordings.
Definition at line 354 of file recordingextender.h.
Referenced by create(), processActiveRecordings(), and processNewRecordings().
|
private |
New recordings are added by the scheduler process and removed by this process.
Definition at line 357 of file recordingextender.h.
Referenced by addNewRecording(), checkDone(), and processNewRecordings().
|
private |
Newly started recordings to process.
Definition at line 359 of file recordingextender.h.
Referenced by addNewRecording(), checkDone(), and processNewRecordings().
|
private |
Currently ongoing games to track.
Definition at line 361 of file recordingextender.h.
Referenced by checkDone(), processActiveRecordings(), and processNewRecordings().
|
private |
Recordings that have had an override rule creates.
Definition at line 363 of file recordingextender.h.
Referenced by checkDone(), expireOverrides(), and extendRecording().
|
private |