#include <previewgenerator.h>
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, creating a sockets the the backend if the recording is not local.
Run(void) will process the request in the current thread, and it uses the MythContext's server and event sockets if the recording is not local.
The PreviewGenerator will send Qt signals when the preview is ready and when the preview thread finishes running if Start(void) was called.
Definition at line 15 of file previewgenerator.h.
Public Slots | |
| void | deleteLater () |
Signals | |
| void | previewThreadDone (const QString &, bool &) |
| void | previewReady (const ProgramInfo *) |
Public Member Functions | |
| PreviewGenerator (const ProgramInfo *pginfo, bool local_only=true) | |
| Constructor. | |
| void | SetPreviewTime (long long time, bool in_seconds) |
| void | SetPreviewTimeAsSeconds (long long seconds_in) |
| void | SetPreviewTimeAsFrameNumber (long long frame_number) |
| void | SetOutputFilename (const QString &) |
| void | SetOutputSize (const QSize &size) |
| void | Start (void) |
| This call starts a thread that will create a preview. | |
| bool | Run (void) |
| void | AttachSignals (QObject *) |
| void | disconnectSafe (void) |
| disconnects signals while holding previewLock, ensuring that no one will receive a signal from this class after this call. | |
Static Public Attributes | |
| static const char * | kInUseID = "preview_generator" |
Protected Member Functions | |
| virtual | ~PreviewGenerator () |
| void | TeardownAll (void) |
| bool | RemotePreviewSetup (void) |
| bool | RemotePreviewRun (void) |
| void | RemotePreviewTeardown (void) |
| bool | LocalPreviewRun (void) |
| bool | IsLocal (void) const |
| bool | RunReal (void) |
| This call creates a preview without starting a new thread. | |
Static Protected Member Functions | |
| static void * | PreviewRun (void *) |
| static char * | GetScreenGrab (const ProgramInfo *pginfo, const QString &filename, long long seektime, bool time_in_secs, int &bufferlen, int &video_width, int &video_height, float &video_aspect) |
| Returns a PIX_FMT_RGBA32 buffer containg a frame from the video. | |
| static bool | SavePreview (QString filename, const unsigned char *data, uint width, uint height, float aspect, int desired_width, int desired_height) |
| static QString | CreateAccessibleFilename (const QString &pathname, const QString &outFileName) |
Protected Attributes | |
| QMutex | previewLock |
| pthread_t | previewThread |
| ProgramInfo | programInfo |
| bool | localOnly |
| bool | isConnected |
| bool | createSockets |
| MythSocket * | serverSock |
| QString | pathname |
| bool | timeInSeconds |
| tells us whether to use time as seconds or frame number | |
| long long | captureTime |
| snapshot time in seconds or frame number, depending on timeInSeconds | |
| QString | outFileName |
| QSize | outSize |
Friends | |
| int | preview_helper (const QString &chanid, const QString &starttime, long long previewFrameNumber, long long previewSeconds, const QSize &previewSize, const QString &infile, const QString &outfile) |
| PreviewGenerator::PreviewGenerator | ( | const ProgramInfo * | pginfo, | |
| bool | local_only = true | |||
| ) |
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 'local_only' should be set to true, otherwise the backend may deadlock if the PreviewGenerator can not find the file.
| pginfo | ProgramInfo for the recording we want a preview of. | |
| local_only | If set to true, the preview will only be generated if the file is local. |
Definition at line 66 of file previewgenerator.cpp.
| PreviewGenerator::~PreviewGenerator | ( | ) | [protected, virtual] |
Definition at line 93 of file previewgenerator.cpp.
| void PreviewGenerator::SetPreviewTime | ( | long long | time, | |
| bool | in_seconds | |||
| ) | [inline] |
Definition at line 29 of file previewgenerator.h.
Referenced by MainServer::HandleGenPreviewPixmap().
| void PreviewGenerator::SetPreviewTimeAsSeconds | ( | long long | seconds_in | ) | [inline] |
Definition at line 31 of file previewgenerator.h.
Referenced by MythXML::GetPreviewImage(), and preview_helper().
| void PreviewGenerator::SetPreviewTimeAsFrameNumber | ( | long long | frame_number | ) | [inline] |
Definition at line 33 of file previewgenerator.h.
Referenced by preview_helper(), NetworkControl::saveScreenshot(), and TV::ScreenShot().
| void PreviewGenerator::SetOutputFilename | ( | const QString & | fileName | ) |
Definition at line 98 of file previewgenerator.cpp.
Referenced by MythXML::GetPreviewImage(), MainServer::HandleGenPreviewPixmap(), preview_helper(), NetworkControl::saveScreenshot(), and TV::ScreenShot().
| void PreviewGenerator::SetOutputSize | ( | const QSize & | size | ) | [inline] |
Definition at line 36 of file previewgenerator.h.
Referenced by MainServer::HandleGenPreviewPixmap(), preview_helper(), NetworkControl::saveScreenshot(), and TV::ScreenShot().
| void PreviewGenerator::Start | ( | void | ) |
This call starts a thread that will create a preview.
Definition at line 156 of file previewgenerator.cpp.
| bool PreviewGenerator::Run | ( | void | ) |
Definition at line 194 of file previewgenerator.cpp.
Referenced by MythXML::GetPreviewImage(), MainServer::HandleGenPreviewPixmap(), PreviewRun(), NetworkControl::saveScreenshot(), and TV::ScreenShot().
| void PreviewGenerator::AttachSignals | ( | QObject * | obj | ) |
Definition at line 132 of file previewgenerator.cpp.
Referenced by PlaybackBox::SetPreviewGenerator().
| void PreviewGenerator::disconnectSafe | ( | void | ) |
disconnects signals while holding previewLock, ensuring that no one will receive a signal from this class after this call.
Definition at line 146 of file previewgenerator.cpp.
Referenced by TeardownAll().
| void PreviewGenerator::previewThreadDone | ( | const QString & | , | |
| bool & | ||||
| ) | [signal] |
Referenced by AttachSignals(), and TeardownAll().
| void PreviewGenerator::previewReady | ( | const ProgramInfo * | ) | [signal] |
Referenced by AttachSignals(), and Run().
| void PreviewGenerator::deleteLater | ( | void | ) | [slot] |
Definition at line 126 of file previewgenerator.cpp.
Referenced by MythXML::GetPreviewImage(), MainServer::HandleGenPreviewPixmap(), preview_helper(), PreviewRun(), NetworkControl::saveScreenshot(), and TV::ScreenShot().
| void PreviewGenerator::TeardownAll | ( | void | ) | [protected] |
Definition at line 103 of file previewgenerator.cpp.
Referenced by deleteLater(), and ~PreviewGenerator().
| bool PreviewGenerator::RemotePreviewSetup | ( | void | ) | [protected] |
| bool PreviewGenerator::RemotePreviewRun | ( | void | ) | [protected] |
| void PreviewGenerator::RemotePreviewTeardown | ( | void | ) | [protected] |
| bool PreviewGenerator::LocalPreviewRun | ( | void | ) | [protected] |
| bool PreviewGenerator::IsLocal | ( | void | ) | const [protected] |
Definition at line 558 of file previewgenerator.cpp.
Referenced by PreviewGenerator(), Run(), and RunReal().
| bool PreviewGenerator::RunReal | ( | void | ) | [protected] |
This call creates a preview without starting a new thread.
Definition at line 166 of file previewgenerator.cpp.
Referenced by preview_helper().
| void * PreviewGenerator::PreviewRun | ( | void * | param | ) | [static, protected] |
| char * PreviewGenerator::GetScreenGrab | ( | const ProgramInfo * | pginfo, | |
| const QString & | filename, | |||
| long long | seektime, | |||
| bool | time_in_secs, | |||
| int & | bufferlen, | |||
| int & | video_width, | |||
| int & | video_height, | |||
| float & | video_aspect | |||
| ) | [static, protected] |
Returns a PIX_FMT_RGBA32 buffer containg a frame from the video.
| pginfo | Recording to grab from. | |
| filename | File containing recording. | |
| seektime | Seconds or frames into the video to seek before capturing a frame. | |
| time_in_secs | if true time is in seconds, otherwise it is in frames. | |
| 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 580 of file previewgenerator.cpp.
Referenced by LocalPreviewRun().
| QString PreviewGenerator::CreateAccessibleFilename | ( | const QString & | pathname, | |
| const QString & | outFileName | |||
| ) | [static, protected] |
Definition at line 527 of file previewgenerator.cpp.
Referenced by LocalPreviewRun(), and RemotePreviewRun().
| int preview_helper | ( | const QString & | chanid, | |
| const QString & | starttime, | |||
| long long | previewFrameNumber, | |||
| long long | previewSeconds, | |||
| const QSize & | previewSize, | |||
| const QString & | infile, | |||
| const QString & | outfile | |||
| ) | [friend] |
Definition at line 285 of file mythtv/programs/mythbackend/main.cpp.
const char * PreviewGenerator::kInUseID = "preview_generator" [static] |
Definition at line 44 of file previewgenerator.h.
Referenced by GetScreenGrab(), LocalPreviewRun(), and ProgramInfo::MarkAsInUse().
QMutex PreviewGenerator::previewLock [protected] |
Definition at line 86 of file previewgenerator.h.
Referenced by AttachSignals(), disconnectSafe(), Run(), and TeardownAll().
pthread_t PreviewGenerator::previewThread [protected] |
ProgramInfo PreviewGenerator::programInfo [protected] |
Definition at line 88 of file previewgenerator.h.
Referenced by LocalPreviewRun(), PreviewGenerator(), RemotePreviewRun(), Run(), and TeardownAll().
bool PreviewGenerator::localOnly [protected] |
bool PreviewGenerator::isConnected [protected] |
Definition at line 91 of file previewgenerator.h.
Referenced by AttachSignals(), disconnectSafe(), and TeardownAll().
bool PreviewGenerator::createSockets [protected] |
Definition at line 92 of file previewgenerator.h.
Referenced by PreviewRun(), and RemotePreviewRun().
MythSocket* PreviewGenerator::serverSock [protected] |
Definition at line 93 of file previewgenerator.h.
Referenced by RemotePreviewRun(), RemotePreviewSetup(), and RemotePreviewTeardown().
QString PreviewGenerator::pathname [protected] |
Definition at line 94 of file previewgenerator.h.
Referenced by IsLocal(), LocalPreviewRun(), PreviewGenerator(), Run(), and RunReal().
bool PreviewGenerator::timeInSeconds [protected] |
tells us whether to use time as seconds or frame number
Definition at line 97 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().
long long PreviewGenerator::captureTime [protected] |
snapshot time in seconds or frame number, depending on timeInSeconds
Definition at line 99 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().
QString PreviewGenerator::outFileName [protected] |
Definition at line 100 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), Run(), and SetOutputFilename().
QSize PreviewGenerator::outSize [protected] |
Definition at line 101 of file previewgenerator.h.
Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().
1.5.5