Difference between revisions of "Myth Protocol"

From MythTV Official Wiki
Jump to: navigation, search
m (Fix typo in QUERY_TIME_ZONE (underscore between "TIME" and "ZONE"))
(Add release versions)
Line 5: Line 5:
 
<center>
 
<center>
 
{| border=1 cellspacing=0 cellpadding=5
 
{| border=1 cellspacing=0 cellpadding=5
| MYTH_PROTO_VERSION  
+
| MYTH_PROTO_VERSION, Myth Release
 
| Changeset  
 
| Changeset  
 
| Description
 
| Description
Line 65: Line 65:
 
|
 
|
 
|-
 
|-
| 15
+
| 15, 0.18
 
| {{changeset|5833}}  
 
| {{changeset|5833}}  
 
| <code><font color="green">+QUERY_LOAD, +QUERY_UPTIME, +QUERY_MEMSTATS, +QUERY_GUIDEDATATHROUGH, +RESCHEDULE_RECORDINGS</font></code>
 
| <code><font color="green">+QUERY_LOAD, +QUERY_UPTIME, +QUERY_MEMSTATS, +QUERY_GUIDEDATATHROUGH, +RESCHEDULE_RECORDINGS</font></code>
Line 109: Line 109:
 
|
 
|
 
|-
 
|-
| 26  
+
| 26, 0.19
 
| {{changeset|8754}}
 
| {{changeset|8754}}
 
| <code><font color="green">+SET_LIVE_RECORDING</font></code>
 
| <code><font color="green">+SET_LIVE_RECORDING</font></code>
Line 125: Line 125:
 
| Increments protocol to deal with new FileTransfer params<br/><code>*ANN</code>
 
| Increments protocol to deal with new FileTransfer params<br/><code>*ANN</code>
 
|-
 
|-
| 30
+
| 30, 0.20
 
| {{changeset|9968}}
 
| {{changeset|9968}}
 
| Adds recorder keyed picture attribute adjustments<br/><code><font color="green">+GET_COLOUR, +GET_CONTRAST, +GET_BRIGHTNESS, +GET_HUE</font>, *CHANGE_COLOUR, *CHANGE_CONTRAST, *CHANGE_BRIGHTNESS, *CHANGE_HUE</code>
 
| Adds recorder keyed picture attribute adjustments<br/><code><font color="green">+GET_COLOUR, +GET_CONTRAST, +GET_BRIGHTNESS, +GET_HUE</font>, *CHANGE_COLOUR, *CHANGE_CONTRAST, *CHANGE_BRIGHTNESS, *CHANGE_HUE</code>
 
|-
 
|-
| 31
+
| 31, some 0.20-fixes
 
| {{changeset|11278}}
 
| {{changeset|11278}}
 
| Add parentid to the proginfo StringLists.
 
| Add parentid to the proginfo StringLists.
Line 161: Line 161:
 
| <code><font color="green">+DELETE_FAILED_RECORDING</font></code>
 
| <code><font color="green">+DELETE_FAILED_RECORDING</font></code>
 
|-
 
|-
| 39
+
| 39, 0.21
 
| {{changeset|15701}}
 
| {{changeset|15701}}
 
| Revert [15549], because the scheduler (starting with [15566]) now uses its own temporary copy of the record table during the BUSQ.<br/><code><font color="red">-DELETE_FAILED_RECORDING</font></code>
 
| Revert [15549], because the scheduler (starting with [15566]) now uses its own temporary copy of the record table during the BUSQ.<br/><code><font color="red">-DELETE_FAILED_RECORDING</font></code>
 
|-
 
|-
| 40
+
| 40, some 0.21-fixes
 
| {{changeset|16090}}
 
| {{changeset|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.<br/><code>*QUERY_PIXMAP_LASTMODIFIED</code>
 
| 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.<br/><code>*QUERY_PIXMAP_LASTMODIFIED</code>

Revision as of 09:15, 5 March 2009

There is wiki entry started, Using the Myth protocol, 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
1 [3021] +MYTH_PROTO_VERSION
2 [3078]
3 [3112] +GET_NEXT_FREE_RECORDER
4 [3308]
5 [3503] +REACTIVATE_RECORDING, +REFRESH_BACKEND
6 [3589]
7 [3617]
8 [3621]
9 [3838] +GET_FREE_RECORDER_COUNT
10 [3966]
11 [3973]
12 [3988]
13 [4122]
14 [4508]
15, 0.18 [5833] +QUERY_LOAD, +QUERY_UPTIME, +QUERY_MEMSTATS, +QUERY_GUIDEDATATHROUGH, +RESCHEDULE_RECORDINGS
16 [6284] +FORCE_DELETE_RECORDING, +OK, +UNKNOWN_COMMAND
17 [6482] -QUERY_FREESPACE, +QUERY_FREE_SPACE, +QUERY_FREE_SPACE_LIST, +GET_FREE_RECORDER_LIST, +QUERY_PIXMAP_LASTMODIFIED, +QUERY_COMMBREAK, +QUERY_CUTLIST, +QUERY_BOOKMARK, +SET_BOOKMARK, +QUERY_SETTING, +SET_SETTING, +QUERY_REMOTEENCODER GET_MAX_BITRATE, +QUERY_RECORDER GET_MAX_BITRATE, +QUERY_RECORDER SHOULD_SWITCH_CARD
18 [6865] +QUERY_RECORDER SET_SIGNAL_MONITORING_RATE
19 [7427] -REACTIVATE_RECORDING, +ALLOW_SHUTDOWN, +BLOCK_SHUTDOWN, +QUERY_RECORDER GET_CURRENT_RECORDING
20 [7739] -ANN RingBuffer, -QUERY_RECORDER GET_FREE_SPACE, -QUERY_RECORDER SETUP_RING_BUFFER, -QUERY_RECORDER STOP_PLAYING, -QUERY_RECORDER REQUEST_BLOCK_RINGBUF, -QUERY_RECORDER SEEK_RINGBUF, -QUERY_RECORDER DONE_RINGBUF
21 [7826] -GET_PROGRAM_INFO, -GET_INPUT_NAME
22 [7883] +ANN Monitor, +LIVETV_EXITED (event)
23 [8553] -QUEUE_TRANSCODE, -QUEUE_TRANSCODE_CUTLIST, -QUEUE_TRANSCODE_STOP, +QUERY_GETEXPIRING, +SCHEDULER_ADD_RECORDING (event), +CLEAR_SETTINGS_CACHE (event)
24 [8617]
25 [8628]
26, 0.19 [8754] +SET_LIVE_RECORDING
27 [8973] Unification of the ChannelBase class???
-SCHEDULER_ADD_RECORDING (event), -TOGGLE_INPUTS, +GET_CONNECTED_INPUTS, +GET_INPUT, +SET_INPUT
28 [9524] Backend portion of Channel Editing patch.
+GET_CHANNEL_INFO, +SET_CHANNEL_INFO, +SET_TIMEOUT
29 [9592] Increments protocol to deal with new FileTransfer params
*ANN
30, 0.20 [9968] Adds recorder keyed picture attribute adjustments
+GET_COLOUR, +GET_CONTRAST, +GET_BRIGHTNESS, +GET_HUE, *CHANGE_COLOUR, *CHANGE_CONTRAST, *CHANGE_BRIGHTNESS, *CHANGE_HUE
31, some 0.20-fixes [11278] Add parentid to the proginfo StringLists.
32 [12151] Introduction of StorageGroups
+QUERY_RECORDING, +QUERY_FREE_SPACE_SUMMARY, +SET_NEXT_LIVETV_DIR
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
*SPAWN_LIVETV
35 [13952] Replaces the current hdtv, stereo and closecaptioned flags with videoproperties, audioproperties and subtitletype vars
36 [14483] +UNDELETE_RECORDING
37 [15437] -GET_CONNECTED_INPUTS, +GET_FREE_INPUTS, +GET_FLAGS, +CANCEL_NEXT_RECORDING, +STOP_RECORDING
38 [15550] +DELETE_FAILED_RECORDING
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.
-DELETE_FAILED_RECORDING
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.
*QUERY_PIXMAP_LASTMODIFIED
41 [18419] Adds the production year to the programinfo sent via the protocol.
42 [18574] Adds +QUERY_TIME_ZONE to mythtv protocol

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 Myth Protocol 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
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

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