MythTV  0.25-pre
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
PreviewGenerator Class Reference

This class creates a preview image of a recording. More...

#include <previewgenerator.h>

Inheritance diagram for PreviewGenerator:
MThread

List of all members.

Public Types

enum  Mode {
  kNone = 0x0, kLocal = 0x1, kRemote = 0x2, kLocalAndRemote = 0x3,
  kForceLocal = 0x5, kModeMask = 0x7
}
typedef enum PreviewGenerator::Mode Mode

Public Slots

void deleteLater ()

Public Member Functions

 PreviewGenerator (const ProgramInfo *pginfo, const QString &token, Mode mode=kLocal)
 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)
QString GetToken (void) const
void run (void)
 Run's the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
bool Run (void)
void AttachSignals (QObject *)

Protected Member Functions

virtual ~PreviewGenerator ()
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.
virtual bool event (QEvent *e)
bool SaveOutFile (const QByteArray &data, const QDateTime &dt)

Static Protected Member Functions

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

QWaitCondition previewWaitCondition
QMutex previewLock
ProgramInfo programInfo
Mode mode
QObject * listener
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
QString token
bool gotReply
bool pixmapOk

Friends

int preview_helper (uint chanid, QDateTime starttime, long long previewFrameNumber, long long previewSeconds, const QSize &previewSize, const QString &infile, const QString &outfile)

Detailed Description

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 26 of file previewgenerator.h.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
kNone 
kLocal 
kRemote 
kLocalAndRemote 
kForceLocal 
kModeMask 

Definition at line 39 of file previewgenerator.h.


Constructor & Destructor Documentation

PreviewGenerator::PreviewGenerator ( const ProgramInfo pginfo,
const 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 'local_only' should be set to true, otherwise the backend may deadlock if the PreviewGenerator cannot find the file.

Parameters:
pginfoProgramInfo for the recording we want a preview of.
local_onlyIf set to true, the preview will only be generated if the file is local.

Definition at line 67 of file previewgenerator.cpp.

PreviewGenerator::~PreviewGenerator ( ) [protected, virtual]

Definition at line 78 of file previewgenerator.cpp.


Member Function Documentation

void PreviewGenerator::SetPreviewTime ( long long  time,
bool  in_seconds 
) [inline]

Definition at line 54 of file previewgenerator.h.

Referenced by PreviewGeneratorQueue::GeneratePreviewImage().

void PreviewGenerator::SetPreviewTimeAsSeconds ( long long  seconds_in) [inline]

Definition at line 56 of file previewgenerator.h.

Referenced by Content::GetPreviewImage(), and preview_helper().

void PreviewGenerator::SetPreviewTimeAsFrameNumber ( long long  frame_number) [inline]

Definition at line 58 of file previewgenerator.h.

Referenced by preview_helper().

void PreviewGenerator::SetOutputFilename ( const QString &  fileName)
void PreviewGenerator::SetOutputSize ( const QSize &  size) [inline]
QString PreviewGenerator::GetToken ( void  ) const [inline]

Definition at line 63 of file previewgenerator.h.

Referenced by PreviewGeneratorQueue::SetPreviewGenerator().

void PreviewGenerator::run ( void  ) [virtual]

Run's the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note:
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 326 of file previewgenerator.cpp.

Definition at line 101 of file previewgenerator.cpp.

Referenced by PreviewGeneratorQueue::SetPreviewGenerator().

Definition at line 89 of file previewgenerator.cpp.

Referenced by deleteLater(), and ~PreviewGenerator().

Definition at line 335 of file previewgenerator.cpp.

Referenced by Run(), and RunReal().

Definition at line 601 of file previewgenerator.cpp.

Referenced by RunReal().

bool PreviewGenerator::IsLocal ( void  ) const [protected]

Definition at line 720 of file previewgenerator.cpp.

Referenced by Run(), and RunReal().

bool PreviewGenerator::RunReal ( void  ) [protected]

This call creates a preview without starting a new thread.

Definition at line 110 of file previewgenerator.cpp.

Referenced by preview_helper().

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.

Parameters:
pginfoRecording to grab from.
filenameFile containing recording.
seektimeSeconds or frames into the video to seek before capturing a frame.
time_in_secsif true time is in seconds, otherwise it is in frames.
bufferlenReturns size of buffer returned (in bytes).
video_widthReturns width of frame grabbed.
video_heightReturns height of frame grabbed.
video_aspectReturns aspect ratio of frame grabbed.
Returns:
Buffer allocated with new containing frame in RGBA32 format if successful, NULL otherwise.

Definition at line 758 of file previewgenerator.cpp.

Referenced by LocalPreviewRun().

bool PreviewGenerator::SavePreview ( QString  filename,
const unsigned char *  data,
uint  width,
uint  height,
float  aspect,
int  desired_width,
int  desired_height 
) [static, protected]

Definition at line 532 of file previewgenerator.cpp.

Referenced by LocalPreviewRun().

QString PreviewGenerator::CreateAccessibleFilename ( const QString &  pathname,
const QString &  outFileName 
) [static, protected]

Definition at line 689 of file previewgenerator.cpp.

Referenced by LocalPreviewRun().

bool PreviewGenerator::event ( QEvent *  e) [protected, virtual]

Definition at line 396 of file previewgenerator.cpp.

bool PreviewGenerator::SaveOutFile ( const QByteArray &  data,
const QDateTime &  dt 
) [protected]

Definition at line 467 of file previewgenerator.cpp.

Referenced by event().


Friends And Related Function Documentation

int preview_helper ( uint  chanid,
QDateTime  starttime,
long long  previewFrameNumber,
long long  previewSeconds,
const QSize &  previewSize,
const QString &  infile,
const QString &  outfile 
) [friend]

Definition at line 88 of file mythtv/programs/mythpreviewgen/main.cpp.


Member Data Documentation

QWaitCondition PreviewGenerator::previewWaitCondition [protected]

Definition at line 105 of file previewgenerator.h.

Referenced by event(), RemotePreviewRun(), and TeardownAll().

QMutex PreviewGenerator::previewLock [protected]

Definition at line 106 of file previewgenerator.h.

Referenced by AttachSignals(), event(), RemotePreviewRun(), Run(), and RunReal().

Definition at line 107 of file previewgenerator.h.

Referenced by LocalPreviewRun(), RemotePreviewRun(), Run(), RunReal(), and SaveOutFile().

Definition at line 109 of file previewgenerator.h.

Referenced by Run(), and RunReal().

QObject* PreviewGenerator::listener [protected]

Definition at line 110 of file previewgenerator.h.

Referenced by AttachSignals(), Run(), RunReal(), and TeardownAll().

QString PreviewGenerator::pathname [protected]

Definition at line 111 of file previewgenerator.h.

Referenced by IsLocal(), LocalPreviewRun(), Run(), and RunReal().

tells us whether to use time as seconds or frame number

Definition at line 114 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 116 of file previewgenerator.h.

Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().

QString PreviewGenerator::outFileName [protected]
QSize PreviewGenerator::outSize [protected]

Definition at line 118 of file previewgenerator.h.

Referenced by LocalPreviewRun(), RemotePreviewRun(), and Run().

QString PreviewGenerator::token [protected]

Definition at line 121 of file previewgenerator.h.

Referenced by event(), and RemotePreviewRun().

Definition at line 122 of file previewgenerator.h.

Referenced by event(), and RemotePreviewRun().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends