Kodi Community Forum
New MythTV add-on using libcmyth - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+---- Forum: PVR (https://forum.kodi.tv/forumdisplay.php?fid=136)
+---- Thread: New MythTV add-on using libcmyth (/showthread.php?tid=110694)



RE: New MythTV add-on using libcmyth - markcs - 2012-10-03

EDIT: OK, I have the plugin enabled, but it does not start.

In the log, I see the following error:

21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock acquired 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: IsConnected - 1
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: MythTV cmyth PVR-Client successfully created
21:23:49 T:140415731701504 ERROR: PVR - Add-on 'unknown' is using an incompatible API version. Please contact the developer of this add-on: Christian Fetzer, Tonny Petersen
21:23:49 T:140415731701504 WARNING: UpdateAndInitialiseClients - failed to create add-on MythTV cmyth PVR Client

On Myth backend I see the following:
Oct 3 21:32:22 mythtv mythbackend[2278]: C ProcessRequest mainserver.cpp:1259 (HandleVersion) MainServer::HandleVersion - Client speaks protocol version 8 but we speak 72!

I am using Myth backend 0.25.


RE: New MythTV add-on using libcmyth - Aubrien - 2012-10-03

It uses the 1.3.0 API version that just came out a couple days ago.

ERROR: PVR - Add-on 'unknown' is using an incompatible API version

Make sure that you have a fresh git pull of xbmc as well as the addon. Alot has been changing lately. Also delete your Addons.db, Epg.db, and TV22.db if you are having issues. Sometimes this helps. The worst case scenario is to delete everything except your userdata and do a fresh install of both xbmc and the addon. This is pretty drastic but sometimes I mess up bad enough. It should work though as I compile and pull every day.

On another note...I posted a couple days ago that I had worked out the channel change delay details as well as the show stopping between time slots. I posted too soon as it wasn't quite right then. I been doing a little more research and testing and I think I found the best places to insert delays to make this work. I will post back the solution later today if it keeps working. I have live tv just playing episode after episode and I want to be sure it keeps going for a while longer before I post back.


RE: New MythTV add-on using libcmyth - allen00se - 2012-10-03

(2012-10-03, 13:11)markcs Wrote: EDIT: OK, I have the plugin enabled, but it does not start.

In the log, I see the following error:

21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock acquired 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: IsConnected - 1
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: MythTV cmyth PVR-Client successfully created
21:23:49 T:140415731701504 ERROR: PVR - Add-on 'unknown' is using an incompatible API version. Please contact the developer of this add-on: Christian Fetzer, Tonny Petersen
21:23:49 T:140415731701504 WARNING: UpdateAndInitialiseClients - failed to create add-on MythTV cmyth PVR Client

On Myth backend I see the following:
Oct 3 21:32:22 mythtv mythbackend[2278]: C ProcessRequest mainserver.cpp:1259 (HandleVersion) MainServer::HandleVersion - Client speaks protocol version 8 but we speak 72!

I am using Myth backend 0.25.

OK i thought I was the only one... I did a fresh install of 0.25 and XBMC and got the same " Client speaks protocol version 8 but we speak 72" error. I used the XBMC nightly from yesterday... maybe I downloaded from the wrong location or something.


RE: New MythTV add-on using libcmyth - fetzerch - 2012-10-03

(2012-10-03, 16:45)allen00se Wrote:
(2012-10-03, 13:11)markcs Wrote: EDIT: OK, I have the plugin enabled, but it does not start.

In the log, I see the following error:

21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock acquired 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: IsConnected - 1
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 76245664
21:23:49 T:140415731701504 DEBUG: AddOnLog: MythTV cmyth PVR Client: MythTV cmyth PVR-Client successfully created
21:23:49 T:140415731701504 ERROR: PVR - Add-on 'unknown' is using an incompatible API version. Please contact the developer of this add-on: Christian Fetzer, Tonny Petersen
21:23:49 T:140415731701504 WARNING: UpdateAndInitialiseClients - failed to create add-on MythTV cmyth PVR Client

On Myth backend I see the following:
Oct 3 21:32:22 mythtv mythbackend[2278]: C ProcessRequest mainserver.cpp:1259 (HandleVersion) MainServer::HandleVersion - Client speaks protocol version 8 but we speak 72!

I am using Myth backend 0.25.

OK i thought I was the only one... I did a fresh install of 0.25 and XBMC and got the same " Client speaks protocol version 8 but we speak 72" error. I used the XBMC nightly from yesterday... maybe I downloaded from the wrong location or something.

"Client speaks protocol version 8 but we speak 72" should not cause any problems and is in libcmyth from the beginning. libcmyth tries to connect with different versions until it gets an OK from the server. Not nice, and maybe something to be redone at some point.

@markcs: Aubrien is right, your xbmc version must contain this commit: https://github.com/xbmc/xbmc/commit/465c6927594b239e8ae22687d5962669c849e72c
A current nightly or freshly built version should do it.


RE: New MythTV add-on using libcmyth - allen00se - 2012-10-03

(2012-10-02, 18:58)cfetzer Wrote: Doubt that anyone has tested 0.26 yet. According to the protocol changes here (http://www.mythtv.org/wiki/Category:Myth_Protocol) the db time is the 'only' change right now.
If you want to give it a try (please create a BACKUP of your database!), add this line to protomap in libcmyth's connection.c: {74, "SingingPotato"}, {75, "SweetRock"}.

I assume you mean right here?

static myth_protomap_t protomap[] = {
{62, "78B5631E"},
{63, "3875641D"},
{64, "8675309J"},
{65, "D2BB94C2"},
{66, "0C0FFEE0"},
{67, "0G0G0G0"},
{68, "90094EAD"},
{69, "63835135"},
{70, "53153836"},
{71, "05e82186"},
{72, "D78EFD6F"},
{73, "D7FE8D6F"},
{74, "SingingPotato"},
{75, "SweetRock"},

{0, ""}
};


RE: New MythTV add-on using libcmyth - Aubrien - 2012-10-03

OK, I have had live tv playing for hours now without it stopping so I think its time to post the solution. There are two delays needed as well as an object lock. I based this on cfetzer's code not janbar's since that is where we are moving to anyway. The changes are below...

addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
Code:
bool PVRClientMythTV::OpenLiveStream(const PVR_CHANNEL &channel)
{
  if (g_bExtraDebug)
    XBMC->Log(LOG_DEBUG,"%s - chanID: %i, channumber: %i", __FUNCTION__, channel.iUniqueId, channel.iChannelNumber);

  SingleLock<PLATFORM::CMutex> lock(&m_lock);
  if (m_rec.IsNull())
  {
    MythChannel chan = m_channels.at(channel.iUniqueId);
    for (std::vector<int>::iterator it = m_sources.at(chan.SourceID()).begin(); it != m_sources.at(chan.SourceID()).end(); it++)
    {
      m_rec = m_con.GetRecorder(*it);
      if (!m_rec.IsRecording() && m_rec.IsTunable(chan))
      {
        if (g_bExtraDebug)
          XBMC->Log(LOG_DEBUG,"%s: Opening new recorder %i", __FUNCTION__, m_rec.ID());

        if (m_pEventHandler)
          m_pEventHandler->SetRecorder(m_rec);

        if (m_rec.SpawnLiveTV(chan))
        {
          usleep(10000000); //Channel change delay of 10s
          return true;
        }
      }
      m_rec = MythRecorder();
      if (m_pEventHandler)
      {
        m_pEventHandler->SetRecorder(m_rec); // Redundant
      }
    }

    if (g_bExtraDebug)
      XBMC->Log(LOG_DEBUG,"%s - Done", __FUNCTION__);
    return false;
  }
  else
  {
    if (g_bExtraDebug)
      XBMC->Log(LOG_DEBUG,"%s - Done", __FUNCTION__);

    return true;
  }
}
Add the delay for changing channels.

addons/pvr.mythtv.cmyth/src/cppmyth/MythRecorder.cpp
Code:
bool MythRecorder::LiveTVChainUpdate(CStdString chainID)
{
  char* buffer=strdup(chainID.c_str());
  m_recorder_t->Lock();
  int retval = 0;

  usleep(5000000); // Program switch delay of 5s

  CMYTH_REC_CALL( retval, retval < 0, cmyth_livetv_chain_update( *m_recorder_t, buffer, 16*1024 ) );
  if(retval != 0)
    XBMC->Log(LOG_ERROR,"LiveTVChainUpdate failed on chainID: %s",buffer);
  *livechainupdated=1;
  m_recorder_t->Unlock();
  free(buffer);
  return retval==0;
}
Uncomment the lock/unlock. Add the delay for between shows.

addons/pvr.mythtv.cmyth/src/cppmyth/MythRecorder.cpp
Code:
int MythRecorder::ReadLiveTV(void* buffer,unsigned long length)
{

  m_recorder_t->Lock();
  int bytesRead=0;
  CMYTH_REC_CALL( bytesRead, bytesRead < 0, cmyth_livetv_read( *m_recorder_t, static_cast<char*>( buffer ), length ) );
  m_recorder_t->Unlock();
  return bytesRead;
}
Uncomment the lock/unlock

The end result of this makes the channels change properly either from nothing being played or from already watching tv. The delay is especially useful for those of us with IR blasters and analog tuners. Additionally, when the chain is updated (program transition) it locks the recorder for 5s. During this time read operations delay and the user is prevented from underrunning the buffer on the backend. Both the channel change delay and the program switch delay should be made into addon settings to be user configured. Mine works with the static values I inserted for developing the fix. Between program transitions you will see a "Buffering %" dialog for a second or so. This buffering is essential as each program transition causes no data for a small period and eventually the buffer is depleted and this makes it refill.


RE: New MythTV add-on using libcmyth - ryanolf - 2012-10-04

Thanks to everyone who is working on this, especially cfetzer and janbar for their recent work. I just installed the mythtv pvr addon from cfetzer's github repo, and it seems to work for me on Ubuntu 12.04 with a recent compile of xbmc master. I am experiencing one noticeable annoyance, and I'm sure there must be an easy fix. I haven't seen it mentioned in this forum, so I wonder if this is just a configuration problem on my side.

When browsing "TV recordings" under "Live TV," when I select a recording directory, a notification pops up headed "Information:" "This channel cannot be played. Check the log for details." I can say "ok" and then it shows me the relevant recordings. They all play just fine. I'm not sure what to make of this. I am not expecting a "channel" to play when I select a recording folder. Is there a way to get rid of this notification?

Thanks so much and keep up the great work!
Ryan


RE: New MythTV add-on using libcmyth - robweber - 2012-10-04

(2012-10-04, 00:01)ryanolf Wrote: Thanks to everyone who is working on this, especially cfetzer and janbar for their recent work. I just installed the mythtv pvr addon from cfetzer's github repo, and it seems to work for me on Ubuntu 12.04 with a recent compile of xbmc master. I am experiencing one noticeable annoyance, and I'm sure there must be an easy fix. I haven't seen it mentioned in this forum, so I wonder if this is just a configuration problem on my side.

When browsing "TV recordings" under "Live TV," when I select a recording directory, a notification pops up headed "Information:" "This channel cannot be played. Check the log for details." I can say "ok" and then it shows me the relevant recordings. They all play just fine. I'm not sure what to make of this. I am not expecting a "channel" to play when I select a recording folder. Is there a way to get rid of this notification?

Thanks so much and keep up the great work!
Ryan

See this commit - does this fix what you are seeing? https://github.com/xbmc/xbmc/commit/2680e87f3aa35b1235dc2dc784f20df8290b5a46



RE: New MythTV add-on using libcmyth - ryanolf - 2012-10-04

I have that commit in my history, and I'm still seeing the issue, though it sounds very much like my problem. Perhaps the difference is I'm not seeing this when opening an actual recording, but rather when browsing them and selecting a folder, as in "30 Rock" or "*All recordings".

Perhaps I should reopen that trac..


RE: New MythTV add-on using libcmyth - markcs - 2012-10-04

(2012-10-03, 17:30)cfetzer Wrote: "Client speaks protocol version 8 but we speak 72" should not cause any problems and is in libcmyth from the beginning. libcmyth tries to connect with different versions until it gets an OK from the server. Not nice, and maybe something to be redone at some point.

@markcs: Aubrien is right, your xbmc version must contain this commit: https://github.com/xbmc/xbmc/commit/465c6927594b239e8ae22687d5962669c849e72c
A current nightly or freshly built version should do it.

Thanks for your replies.
- I did a git pull on both xbmc and the xbmc-pvr-addons (from fetzerch's repository) but both were up to date.
- I deleted the db files in userdate/Database directory.
- I thought my problem may be due to an 'old' install of xbmc that was from the ppa repository for ubuntu. I removed all traces I could find of xbmc under /usr/local/share/xbmc and /usr/share/xbmc
- I reinstalled.

I can enable the addon, but when I try to go into any of the Live TV menu's, i'm told the addon has not started.

This is the last few line from xbmc.log:
Code:
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: LibCMyth: (cmyth)__cmyth_send_message: sending message '38      QUERY_SETTING mint LiveTVPriority'
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: LibCMyth: (cmyth)__cmyth_rcv_length
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: LibCMyth: (cmyth)__cmyth_rcv_length: buffer is '2       ' ret = 2
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: LibCMyth: (cmyth)__cmyth_rcv_string: string received '-1'
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: LibCMyth: (cmyth)cmyth_conn_get_setting_unlocked: Setting: LiveTVPriority or hostname: mint not found.
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 740612576
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock 740612576
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: Lock acquired 740612576
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 740612576
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: IsConnected - 1
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: Unlock 740612576
09:39:54 T:140450766628608   DEBUG: AddOnLog: MythTV cmyth PVR Client: MythTV cmyth PVR-Client successfully created
09:39:54 T:140450766628608   ERROR: PVR - Add-on 'unknown' is using an incompatible API version. Please contact the developer of this add-on: Christian Fetzer, Tonny Petersen
09:39:54 T:140450766628608 WARNING: UpdateAndInitialiseClients - failed to create add-on MythTV cmyth PVR Client
09:39:54 T:140450775021312   ERROR: PVRManager - Process - failed to load PVR data
09:39:54 T:140450775021312   DEBUG: Thread PVR manager 140450775021312 terminating
09:39:54 T:140450766628608   DEBUG: Thread PVR add-on updater 140450766628608 terminati

If no one else has this issue, could there be some remnants of xbmc somewhere that are creating issues (libraries or something I forgot to remove)? What other logs can I provide?

Note that the MythTV backend is running on a different machine than XBMC (if that makes any difference)

Thanks!


RE: New MythTV add-on using libcmyth - pyrodex - 2012-10-04

(2012-10-03, 21:11)Aubrien Wrote: The end result of this makes the channels change properly either from nothing being played or from already watching tv. The delay is especially useful for those of us with IR blasters and analog tuners. Additionally, when the chain is updated (program transition) it locks the recorder for 5s. During this time read operations delay and the user is prevented from underrunning the buffer on the backend. Both the channel change delay and the program switch delay should be made into addon settings to be user configured. Mine works with the static values I inserted for developing the fix. Between program transitions you will see a "Buffering %" dialog for a second or so. This buffering is essential as each program transition causes no data for a small period and eventually the buffer is depleted and this makes it refill.

Great work!

One quick thought... For people who don't have IR or Analog say using a HDHomerun could we make the delay configurable option in the module? It could default to 5 seconds for safety but people can tune it for their own benefit and testing.


RE: New MythTV add-on using libcmyth - Aubrien - 2012-10-04

@pyrodex

As soon I I got it working I realized that I don't like the user having to define variables, and although the solution I posted does work (and I'm going to hold on to that in case I cant come up with anything else) I started trying to find a solution that auto senses when the stream is ready to read off of. There is a property call LiveTVDuration that starts at 0. When it becomes non-zero it is safe to read off of the buffer. When this value hangs for a while and then begins to climb again, it went through a program transition.I'm thinking that once it begins to climb again it is safe to read off of the stream again. Hopefully I'll come up with something that leaves me fully satisfied so I can stop going through these different iterations. Ideally, there are no user configured values as these are annoying.


RE: New MythTV add-on using libcmyth - fetzerch - 2012-10-04

Just pushed an update to https://github.com/fetzerch/xbmc-pvr-addons/.
This uses now API version 1.4.0 (requires xbmc build from today) and brings recording images support (thumbs + icons).
The update also contains a first cleanup round (mostly coding styles, and restructoring especially in cppmyth).
This should not change any functional behavior. However as I touched pretty much every file it would be nice if some of you could test this and let me know it everything is still working as before.


RE: New MythTV add-on using libcmyth - jskube - 2012-10-05

(2012-10-04, 21:27)cfetzer Wrote: Just pushed an update to https://github.com/fetzerch/xbmc-pvr-addons/.
This uses now API version 1.4.0 (requires xbmc build from today) and brings recording images support (thumbs + icons).
The update also contains a first cleanup round (mostly coding styles, and restructoring especially in cppmyth).
This should not change any functional behavior. However as I touched pretty much every file it would be nice if some of you could test this and let me know it everything is still working as before.

I pulled in the lastest XBMC and lastest xbmc-pvr-addons from your repo today I am having problems enabling the cmyth pvr addon. Specifically it is complaining about libcmyth missing and I have no idea where it is look for it. Relevant error:

18:04:13 T:140603704665856 DEBUG: Thread PVR manager 140603704665856 terminating
18:04:13 T:140603731994368 NOTICE: Thread Jobworker start, auto delete: true
18:04:13 T:140604458465152 DEBUG: CGUIMediaWindow::GetDirectory (addons://disabled/xbmc.pvrclient)
18:04:13 T:140604458465152 DEBUG: ParentPath = [addons://disabled/xbmc.pvrclient]
18:04:13 T:140603704665856 NOTICE: Thread Background Loader start, auto delete: false
18:04:13 T:140603704665856 DEBUG: Thread Background Loader 140603704665856 terminating
18:04:13 T:140603270625024 DEBUG: RegisterClient - registering add-on 'MythTV cmyth PVR Client'
18:04:13 T:140603270625024 DEBUG: PVR - Create - creating PVR add-on instance 'MythTV cmyth PVR Client'
18:04:13 T:140603270625024 DEBUG: ADDON: Dll Initializing - MythTV cmyth PVR Client
18:04:13 T:140603270625024 DEBUG: SECTION:LoadDLL(/home/xbmc/.xbmc/addons/pvr.mythtv.cmyth/XBMC_MythTV_cmyth.pvr)
18:04:13 T:140603270625024 DEBUG: Loading: /home/xbmc/.xbmc/addons/pvr.mythtv.cmyth/XBMC_MythTV_cmyth.pvr
18:04:13 T:140603270625024 ERROR: Unable to load /home/xbmc/.xbmc/addons/pvr.mythtv.cmyth/XBMC_MythTV_cmyth.pvr, reason: libcmyth.so.0: cannot open shared object file: No such file or directory
18:04:13 T:140603270625024 INFO: Called Add-on status handler for '4' of clientName:MythTV cmyth PVR Client, clientID:pvr.mythtv.cmyth (same Thread=no)
18:04:13 T:140604457936640 NOTICE: Thread CAddonStatusHandler:pvr.mythtv.cmyth start, auto delete: true
18:04:13 T:140603270625024 WARNING: UpdateAndInitialiseClients - failed to create add-on MythTV cmyth PVR Client
18:04:13 T:140603270625024 WARNING: UpdateAndInitialiseClients - failed to load the dll for add-on MythTV cmyth PVR Client, disabling it
18:04:13 T:140604458465152 DEBUG: ------ Window Init (DialogOK.xml) ------
18:04:13 T:140604458465152 DEBUG: Window DialogOK.xml was already loaded



RE: New MythTV add-on using libcmyth - allen00se - 2012-10-05

I also just tried to build for windows and I got an error during the build which causes the build to fail..
c:\users\kallen1\documents\github\xbmc-pvr-addons\addons\pvr.mythtv.cmyth\src\cppmyth/MythChannel.h(24): fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory
1> MythChannel.cpp

I am not very experienced with building on windows... could this be caused by my OS being x64?

*****scratch that just realized i needed some libraries