Difference between revisions of "Myth Protocol"

From MythTV Official Wiki
Jump to: navigation, search
(protocol version 37, 38 added)
Line 61: Line 61:
 
| 36
 
| 36
 
| [http://cvs.mythtv.org/trac/changeset/14483 14483]
 
| [http://cvs.mythtv.org/trac/changeset/14483 14483]
| Adds "UNDELETE_RECORDING" command
+
| <font color="green">+UNDELETE_RECORDING</font>
 
|-
 
|-
 
| 37
 
| 37
Line 72: Line 72:
 
|}
 
|}
 
</center>
 
</center>
 +
 +
''Legend:'' <font color="red">'''-'''</font> = removed command, <font color="green">'''+'''</font> = added command, <font color="black">'''*'''</font> = changed command
  
 
== Packet Data Format ==
 
== Packet Data Format ==
Line 78: Line 80:
 
A MythTV protocol packet contains two fields, the size and the payload.
 
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 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.
+
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 "<code>[]:[]</code>". Commands are sent to port 6543.
  
 
== Backend Commands ==
 
== 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)''
 
''(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.
+
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 "<code>[]:[]</code>".  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.
 
Whitespace is spaces, tabs, carriage returns, linefeeds, etc.  Multiple whitespace characters are treated as a single whitespace.
Line 89: Line 91:
 
In general, commands and arguments are case sensitive.
 
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.
+
When testing your code with the protocol, be warned that all commands except <code>MYTH_PROTO_VERSION</code>, <code>ANN</code>, and <code>DONE</code> will silently fail until a successful <code>ANN</code> 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]].
 
For a list of all Myth protocol commands, see [[Myth Protocol Command List]].

Revision as of 08:27, 24 January 2008

WhyTey will try to start to describe the Myth Protocol here. Any input that others might have would be most appreciated.

I will be using the MythTV Protocol Overview document from the WinMyth project (thanks to Ofer Achler), the MythTV source code and trial-and-error to provide the detail.

My aim is to start with release 0.17 of MythTV, which I believe is using Myth Protocol 14, and provide complete documentation for all new versions of the protocol that may be released.

My plan is to use sections of the protocol to write an Java server that I can interface with for some JSP's I would like to develop. The Java server will simply serve as a broker and convert Java RPC's into Socket calls to the Myth Backend.

I know of others that would also like to be able to provide an interface to the Myth Backend to other languages/technologies so this Myth Protocol resource would/could prove useful.

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 Changeset Description
26 8754
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 9968 Adds recorder keyed picture attribute adjustments
31 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
36 14483 +UNDELETE_RECORDING
37 15437 -GET_CONNECTED_INPUTS, +GET_FREE_INPUTS, +GET_FLAGS, +CANCEL_NEXT_RECORDING, +STOP_RECORDING
38 15550 +DELETE_FAILED_RECORDING

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