Introduction

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 new to Qt programming it is essential that you keep in mind that almost all Qt objects are not thread-safe, including QString. The Qt containers QMap, QSet, QHash, QString, QList, etc are copy-on-write containers. This means that when you assign one container from another the data isn't actually copied. Instead a copy of a pointer to the data is made and the reference count is increased. Then when you actually modify the date or get a modifiable reference into the container an actual copy is made. This means you can return one of these containers efficiently from a function without needing C++11 support. This also means these containers are a bit less efficient than their STL equivalents most of the time. We still prefer them in MythTV code, especially QString due to the extensive i18n support in Qt. QList is actually equivalent to an STL deque. We also use the STL style iterators. This is both because it makes it easier to switch to an STL container in the rare case when it is necessary, such as when we need a reverse iterator iterator, and because they are more efficient than the Java style iterators that Qt also supports.

In Qt 3.x and Qt 4.0 assignment of one Qt copy-on-write was not yet thread-safe. Because of this you will see a number of ::detach() calls in MythTV code. These calls force a deep copy to be made immediately and should either be removed or a comment should be added in the rare case where this is done as an optimization and not just a hold-over from when copy-on-write wasn't yet thread-safe in Qt 4.0 and earlier.

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.

Libraries

Contains the \ref database_subsystem "database",
and network support code (used by the
\ref myth_network_protocol "MythTV network protocol" and
\ref lcd_subsystem "LCDproc interface").
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 MythTV 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
(\ref lirc_subsystem "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 MythTV binary version change because the plugins depend on
it.

libmythupnp

Simple uPnP (universal Plug and Play) support.

This library depends on libmythbase.

libmyth

Core MythTV library. Used by the Plugins. The audio, language support, plugin manager, media manager, and some old UI widgets are implemented by libmyth.

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. Documented externally. This 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.

libsamplerate

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.

libmythbluray/libmythdvdnav

Used for navigating Blu Ray and DVD menus when using the internal player.

Two libraries libmythmpeg2 and libsamplerate appear redundant, but libmpeg2 decodes MPEG-2 more quickly than ffmpeg on some systems, and libsamplerate resamples audio with better quality when we only need to match the hardware sample rate to the A/V streams audio sample rate.

Database Schema

Applications

MythTV contains 13 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 MythTV PCs.

mythlogserver

A tool that records log messages from a number of other myth applications in one stream, storing them in any or all of; a logfile, the Unix system log (if availale), and the MySQL database.