MythTV
master
|
This class creates a preview image of a recording. More...
#include <libmythtv/previewgenerator.h>
Public Types | |
enum | Mode : std::uint8_t { kNone = 0x0, kLocal = 0x1, kRemote = 0x2, kLocalAndRemote = 0x3, kForceLocal = 0x5, kModeMask = 0x7 } |
Public Slots | |
void | deleteLater () |
Public Member Functions | |
PreviewGenerator (const ProgramInfo *pginfo, QString token, Mode mode=kLocal) | |
Constructor. More... | |
void | SetPreviewTime (std::chrono::seconds time, long long frame) |
void | SetPreviewTimeAsSeconds (std::chrono::seconds seconds) |
void | SetPreviewTimeAsFrameNumber (long long frame_number) |
void | SetOutputFilename (const QString &fileName) |
void | SetOutputSize (const QSize size) |
QString | GetToken (void) const |
void | run (void) override |
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More... | |
bool | Run (void) |
void | AttachSignals (QObject *obj) |
Public Member Functions inherited from MThread | |
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... | |
Protected Member Functions | |
~PreviewGenerator () override | |
void | TeardownAll (void) |
bool | RemotePreviewRun (void) |
bool | LocalPreviewRun (void) |
bool | IsLocal (void) const |
bool | RunReal (void) |
This call creates a preview without starting a new thread. More... | |
bool | event (QEvent *e) override |
bool | SaveOutFile (const QByteArray &data, const QDateTime &dt) |
Protected Member Functions inherited from MThread | |
int | exec (void) |
Enters the qt event loop. call exit or quit to exit thread. More... | |
Static Protected Member Functions | |
static char * | GetScreenGrab (const ProgramInfo &pginfo, const QString &filename, std::chrono::seconds seektime, long long seekframe, int &bufferlen, int &video_width, int &video_height, float &video_aspect) |
Returns a AV_PIX_FMT_RGBA32 buffer containg a frame from the video. More... | |
static bool | SavePreview (const QString &filename, const unsigned char *data, uint width, uint height, float aspect, int desired_width, int desired_height, const QString &format) |
static QString | CreateAccessibleFilename (const QString &pathname, const QString &outFileName) |
Static Protected Member Functions inherited from MThread | |
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) |
Protected Attributes | |
QWaitCondition | m_previewWaitCondition |
QMutex | m_previewLock |
ProgramInfo | m_programInfo |
Mode | m_mode |
QObject * | m_listener {nullptr} |
QString | m_pathname |
std::chrono::seconds | m_captureTime {-1s} |
snapshot time in seconds or frame number (seconds has priority) More... | |
long long | m_captureFrame {-1} |
QString | m_outFileName |
QSize | m_outSize {0,0} |
QString | m_outFormat {"PNG"} |
QString | m_token |
bool | m_gotReply {false} |
bool | m_pixmapOk {false} |
Protected Attributes inherited from MThread | |
MThreadInternal * | m_thread {nullptr} |
QRunnable * | m_runnable {nullptr} |
bool | m_prologExecuted {true} |
bool | m_epilogExecuted {true} |
Friends | |
int | preview_helper (uint chanid, QDateTime starttime, long long previewFrameNumber, std::chrono::seconds previewSeconds, QSize previewSize, const QString &infile, const QString &outfile) |
Additional Inherited Members | |
Static Public Member Functions inherited from MThread | |
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) |
This class creates a preview image of a recording.
The usage is simple: First, pass a ProgramInfo whose pathname points to a local or remote recording to the constructor. Then call either start(void) or Run(void) to generate the preview.
start(void) will create a thread that processes the request.
Run(void) will block until the preview completes.
The PreviewGenerator will send a PREVIEW_SUCCESS or a PREVIEW_FAILED event when the preview completes or fails.
Definition at line 27 of file previewgenerator.h.
enum PreviewGenerator::Mode : std::uint8_t |
Enumerator | |
---|---|
kNone | |
kLocal | |
kRemote | |
kLocalAndRemote | |
kForceLocal | |
kModeMask |
Definition at line 40 of file previewgenerator.h.
PreviewGenerator::PreviewGenerator | ( | const ProgramInfo * | pginfo, |
QString | token, | ||
PreviewGenerator::Mode | mode = kLocal |
||
) |
Constructor.
ProgramInfo::pathname must include recording prefix, so that the file can be found on the file system for local preview generation. When called by the backend 'mode' should be set to kLocal, otherwise the backend may deadlock if the PreviewGenerator cannot find the file.
pginfo | ProgramInfo for the recording we want a preview of. |
token | A token value used to match up this request with the response from the backend. If a token isn't provided, the code will generate one. |
mode | Specify the location where the file must exist in order to be processed. |
Definition at line 73 of file previewgenerator.cpp.
|
overrideprotected |
Definition at line 87 of file previewgenerator.cpp.
|
inline |
Definition at line 55 of file previewgenerator.h.
|
inline |
Definition at line 57 of file previewgenerator.h.
|
inline |
Definition at line 59 of file previewgenerator.h.
void PreviewGenerator::SetOutputFilename | ( | const QString & | fileName | ) |
Definition at line 93 of file previewgenerator.cpp.
Referenced by SaveOutFile().
|
inline |
Definition at line 62 of file previewgenerator.h.
|
inline |
Definition at line 64 of file previewgenerator.h.
Referenced by PreviewGeneratorQueue::SetPreviewGenerator().
|
overridevirtual |
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Reimplemented from MThread.
Definition at line 348 of file previewgenerator.cpp.
bool PreviewGenerator::Run | ( | void | ) |
Definition at line 208 of file previewgenerator.cpp.
Referenced by run().
void PreviewGenerator::AttachSignals | ( | QObject * | obj | ) |
Definition at line 115 of file previewgenerator.cpp.
Referenced by PreviewGeneratorQueue::SetPreviewGenerator().
|
slot |
Definition at line 109 of file previewgenerator.cpp.
Referenced by PreviewGeneratorQueue::SetPreviewGenerator().
|
protected |
Definition at line 102 of file previewgenerator.cpp.
Referenced by deleteLater(), and ~PreviewGenerator().
|
protected |
Definition at line 355 of file previewgenerator.cpp.
|
protected |
Definition at line 634 of file previewgenerator.cpp.
Referenced by RunReal().
|
protected |
Definition at line 756 of file previewgenerator.cpp.
|
protected |
This call creates a preview without starting a new thread.
Definition at line 124 of file previewgenerator.cpp.
|
staticprotected |
Returns a AV_PIX_FMT_RGBA32 buffer containg a frame from the video.
pginfo | Recording to grab from. |
filename | File containing recording. |
seektime | Seconds into the video to seek before capturing a frame. This field has priority. If it is set to -1s then seekframe will be used. |
seekframe | Frames into the video to seek before capturing a frame. |
bufferlen | Returns size of buffer returned (in bytes). |
video_width | Returns width of frame grabbed. |
video_height | Returns height of frame grabbed. |
video_aspect | Returns aspect ratio of frame grabbed. |
Definition at line 795 of file previewgenerator.cpp.
Referenced by LocalPreviewRun().
|
staticprotected |
Definition at line 567 of file previewgenerator.cpp.
Referenced by LocalPreviewRun().
|
staticprotected |
Definition at line 725 of file previewgenerator.cpp.
Referenced by LocalPreviewRun().
|
overrideprotected |
Definition at line 424 of file previewgenerator.cpp.
|
protected |
Definition at line 502 of file previewgenerator.cpp.
Referenced by event().
|
friend |
Definition at line 66 of file mythpreviewgen.cpp.
|
protected |
Definition at line 107 of file previewgenerator.h.
Referenced by event(), RemotePreviewRun(), and TeardownAll().
|
protected |
Definition at line 108 of file previewgenerator.h.
Referenced by AttachSignals(), event(), RemotePreviewRun(), Run(), RunReal(), and TeardownAll().
|
protected |
Definition at line 109 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), Run(), RunReal(), and SaveOutFile().
|
protected |
Definition at line 111 of file previewgenerator.h.
|
protected |
Definition at line 112 of file previewgenerator.h.
Referenced by AttachSignals(), Run(), RunReal(), and TeardownAll().
|
protected |
Definition at line 113 of file previewgenerator.h.
Referenced by IsLocal(), LocalPreviewRun(), Run(), and RunReal().
|
protected |
snapshot time in seconds or frame number (seconds has priority)
Definition at line 116 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().
|
protected |
Definition at line 117 of file previewgenerator.h.
Referenced by RemotePreviewRun(), and Run().
|
protected |
Definition at line 118 of file previewgenerator.h.
Referenced by IsLocal(), LocalPreviewRun(), RemotePreviewRun(), Run(), RunReal(), SaveOutFile(), and SetOutputFilename().
|
protected |
Definition at line 119 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().
|
protected |
Definition at line 120 of file previewgenerator.h.
Referenced by LocalPreviewRun(), and SetOutputFilename().
|
protected |
Definition at line 122 of file previewgenerator.h.
Referenced by event(), RemotePreviewRun(), Run(), and RunReal().
Definition at line 123 of file previewgenerator.h.
Referenced by event(), and RemotePreviewRun().
Definition at line 124 of file previewgenerator.h.
Referenced by event(), and RemotePreviewRun().