PreviewGenerator Class Reference

#include <previewgenerator.h>

List of all members.


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, 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
MythSocketserverSock
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)

Constructor & Destructor Documentation

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.

Parameters:
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.


Member Function Documentation

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]

void PreviewGenerator::SetOutputFilename ( const QString &  fileName  ) 

void PreviewGenerator::SetOutputSize ( const QSize &  size  )  [inline]

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   ) 

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]

void PreviewGenerator::TeardownAll ( void   )  [protected]

Definition at line 103 of file previewgenerator.cpp.

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

bool PreviewGenerator::RemotePreviewSetup ( void   )  [protected]

Definition at line 283 of file previewgenerator.cpp.

Referenced by RemotePreviewRun().

bool PreviewGenerator::RemotePreviewRun ( void   )  [protected]

Definition at line 292 of file previewgenerator.cpp.

Referenced by Run(), and RunReal().

void PreviewGenerator::RemotePreviewTeardown ( void   )  [protected]

Definition at line 414 of file previewgenerator.cpp.

Referenced by RemotePreviewRun().

bool PreviewGenerator::LocalPreviewRun ( void   )  [protected]

Definition at line 492 of file previewgenerator.cpp.

Referenced by RunReal().

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]

Definition at line 271 of file previewgenerator.cpp.

Referenced by Start().

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:
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.
Returns:
Buffer allocated with new containing frame in RGBA32 format if successful, NULL otherwise.

Definition at line 580 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 423 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().


Friends And Related Function Documentation

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.


Member Data Documentation

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().

Definition at line 87 of file previewgenerator.h.

Referenced by Start().

Definition at line 90 of file previewgenerator.h.

Referenced by Run(), and RunReal().

Definition at line 91 of file previewgenerator.h.

Referenced by AttachSignals(), disconnectSafe(), and TeardownAll().

Definition at line 92 of file previewgenerator.h.

Referenced by PreviewRun(), and RemotePreviewRun().

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().

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().


The documentation for this class was generated from the following files:

Generated on Sat Dec 18 05:16:09 2010 for MythTV by  doxygen 1.5.5