MythTv Protocol
This page contains some information and tips/and tricks about the MythTv Protocol. I concentrate on some of the important things I have found out while developing the player.
Protocol Basics
The basic of the the protocol can be found in the Official Wiki. A lot of this information is originally from the author of Winmyth (Which is currently unmaintained).
How to find out about the protocol
As MythTv is OpenSource, there is no need to sniff packets or apply other reverse-engineering approaches. Simply inspect the code for the backend. Most of the code can be found in /mythtv/programs/mythbackend/mainserver.cpp in the source tree. Here is a link for the file in the different versions: 0.19, 0.20, and trunk.
Watch your steps!
The backend is a bit picky about the protocol, so you have to be careful. On this page I will try to point out the things I have discovered so far. (I have discovered this by inspecting the code for the backend or by messing up my backend while testing the player). A few commands are able to crash the backend. Some commands are able to leave the backend in a state such that it can not shut down. If you want to implement LiveTV, you really have to watch your steps. It is easy to get a recorder and use it for livetv, but it is also easy to mess up your recording schedules.
Crash crash crash
Unfortunately it is possible to crash the backend with a few of the commands. The problem exists in all versions of the backend. The backend crashes as pointers are dereferenced without checking the validity of the pointers. I might have overlooked some commands, so mail me if you find any.
QUERY_RECORDER <REC> GET_CURRENT_RECORDING
Use GET_RECORDING instead. This command does exactly the same, but returns a dummy command if the recorder is not recording
The following commands crashes the backend if the recording does not exist
QUERY_CUTLIST, QUERY_COMMBREAK, QUERY_BOOKMARK, SET_BOOKMARK
Do not send the "DONE" Command
You must never send the "DONE" command. This is a bit wierd, but after you have sent the "ANN" command this is not the purpose. When you close a connection more brutal, the socket is removed from the internal list of connections and everything works fine. If you send the "DONE" command, the backend closes the socket *without* removing it from the internal lists.
Live TV
(I am currently writing this section)
Currently, the MythTv Player does not support LiveTV. Not because I am not able to do it, but because I do not want angry users with crashing backends, and recordings that are not recorded as scheduled. This is because the backend is not forcing you to release a recorder it want to use to record a show. Instead it ask you nicely to release the recorder and you then have to release it yourself! If you do not do this, the sheduled recording will not be recorded. You can also change channels on recorders that are currently recording.
Support for multiple versions
Here, I will write my thoughts about supporting multiple versions.
Retrieve Guide Data through the protocol
I am able to retrieve the entire program guide, through the mythtv protocol. Here, I will write how this can be done.
Previous page: Roadmap
Next page: Source code
