Category:Myth Protocol

Warning: The Myth Protocol is designed for internal use only, for third party applications we strongly recommend using the Services API instead which uses HTTP and a choice of JSON or XML serialised data, with support for SOAP, WSDL etc

Patch from #4583, along with corresponding fixes in mythweb and the perl bindings. Switches QUERY_PIXMAP_LASTMODIFIED to send a unix timestamp instead of a localized string that would be affected by LANG settings.

Packet Data Format

(This information is from reading the code and packet sniffing. Do not take this information as a specification, as the developers may not have intended some of the following behavior)

A MythTV protocol packet contains two fields, the size and the payload.
The first field is the size, encoded as an 8 byte, UTF8 decimal string padded with spaces. If you are sending a 20 byte payload, the first 8 bytes should be the characters "20" followed by 6 spaces.
The second field is the payload, an arbitrary length UTF8 string made up of a list of one or more strings seperated by a the delimeter "[]:[]". Commands are sent to port 6543.

Event Handling

When announcing ones self to the backend, the client can specify that it wants to receive update events. These events follow the same packet data format as outlined above and are sent asynchronously. These events will be identified as a backend message, and care must be taken to properly handle these when querying information from the backend.

Backend Commands

(This information is from reading the code and packet sniffing. Do not take this information as a specification, as the developers may not have intended some of the following behavior)

Backend commands are sent using the above packet format. The first string in the payload is the command, possibly with whitespace separated arguments. There may also be other arguments in successive strings in the list, separated by the delimiter "[]:[]". The two types of arguments are not interchangeable, each command may require specific whitespace separated arguments as well as specific list arguments.

When testing your code with the protocol, be warned that all commands except MYTH_PROTO_VERSION, ANN, and DONE will silently fail until a successful ANN command has been received by the backend. This includes non-existent commands.

Some example MythTV protocol exchanges, taken from a packet sniffing capture of a 0.19 frontend to backend exchange:

Frontend sends

Backend responds with

23 ANN Playback sycamore 0

2 OK

48 QUERY_FILETRANSFER 32[]:[]REQUEST_BLOCK[]:[]2048

4 2048

63 QUERY_FILETRANSFER 32[]:[]SEEK[]:[]0[]:[]0[]:[]0[]:[]0[]:[]2048

7 0[]:[]0

Third Party Code that implements the Myth Protocol

MythtvJ is a high-level Java client library. It currently supports the version 40 of the protocol. Currently streaming a file from the backend, reading the EPG and tuning a recorder is supported. Last updated for protocol version 40 (0.21).

ruby-mythtv is a basic set of Ruby bindings providing a connected backend socket. Last updated for protocol 56 (0.23).

telnetting_mythtv is a very basic C# library. Last updated for protocol version 40 (0.21).

libmythtv-java is a suite of libraries used to communicate with the entire MythTV ecosystem from Java. The latest released version (0.1) supports protocol versions 63 (0.24) through 70 (git master as of 2012/01/13).

jMythAPI is a a java library to query and control a MythTV backend and MythTV database. Its supports all protocol versions from 01 to 77 (0.27).

Third Party Code that implements the Myth Protocol ... badly

These implementations support an unknown protocol version, and repeatedly guess at what version the backend wants to use, in order to force a connection without actually maintaining the code. This should be considered very dangerous behavior, and should not be used to connect to any production backend.

libcmyth from mvpmc is a lightweight C client library which is also used by XBMC. It features livetv with epg, watching recordings and managing recordings.

GMyth is a library based on the Glib/GObject APIs. It is used in MobileMythtv, GMythStream and others.