Talk:MythTV PVR

From Official Kodi Wiki
Jump to: navigation, search

1 API for MythTV backend

Full API docs for MythTV can be found under [1]

2 Development information about old version


see current information about the MythTV PVR add-on. Much of the information in this article or section has not been updated and refers to XBMC features that have been superseded, and may not be reliable.

The MythTV PVR Addon is being developed in C++ to implement the new XBMC Media Center PVR Interface. The PVR Interface is defined in the pvrtesting2 branch. That branch is where the MythTV Addon will be developed.

svn co

At the time of writing, a small part of the implementation has been checked into the branch. Most of the work related to this effort is being tracked in the MythTV PVR Addon trac ticket

The pvrtesting2 branch is not up-to-date with trunk, so the myth:// protocol will not work with Myth 0.24. There are no plans to keep the pvrtesting2 branch up-to-date with trunk. The point of the branch is to flesh out the PVR Addons and that's enough work without having to keep it up-to-date with trunk. The PVR related changes will then get moved into trunk after the Dharma release.

2.1 What it will look like when done

Some YouTube videos of the integration with the VDR backend through the PVR Addon interface. Note that the "Timer" aspect of the interface needs to change for it to work with MythTV. (only really at the start)

Some screenshots of the integration with the tvheadend backend through the PVR Addon interface. Dated 06/06/2011

2.1.1 MythTV PVR Addon Tasks

In a very ad hoc way, below is a series of tasks that need to be done to get the MythTV PVR Addon implemented.

  1. DONE: Stub out the MythTV PVR Addon classes copy and paste of the VDR Addon. Remove the VDR specific parts and relabel as MythTV etc. Ensure compiles. If anyone has done some / part of this please create a trac ticket and attach a patch for the pvr branch and then assign it to me. tafypz
  2. Identify what does not exist in any of the myth:// code - after 1 is done it should be more obvious what XBMC doesn't already have a solution to based on the existing myth:// functionality. Missing functions may already be available in libcmyth and just need to be exposed. From there we can identify what methods need to be added to libcmyth to get the additional information / actions needed by the PVR interface, or use the MythXML interface if that is easier. If really necessary via MySQL. With the list of missing areas available, people can choose to help implementing parts. This will hopefully be straight forward if the Myth Protocol already supports the query or action. tafypz is looking at the Program Guide / Recording Schedule Areas already.
  3. Start copying across existing myth:// code - where possible, start copying the existing MythSession.cpp, MythFile.cpp and MythDirectory.cpp code to the appropriate places in MythTV PVR Addon to get back the list of recordings and provide the functionality that myth:// already supports. If it helps, we can start with using the existing myth:// functionality in XBMC to play the content until it's clearer how libcmyth can be bundled as part of an Addon rather than relying on that being in the XBMC lib area. dteirney can spend some time once the classes are stubbed out. Other volunteers very welcome
  4. DONE: Changes to libcmyth to support the Myth 0.24 protocol - Myth 0.24 will be released in the near future. There has been a number of changes to the ProgramInfo structure passed back so these need to be reviewed and appropriate changes made in libcmyth. XBMC will also need to pass through the appropriate token each time a connection is made to the backend. Having the MythTV trunk codebase handy will probably make this easier - start from mythtv/programs/mythbackend/mainserver.cpp as that is where the Myth Protocol handling ends up. Myth Protocol lists all the protocol changes with links to the SVN checkins. The mythtv checkin that altered the ProgramInfo object is freaking gargantuan. The checkin that relates to the new token for each protocol version was in PhracturedBlue
  5. Bundle libcmyth in the Addon - not sure how this will work. Perhaps find another Add-On that is using a 3rd party C library. So we know how to move libcmyth out of XBMC and into the PVR Addon all proper like. libcmyth functions are current exposed to XBMC via DllLibCMyth. Is there an equivlent DLL type model in Addon land? Volunteer needed
  6. Integrate Addon EDL functionality - suggest how the existing EDL commercial break retrieval can be changed so the Edl.cpp class in XBMC queries the MythTV Addon implementation rather than the internal myth:// related classes. Can leave that up to the existing myth:// playback for the moment. dteirney

2.2 API Methods

Below is the full list of methods that can be implemented by a PVR Addon. Some don't look like they will be needed for the MythTV PVR, or it doesn't look like MythTV can support them.

Next to each item is the likely source of data for the implementation. Methods with a bold name next to them are being done by that person.

GetBackendName() - ?

GetBackendVersion() - ?

GetConnectionString() - not sure

GetDriveSpace(long long *total, long long *used) -

GetBackendTime(time_t *localTime, int *gmtOffset) - used for timezone corrections in EPG if backend and xbmc are in different time zones or have different timezone settings. Behaviour is overridable in advancedsettings.xml - tafypz

DialogChannelScan() - not sure what this is

MenuHook(const PVR_MENUHOOK &menuhook) - not sure what this is

RequestEPGForChannel(PVRHANDLE handle, const PVR_CHANNEL &channel, time_t start, time_t end) - implemented in svn - tafpyz

GetNumBouquets() - Bouquets are a DVB specific thing, - I guess this can be left unimplemented - tafypz

RequestBouquetsList(PVRHANDLE handle, int radio) - Bouquets are a DVB specific thing, - I guess this can be left unimplemented - tafypz

GetNumChannels() - implemented in svn - tafypz

RequestChannelList(PVRHANDLE handle, int radio) - implemented in svn - tafpyz

DeleteChannel(unsigned int number) - not sure what this is used for

RenameChannel(unsigned int number, const char *newname) - not sure what this is used for

MoveChannel(unsigned int number, unsigned int newnumber) - not sure what this is used for

DialogChannelSettings(const PVR_CHANNEL &channelinfo) - not sure

DialogAddChannel(const PVR_CHANNEL &channelinfo) - not sure what it's used for

GetNumRecordings(void) - implemented in patch (ticket 10445) - tafypz

RequestRecordingsList(PVRHANDLE handle) - implemented in patch (ticket 10445) - tafypz

DeleteRecording(const PVR_RECORDINGINFO &recinfo) - libcmyth

RenameRecording(const PVR_RECORDINGINFO &recinfo, const char *newname) - not sure why this is needed

HaveCutmarks() - libcmyth

RequestCutMarksList(PVRHANDLE handle) - libcmyth

AddCutMark(const PVR_CUT_MARK &cutmark) - not sure what this is used for. Is there some sort of integration with XBMC to set cut marks through the UI?

DeleteCutMark(const PVR_CUT_MARK &cutmark) - not sure what this is used for. Is there some sort of integration with XBMC to set cut marks through the UI?

StartCut() - not sure what this is

GetNumTimers(void) - what's a timer? Is this a recording schedule?

RequestTimerList(PVRHANDLE handle)

AddTimer(const PVR_TIMERINFO &timerinfo)

DeleteTimer(const PVR_TIMERINFO &timerinfo, bool force)

RenameTimer(const PVR_TIMERINFO &timerinfo, const char *newname)

UpdateTimer(const PVR_TIMERINFO &timerinfo)

OpenLiveStream(const PVR_CHANNEL &channelinfo) - I think libcmyth

ReadLiveStream(unsigned char* buf, int buf_size) - I think libcmyth

GetCurrentClientChannel() - maintained internally?

SwitchChannel(const PVR_CHANNEL &channelinfo) - I think libcmyth

SignalQuality(PVR_SIGNALQUALITY &qualityinfo) - not sure

SwapLiveTVSecondaryStream() - is this for like PnP stuff? Not sure Myth Protocol supports this

OpenSecondaryStream(const PVR_CHANNEL &channelinfo) - is this for like PnP stuff?


ReadSecondaryStream(unsigned char* buf, int buf_size)

OpenRecordedStream(const PVR_RECORDINGINFO &recinfo) - can we stream via

CloseRecordedStream(void) - not needed if HTTP streaming?

ReadRecordedStream(unsigned char* buf, int buf_size) - not needed if HTTP streaming?

SeekRecordedStream(long long pos, int whence) - not needed if HTTP streaming?

PositionRecordedStream(void) - not needed if HTTP streaming?

LengthRecordedStream(void) - not needed if HTTP streaming?

DemuxPacket* DemuxRead() - not needed if HTTP streaming?

DemuxAbort() - not needed if HTTP streaming?

DemuxReset() - not needed if HTTP streaming?

DemuxFlush() - not needed if HTTP streaming?

SeekLiveStream(long long pos, int whence) - not supported by existing libcmyth

PositionLiveStream(void) - libcmyth

2.3 MythXML Library Public API Ideas

Below are some ideas regarding the structure of the classes that will be used to fire off commands to the MythXml interface and then parse the results.

MythXml::MythXml(hostname, username, pin, timeout etc) - static global variable created and used.

bool MythXML::ExecuteCommand(MythXmlCommand command, MythXmlResponse response) return value of true = successful, false = unsuccessful

MythXMLCommand(CStdString command, MythXmlParameters parameters) - abstract Super Class. All SubClasses have constructors that take the appropriate API for the command, and then call superclass constructor.

MythXMLResponse - perhaps this just has some helper methods in it for parsing the content, e.g. string to time_t conversion etc.

void MythXmlParameters::SetParameter(CStdString name, CStdString value)

void MythXmlParameters::SetParameter(CStdString name, time_t time)

+ whatever other overloads are needed for the formatting rules for the different data types for MythXML

+ internals of each overload for SetParameter does all the necessary conversion for the HTTP parameters

CStdString MythXmlParameters::GetParameterString() (not able to be overwritten in subclass, all managed through the parameters added through AddParameter)

Any subclasses of MythXmlParameters can have the mandatory parameter values passed in the constructor, and then the superclass SetParameter methods called using the appropriate names in the constructor.

? MythXmlResponse::GetErrors() - not sure how the errors are used

CStdString MythXmlResponse::GetXML() (which can be pushed into the parsing routine for the responses. Parsing routine can make use of the helper functions for parsing to objects)

Any subclass of MythXmlReponse can have getter methods to parse out what is needed of the XML data from the response into a suitable format. E.g. int XYZResponse::GetNumberOfChannels(). I guess there could be a subclass Response object for each type of Command to parse out sensible data structures.

2.4 MythTV PVR Addon Agnostic Tasks

  • DONE: Review the mythtv trunk codebase to see what events get fired to client and compare with what libcmyth currently understands and what XBMC does something with. The list of events that libcmyth deals with is in xbmc/lib/cmyth/libcmyth/event.c. The list of what XBMC does with them is in xbmc/FileSystem/CMythSession.cpp in the Process() method. Missing event handling is probably what is causing some issues with LiveTV playback. PhracturedBlue + dteirney
  • DONE: Figure out how to parse out the season and episode number from the program ID. Someone using Schedules Direct can probably do this. Here in NZ our EPG data is a bit sparse. Happy to include code to parse out the season and episode ID if the program ID can be identified as a Schedules Direct one. See trac ticket for detail. dteirney - partially done
  • Suggest how the XBMC TV Show Library can show recorded TV Shows from MythTV. This will start with the existing myth:// model and then the PVR extension point might need to be changed to support a similar way of integrating. See trac ticket for detail. PhracturedBlue
  • Bug fix so all the tuners are enumerated when looking for LiveTV. Involves checking to see if the GET_FREE_RECORDER_LIST Myth Protocol query has been implemented in libcmyth or not. The folk developing mythroku may have already done. See trac ticket for detail. Volunteer needed
  • DONE: Update libcmyth to log the UNKNOWN events are that are passed from the backend. dteirney - done