Myth Protocol

From MythTV Official Wiki
Revision as of 04:18, 21 December 2009 by Wagnerrp (talk | contribs) (bump for 55)

Jump to: navigation, search

There is guide started, which describes how to use the Myth Protocol for watching Live TV.

List of proto bumps

Note: This is merely here to hold the current protocol changes while I take my time to reverse engineer as was done with Myth Protocol 14.

MYTH_PROTO_VERSION, Myth Release Changeset Description
2 [3078]
4 [3308]
6 [3589]
7 [3617]
8 [3621]
10 [3966]
11 [3973]
12 [3988]
13 [4122]
14 [4508]
22 [7883] +ANN Monitor, +LIVETV_EXITED (event)
24 [8617]
25 [8628]
26, 0.19 [8754] +SET_LIVE_RECORDING
27 [8973] Unification of the ChannelBase class???
28 [9524] Backend portion of Channel Editing patch.
29 [9592] Increments protocol to deal with new FileTransfer params
30, 0.20 [9968] Adds recorder keyed picture attribute adjustments
31, some 0.20-fixes [11278] Add parentid to the proginfo StringLists.
32 [12151] Introduction of StorageGroups
33 [12904] Changes the format of the original airdate field in the ProgramInfo stringlist
34 [13230] Sends the start channel as additional parameter in SpawnLiveTV
35 [13952] Replaces the current hdtv, stereo and closecaptioned flags with videoproperties, audioproperties and subtitletype vars
39, 0.21 [15701] Revert [15549], because the scheduler (starting with [15566]) now uses its own temporary copy of the record table during the BUSQ.
40, some 0.21-fixes [16090] 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.
41 [18419] Adds the production year to the programinfo sent via the protocol.
42 [18574] +QUERY_TIME_ZONE
43 [19417] (warning: huge changeset) Associated with the merging of the mythtv-vid branch to trunk.
*FILL_POSITION_MAP and possibly GetChainWithRecording.
44 [19978] Adds Videos storage group
45 [20523] Add channel grouping feature
46 [21158] Adds ability to delete remote files
47 [21298] Adds filesystem block size to the FileSystemInfo structure
48 [21445] When ANN returns "ERROR", it is now followed by the reason for the error
49 [22164] Adds new pixmap query to speed up preview generation
50, 0.22 [22170] Adds a hostname lookup to aid use of Storage Groups in MythVideo
51 [22892] Adds a remote hash function for files based of that used by OpenSubtitles.
52 [22932]
53 [22955]

Legend: - = removed command, + = added command, * = changed command

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.

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.

Whitespace is spaces, tabs, carriage returns, linefeeds, etc. Multiple whitespace characters are treated as a single whitespace.

In general, commands and arguments are case sensitive.

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.

For a list of all Myth protocol commands, see Command List.

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
4       2048
63      QUERY_FILETRANSFER 32[]:[]SEEK[]:[]0[]:[]0[]:[]0[]:[]0[]:[]2048
7       0[]:[]0

Third Party Code that implements the Myth Protocol

  • 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.
  • 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.