MythTV Architecture
pre-0.23
Over the last couple years MythTV has grown into a rather large application. The purpose of these pages is to provide a portal into the code for developers to get their heads around it. This is intended for both those new to MythTV and experienced with it to get familiar with different aspects of the code base.
If you are just looking for the code formatting standards, see the official MythTV wiki article coding standards. If you are looking for the bug tracker, it can be found on the official pages. If you haven't already, you should subscribe to the developer mailing list and the SVN commits mailing list
If you just stumbled onto the developer pages by accident, maybe you want to go to the official MythTV Installation page. There is also a good unofficial Fedora MythTV installation page, and a Gentoo MythTV installation page.
If you are new to Qt programming it is essential that you keep in mind that almost all Qt objects are not thread-safe, including QString. Almost all Qt container objects, including QString, make shallow copies on assignment, the two copies of the object must only be used in one thread unless you use a lock on the object. You can use the QDeepCopy template on most Qt containers to make a copy you can use in another thread.
There are some special dangers when using QObject outside the Qt event thread.
There is a short HOWTO on Profiling MythTV available in addition to documentation on the code itself.
There are also a few simple testing shortcuts.
MythTV is divided up into 17 libraries:
- libmythdb
- Lowest-level MythTV library. Used by the Plugins. Contains the database, LCD, and network support code (used by the myth network protocol).
This also contains some other basic functionality and classes which are used by one or more of libmyth, libmythui and libmythtv.
Any changes to this library's ABI may trigger a myth binary version change because the plugins depend on it.
- libmythui
- Main user interface rendering library. Used by the Plugins. The mouse/touchscreen gesture, remote control (LIRC and AppleRemote) and screen saver control code are also contained in this library.
This library depends on libmyth. Any changes to this library's ABI may trigger a myth binary version change because the plugins depend on it.
- libmythupnp
- Initial uPnP (universal Plug and Play) support
This library depends on libmythdb.
- libmyth
- Core MythTV library. Used by the Plugins. The audio, language support, plugin manager, media manager, and some UI widgets are implemented by libmyth.
This library depends on both libmyth, libmythupnp and libmythui. Any changes to this library's ABI may trigger a myth binary version change because the plugins depend on it.
- libmythtv
- MythTV TV functionality library. Used by some Plugins. The OSD, recorders, video and A/V players are supported by libmythtv.
This library depends on libmythdb, libmythui and libmyth. It also depends on avlib, libmythmpeg2, libmythsamplerate, libmythsoundtouch, libdvdnav, libfreemheg and liblivemedia.
This library is used by some plugins so changes to it's ABI may require a myth binary version change.
Any changes to classes that are serialized by the myth network protocol (for example ProgramInfo) or to the protocol itself require the protocol version number to be incremented.
- libavcodec/libavformat/libavutil/libpostproc/libswscale
- These together form the FFmpeg A/V decoding library (aka avlib). Documented Externally.
These should be modified as little as possible, and any changes should be sent upstream for inclusion in the FFmpeg project's version of these libraries.
These libraries do not depend on any of our libraries.
- libmythmpeg2
- Alternate MPEG-1/2 A/V decoding library. External Website.
This is an alternate MPEG-2 decoding library. It is offered as an option for software decoding of MPEG-1 and MPEG-2 files. FFmpeg is still used for decoding MPEG still frames when this library is selected for playback.
This library does not depend on any of our libraries.
- libmythsamplerate
- Audio resampling library Documented Externally. We use this to support different output sample rates than the sample rate used in the audio streams we play.
This library does not depend on any of our libraries.
- libmythsoundtouch
- Pitch preserving audio resampling library. External Website. We use this for the time-stretch feature.
This library does not depend on any of our libraries.
- libmythdvdnav
- Used for navigating DVD menus when using the internal player
This library should not depend on any of our libraries.
- libmythfreemheg
- UK interactive TV viewer
This library does not depend on any of our libraries.
- libmythlivemedia
- Support for the FreeBox recorder device
This library does not depend on any of our libraries.
- libmythhdhomerun
- Support for the HDHomeRun recorder device
This library does not depend on any of our libraries.
Two libraries libmythmpeg2 and libmythsamplerate appear redundant, but libmpeg2 decodes MPEG-2 more quickly than ffmpeg on some systems, and libmythsamplerate resamples audio with better quality when we only need to match the hardware sample rate to the A/V streams audio sample rate.
The database schema is documented here
MythTV Database Schema.
MythTV contains 12 applications which are installed by make install
- mythbackend
- This is the backend server which runs the recorders. On frontend only systems, the binary needs to be installed to perform some functions for the frontend, but does not need to be constantly running -- the frontend will run it as needed.
- mythfrontend
- This is the frontend which is the main application for viewing programs and using the MythTV plugins.
- mythtv-setup
- This is the program which sets up the database to use a machine as a backend server.
- mythavtest
- For testing audio and video playback. Was once an "External Player" used to play video files from within mythfrontend. Setting the player command to "internal" achieves the same thing now.
- mythtvosd
- This is used externally by programs that want to pop-up an on screen display in MythTV while one is watching a recording.
- mythfilldatabase
- This is used both internally and externally to fetch program listings. Tribune Media provides listings in exchange for demographic information in the USA, and Australia has a community-driven TV guide originally developed for OzTiVo. Other markets are served by the XMLTV web spiders.
- mythtranscode
- This is used both internally and externally to transcode videos from one format to another. This is used to shrink HDTV programs to lower quality recordings that match the hardware the user has.
- mythjobqueue
- This can be run on a frontend only system instead of mythbackend to handle commercial flagging, transcode and user jobs. The only advantage over running a full mythbackend is to use sligtly less memory.
- mythcommflag
- This is used internally by mythfrontend to flag commercials. It can also be used to repair keyframe maps for recordings.
- mythlcdserver
- This is an interface between a number of Myth clients and a small text display (LCDProc server).
- mythwelcome/mythshutdown
- These programs manage Power Saving (shutdown/wakeup) on your Myth PCs.
- mytharchive
- Creates themed Video DVDs from recordings (and other video files).
- mythbrowser
- Provides a simple web browser.
- mythflix
- An interface to the NetFlix DVD/BluRay rental service.
- mythgallery
- A simple picture viewer for your TV.
- mythgame
- Launches the xmame classic game system emulator.
- mythmovies
- Looks up movie times at local cinemas.
- mythmusic
- A simple music player for your TV.
- mythnews
- Browses RSS news feeds.
- mythvideo
- Launch DVD players, and a Video Browser for other files (non-MythTV recordings).
- mythweather
- Presents your local weather report.
- mythzoneminder
- Video surveilance system interface.
- mythweb
- Provides a PHP based web pages to control mythbackend.
These tools are in the packaging repository:
- osx-packager.pl
- Downloads and builds all dependencies, then the source, of MythTV and all the official plugins, on Mac OS 10.3 thru 10.5
- win32-packager.pl
- Similar tool for Windows XP and Vista