VideoSync Class Reference

Virtual base class for all video synchronization classes. More...

#include <vsync.h>

Inheritance diagram for VideoSync:
BusyWaitVideoSync DRMVideoSync DummyVideoSync RTCVideoSync USleepVideoSync

List of all members.

Public Member Functions

 VideoSync (VideoOutput *, int fi, int ri, bool intr)
 Used by BestMethod(VideoOutput*,uint,uint,bool) to initialize video synchronization method.
virtual ~VideoSync ()
virtual QString getName (void) const =0
 Returns name of instanciated VSync method.
virtual bool TryInit (void)=0
 Tries to initialize VSync method.
virtual void Start (void)
 Start VSync; must be called from main thread.
virtual int WaitForFrame (int sync_delay)=0
 Waits for next a frame or field.
int getRefreshInterval (void) const
 Returns the (minimum) refresh interval of the output device.
void setRefreshInterval (int ri)
 Sets the refresh interval of the output device.
virtual void setFrameInterval (int fi)
virtual void Stop (void)
 Stops VSync; must be called from main thread.

Static Public Member Functions

static VideoSyncBestMethod (VideoOutput *, uint frame_interval, uint refresh_interval, bool interlaced)
 Returns the most sophisticated video sync method available.

Protected Member Functions

int64_t GetTime (void)
int CalcDelay (void)
 Calculates the delay to the next frame.
void KeepPhase (void)
 Keep our nexttrigger from drifting too close to the exact retrace.

Protected Attributes

VideoOutputm_video_output
int m_frame_interval
int m_refresh_interval
bool m_interlaced
int64_t m_nexttrigger
int m_delay

Static Protected Attributes

static int m_forceskip = 0

Detailed Description

Virtual base class for all video synchronization classes.

This set of classes implements a variety of algorithms for synching video frames to a display. The better algorithms synchronize to the display's refresh rate, and also attempt to maintain phase with respect to the vertical retrace. The poorer algorithms simply try to display frames at a regular interval.

The factory method BestMethod tries subclasses in roughly quality order until one succeeds.

A/V sync methods may supply the nominal delay per frame. Other than that, video timing is entirely up to these classes. When WaitForFrame returns, it is time to show the frame.

Definition at line 45 of file vsync.h.


Constructor & Destructor Documentation

VideoSync::VideoSync ( VideoOutput video_output,
int  fi,
int  ri,
bool  intr 
)

Used by BestMethod(VideoOutput*,uint,uint,bool) to initialize video synchronization method.

Definition at line 115 of file vsync.cpp.

virtual VideoSync::~VideoSync (  )  [inline, virtual]

Definition at line 50 of file vsync.h.


Member Function Documentation

virtual QString VideoSync::getName ( void   )  const [pure virtual]

Returns name of instanciated VSync method.

Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.

Referenced by MythPlayer::InitAVSync().

virtual bool VideoSync::TryInit ( void   )  [pure virtual]

Tries to initialize VSync method.

Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.

void VideoSync::Start ( void   )  [virtual]

Start VSync; must be called from main thread.

Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.

Reimplemented in DRMVideoSync.

Definition at line 131 of file vsync.cpp.

Referenced by MythPlayer::DisplayPauseFrame(), MythPlayer::InitAVSync(), MythPlayer::PrebufferEnoughFrames(), and MythPlayer::VideoStart().

virtual int VideoSync::WaitForFrame ( int  sync_delay  )  [pure virtual]

Waits for next a frame or field.

Returns delay to real frame timing in usec

Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.

Parameters:
sync_delay time until the desired frame or field
See also:
CalcDelay(void), KeepPhase(void)

Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.

Referenced by MythPlayer::AVSync().

int VideoSync::getRefreshInterval ( void   )  const [inline]

Returns the (minimum) refresh interval of the output device.

Definition at line 78 of file vsync.h.

Referenced by MythPlayer::CanSupportDoubleRate(), and MythPlayer::ReinitVideo().

void VideoSync::setRefreshInterval ( int  ri  )  [inline]

Sets the refresh interval of the output device.

Definition at line 80 of file vsync.h.

Referenced by MythPlayer::ReinitVideo().

virtual void VideoSync::setFrameInterval ( int  fi  )  [inline, virtual]

Definition at line 82 of file vsync.h.

Referenced by MythPlayer::ChangeSpeed(), and MythPlayer::SetVideoParams().

virtual void VideoSync::Stop ( void   )  [inline, virtual]

Stops VSync; must be called from main thread.

Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.

Definition at line 90 of file vsync.h.

VideoSync * VideoSync::BestMethod ( VideoOutput video_output,
uint  frame_interval,
uint  refresh_interval,
bool  interlaced 
) [static]

Returns the most sophisticated video sync method available.

Definition at line 76 of file vsync.cpp.

Referenced by MythPlayer::VideoStart().

int64_t VideoSync::GetTime ( void   )  [protected]

Definition at line 124 of file vsync.cpp.

Referenced by CalcDelay(), and Start().

int VideoSync::CalcDelay ( void   )  [protected]

Calculates the delay to the next frame.

Regardless of the timing method, if delay is greater than four full frames (could be greater than 20 or greater than 200), we don't want to freeze while waiting for a huge delay. Instead, contine playing video at half speed and continue to read new audio and video frames from the file until the sync is 'in the ballpark'. Also prevent the nexttrigger from falling too far in the past in case we are trying to speed up video output faster than possible.

Definition at line 147 of file vsync.cpp.

Referenced by USleepVideoSync::WaitForFrame(), BusyWaitVideoSync::WaitForFrame(), RTCVideoSync::WaitForFrame(), and DRMVideoSync::WaitForFrame().

void VideoSync::KeepPhase ( void   )  [protected]

Keep our nexttrigger from drifting too close to the exact retrace.

If delay is near zero, some frames will be delay < 0 and others delay > 0 which would cause continous rapid fire stuttering. This method is only useful for those sync methods where WaitForFrame targets hardware retrace rather than targeting nexttrigger. NOTE: deprecated in favor of handling phase issues in mythplayer's AVSync.

Definition at line 192 of file vsync.cpp.


Member Data Documentation

Definition at line 101 of file vsync.h.

int VideoSync::m_frame_interval [protected]

Definition at line 102 of file vsync.h.

Referenced by CalcDelay(), setFrameInterval(), and BusyWaitVideoSync::WaitForFrame().

Definition at line 104 of file vsync.h.

Referenced by CalcDelay().

int VideoSync::m_delay [protected]
int VideoSync::m_forceskip = 0 [static, protected]

Definition at line 108 of file vsync.h.

Referenced by BestMethod().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Fri May 25 06:42:31 2012 for MythTV by  doxygen 1.6.3