Difference between revisions of "Video pipeline"

From MythTV Official Wiki
Jump to: navigation, search
m
(Adding to Logic Flow ...)
Line 16: Line 16:
 
Each time a new playback is started, there is a new TV object created for it. A static method TV::StartTV calls static method TV::GetTV which creates the object. The TV::StartTV method is invoked when you start to play a video or recording and control remains in that method until the playback is done. Although it is called StartTV it handles Starting, playing and ending of the playback.
 
Each time a new playback is started, there is a new TV object created for it. A static method TV::StartTV calls static method TV::GetTV which creates the object. The TV::StartTV method is invoked when you start to play a video or recording and control remains in that method until the playback is done. Although it is called StartTV it handles Starting, playing and ending of the playback.
  
The TV::StartTV method calls TV::PlaybackLoop on the newly created TV object.
+
The TV::StartTV method calls TV::PlaybackLoop on the newly created TV object. The TV object contains a vector of PlayerContext objects, one for the main playback and one for each PIP or PBP additional playback that is happening at the same time. In most cases there will only be one (i.e. the main playback). Inside StartTV there is a while (true) loop that has a nested loop calling  MythPlayer::EventLoop and MythPlayer::VideoLoop for each player that is active. Each iteration of the while(true) loop is one frame of video display.
 +
 
 +
The MythPlayer class in libmythtv/mythplayer.cpp implements lower level aspects of playback. MythPlayer::VideoLoop processes one frame of video. MythPlayer::EventLoop is called between frame displays and checks for events such as keyboard or ir remote actions and controls the various actions than can be invoked.
 +
 
 +
Inside MythPlayer::VideoLoop is a call to MythPlayer::DisplayNormalFrame which processes the next frame of video, if it is available.
 +
 
 +
MythPlayer::DisplayNormalFrame calls MythPlayer::AVSync which synchronizes the next frame with the audio and gets it ready for display.
 +
 
 +
MythPlayer::AVSync determines if the video is in sync and calls the VideoSync class to wait an appropriate interval before displaying the frame. The VideoSync class is implemented in libmythtv/vsync.cpp. There are a number of implementations of VideoSync with classes for various methods of syncing. If audio and video are out of sync by more than a certain amount, AVSync adjust things by (1) dropping a frame (if video is behind), (2) doubling frame interval (if video is ahead), (3) Pausing audio (if video is behind
 +
). AVSync calls videoOutput->Show to actually show a frame on the screen.
 +
 
 +
VideoOutput::Show displays a frame on the screen. VideoOutput is an abstract base class in libmythtv/videooutbase.cpp. There are implementations of derived classes in several files named libmythtv/videoout_*.cpp, for the various output methods, such as OpenGL, VDPAU, etc.
  
 
To Be continued ...
 
To Be continued ...

Revision as of 23:01, 18 June 2017

The video playback mechanism in MythTV uses a common path for all of the types:

  • Recording playback.
  • Live TV.
  • Video playback.

There are checks in many places to do different things depending on the type. Live TV is just a recording and simultaneous playback, but does have many nuances for features such as channel changing and moving from one program to the next.

Logic Flow

Recording playback is invoked from the recording list window, which is themed at recordings-ui.xml. The window name is watchrecordings and it is implemented in class PlaybackBox in file programs/mythfrontend/playbackbox.cpp. The PlaybackBox::Play method calls the TV class to perform the playback.

In the case of watching videos playback is initiated from the Video list window, which is themed at video-ui.xml. The class name is VideoDialog and is implemented in mythfrontend/videodlg.cpp. The window name varies depending on which view is being used. The logic ultimately lands up in the TV class as well.

Playback is controlled by the TV class, which is implemented in libmythtv/tv_play.cpp. Do not be confused by the class name. Although the class is called TV it is used in Videos, Recordings and Live TV playback.

Each time a new playback is started, there is a new TV object created for it. A static method TV::StartTV calls static method TV::GetTV which creates the object. The TV::StartTV method is invoked when you start to play a video or recording and control remains in that method until the playback is done. Although it is called StartTV it handles Starting, playing and ending of the playback.

The TV::StartTV method calls TV::PlaybackLoop on the newly created TV object. The TV object contains a vector of PlayerContext objects, one for the main playback and one for each PIP or PBP additional playback that is happening at the same time. In most cases there will only be one (i.e. the main playback). Inside StartTV there is a while (true) loop that has a nested loop calling MythPlayer::EventLoop and MythPlayer::VideoLoop for each player that is active. Each iteration of the while(true) loop is one frame of video display.

The MythPlayer class in libmythtv/mythplayer.cpp implements lower level aspects of playback. MythPlayer::VideoLoop processes one frame of video. MythPlayer::EventLoop is called between frame displays and checks for events such as keyboard or ir remote actions and controls the various actions than can be invoked.

Inside MythPlayer::VideoLoop is a call to MythPlayer::DisplayNormalFrame which processes the next frame of video, if it is available.

MythPlayer::DisplayNormalFrame calls MythPlayer::AVSync which synchronizes the next frame with the audio and gets it ready for display.

MythPlayer::AVSync determines if the video is in sync and calls the VideoSync class to wait an appropriate interval before displaying the frame. The VideoSync class is implemented in libmythtv/vsync.cpp. There are a number of implementations of VideoSync with classes for various methods of syncing. If audio and video are out of sync by more than a certain amount, AVSync adjust things by (1) dropping a frame (if video is behind), (2) doubling frame interval (if video is ahead), (3) Pausing audio (if video is behind ). AVSync calls videoOutput->Show to actually show a frame on the screen.

VideoOutput::Show displays a frame on the screen. VideoOutput is an abstract base class in libmythtv/videooutbase.cpp. There are implementations of derived classes in several files named libmythtv/videoout_*.cpp, for the various output methods, such as OpenGL, VDPAU, etc.

To Be continued ...

Video Decode

- Describe how we decode a frame

Video Deinterlace

- How do we deinterlace frame(s)

Video Ouput

- How those frames then get to the display

Video Painters

- What does the video painter do?

Video Renderers

- What does the video renderer do?