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 - pyrodex - 2012-10-05

FYI Mythtv 0.26 STABLE was just released to the public.


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

So i installed a boost library that I thought would get me the include i needed, but i still alot of errors (MS Visual C++ express on win7 x64)

*** I had to go in and manually tell Visual C++ where the boost files were to resolve my issue. Now I am really stuck though.

fileOps.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl boost::filesystem::detail::file_size(class boost::filesystem::path const &,class boost:Confusedystem::error_code *)" (?file_size@detail@filesystem@boost@@YA_KABVpath@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "class boost::filesystem::file_status __cdecl boost::filesystem::detail:Confusedtatus(class boost::filesystem::path const &,class boost:Confusedystem::error_code *)" (?status@detail@filesystem@boost@@YA?AVfile_status@23@ABVpath@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "class boost:Confusedystem::error_code __cdecl boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close@detail@filesystem@boost@@YA?AVerror_code@system@3@AAPAX@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem::detail::directory_iterator_increment(class boost::filesystem::directory_iterator &,class boost:Confusedystem::error_code *)" (?directory_iterator_increment@detail@filesystem@boost@@YAXAAVdirectory_iterator@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "bool __cdecl boost::filesystem::detail::create_directory(class boost::filesystem::path const &,class boost:Confusedystem::error_code *)" (?create_directory@detail@filesystem@boost@@YA_NABVpath@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "bool __cdecl boost::filesystem::detail::remove(class boost::filesystem::path const &,class boost:Confusedystem::error_code *)" (?remove@detail@filesystem@boost@@YA_NABVpath@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem::detail::directory_iterator_construct(class boost::filesystem::directory_iterator &,class boost::filesystem::path const &,class boost:Confusedystem::error_code *)" (?directory_iterator_construct@detail@filesystem@boost@@YAXAAVdirectory_iterator@23@ABVpath@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::filesystem::path::m_erase_redundant_separator(unsigned int)" (?m_erase_redundant_separator@path@filesystem@boost@@AAEXI@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: unsigned int __thiscall boost::filesystem::path::m_append_separator_if_needed(void)" (?m_append_separator_if_needed@path@filesystem@boost@@AAEIXZ)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem::path::codecvt(void)" (?codecvt@path@filesystem@boost@@SAABV?$codecvt@_WDH@std@@XZ)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: class boost::filesystem::path __thiscall boost::filesystem::path::filename(void)const " (?filename@path@filesystem@boost@@QBE?AV123@XZ)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: class boost::filesystem::path __thiscall boost::filesystem::path::parent_path(void)const " (?parent_path@path@filesystem@boost@@QBE?AV123@XZ)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: class boost::filesystem::path & __thiscall boost::filesystem::path::operator/=(class boost::filesystem::path const &)" (??_0path@filesystem@boost@@QAEAAV012@ABV012@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@YAXPBD0AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV?$codecvt@_WDH@5@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@YAXPB_W0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$codecvt@_WDH@5@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: class boost::filesystem::file_status __thiscall boost::filesystem::directory_entry::m_get_symlink_status(class boost:Confusedystem::error_code *)const " (?m_get_symlink_status@directory_entry@filesystem@boost@@ABE?AVfile_status@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: class boost::filesystem::file_status __thiscall boost::filesystem::directory_entry::m_get_status(class boost:Confusedystem::error_code *)const " (?m_get_status@directory_entry@filesystem@boost@@ABE?AVfile_status@23@PAVerror_code@system@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > & __thiscall boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::do_assign(char const *,char const *,unsigned int)" (?do_assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@AAEAAV12@PBD0I@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "char __fastcall boost::re_detail::w32_toupper(char,unsigned int)" (?w32_toupper@re_detail@boost@@YIDDI@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::re_detail::perl_matcher<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<struct boost:Confusedub_match<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::construct_init(class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > const &,enum boost::regex_constants::_match_flags)" (?construct_init@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@AAEXABV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@3@W4_match_flags@regex_constants@3@@Z)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: bool __thiscall boost::re_detail::perl_matcher<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<struct boost:Confusedub_match<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::find(void)" (?find@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@QAE_NXZ)
4>fileOps.obj : error LNK2001: unresolved external symbol "public: bool __thiscall boost::re_detail::perl_matcher<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<struct boost:Confusedub_match<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::match(void)" (?match@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@QAE_NXZ)
4>..\..\addon\XBMC_mythtv_cmyth_win32.pvr : fatal error LNK1120: 22 unresolved externals


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

@cfetzer

Your most recent changes seem to build and load successfully on Linux against a fresh pull of xbmc. Lots of API updates this cycle. Thanks for keeping up with the changes!


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

Hi guys,

I am close to solve 'livetv stops at show end' bug. I need few days to validate the changes and finish some test. That is a long work because i must wait lot of end of shows (a full night) to know if issue is fully resolved. I'll come back soon. br


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

@janbar

Does your solution involve preventing xbmc from reading off of the buffer when there is not enough data? If yes then it may solve the channel change delay as well since it is essentially the same bug, but just under a different circumstance. I'm not a big fan of the static delays since that requires configuration and it is slower than only reading from the backend when it is safe to do so. I'm not really a developer so I imagine that your solution would be better than mine, but I was able to fix this by using a locking object to prevent ReadLiveTV from progressing until the lock is removed. The recorder is locked when there is not enough data in the buffer and then unlocks when data becomes available. I made it timeout after 30s in case data was never coming. The player in XBMC showed "Buffering %" for a couple seconds between shows. I used the LiveTVDuration property to check if it was either 0 length, or just not increasing. Using this or a similar method it should be possible to fix the channel change delay and the stop between shows without needing user configured settings. If I can be of any help testing or anything let me know. I have a particular intrest in seeing the buffer underuns fixed. Thanks!


RE: New MythTV add-on using libcmyth - janbar - 2012-10-06

(2012-10-05, 20:15)Aubrien Wrote: @janbar

Does your solution involve preventing xbmc from reading off of the buffer when there is not enough data? If yes then it may solve the channel change delay as well since it is essentially the same bug, but just under a different circumstance. I'm not a big fan of the static delays since that requires configuration and it is slower than only reading from the backend when it is safe to do so. I'm not really a developer so I imagine that your solution would be better than mine, but I was able to fix this by using a locking object to prevent ReadLiveTV from progressing until the lock is removed. The recorder is locked when there is not enough data in the buffer and then unlocks when data becomes available. I made it timeout after 30s in case data was never coming. The player in XBMC showed "Buffering %" for a couple seconds between shows. I used the LiveTVDuration property to check if it was either 0 length, or just not increasing. Using this or a similar method it should be possible to fix the channel change delay and the stop between shows without needing user configured settings. If I can be of any help testing or anything let me know. I have a particular intrest in seeing the buffer underuns fixed. Thanks!

Hi, aubrien

To resolve "stop show", i update event handler to catch two events more from the backend: LIVETV_WATCH and DONE_RECORDING. First informs us the next switch is near. Second informs us recorder has finished the current program and (i hope!) start new recording. During period of time between these two events i flag the chain and if the buffer is empty, because the file switch cannot to be done yet, i made a timeout like you (2s by retry) to show "Buffering %". But for now i never seen this case because the period duration is less than 1s and buffer was never empty. So probably we can find a solution to merge our investigations.
Also the root of "stop show" issue is not related to buffer. I added this timeout for critical cases when event DONE_RECORDING is expected. So the root (i seen in my logs) come from Mythtv callback (GET_CURRENT_RECORDING): sometime it returns program info of previous show (the current file in the buffer) and sometime the "new" current recording. Probably because at this time it records two files: it completes the previous and start the new (3s laps). Then to resolve it i waiting event DONE_RECORDING (previous file) before call GET_CURRENT_RECORDING to retrieve the url of the new file and add it in the chain. At the same time player finish to read the buffer until empty and then switch next file of the chain. In critical case (never see until now) if the new file is not yet in the chain then i made the timeout.

Probably we can add a lock on switch file, for the first when we spawn tv and next on program breaks. If you found a good solution for your case, i can try to merge with the issue of program breaks.



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

so i still cant get the addon to build in windows, i found user earlier in this thread that said I needed to run a boost batch file that comes inside the source code, but when I try to run it it fails. So if I am starting from scratch on Windows 7 x64 and Visual C++ express, can anyone tell me what I need to do to be able to build successfully?


RE: New MythTV add-on using libcmyth - janbar - 2012-10-06

@Aubrien

I'm not a fan of lock. because when some unforeseen issues (backend crash etc ...) the frontend is locked waiting for callback. but will never returns and it hangs for long time. Finally as I am looking forward i stop all.
As you said the best way is use a variable length for timeout. When all is ok then it continue and does not wait for nothing. So we can use a setting to setup the MAX length for timeout. If you need more time then set it with higher value and if you don't want to wait then set it to 0.
(2012-10-06, 01:51)allen00se Wrote: so i still cant get the addon to build in windows, i found user earlier in this thread that said I needed to run a boost batch file that comes inside the source code, but when I try to run it it fails. So if I am starting from scratch on Windows 7 x64 and Visual C++ express, can anyone tell me what I need to do to be able to build successfully?

Hi,

if you have clone git from cfetzer then try to run script at "xbmc-pvr-addons\project\BuildDependencies\scripts\boost_d.bat"


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

(2012-10-06, 02:03)janbar Wrote: @Aubrien

I'm not a fan of lock. because when some unforeseen issues (backend crash etc ...) the frontend is locked waiting for callback. but will never returns and it hangs for long time. Finally as I am looking forward i stop all.
As you said the best way is use a variable length for timeout. When all is ok then it continue and does not wait for nothing. So we can use a setting to setup the MAX length for timeout. If you need more time then set it with higher value and if you don't want to wait then set it to 0.
(2012-10-06, 01:51)allen00se Wrote: so i still cant get the addon to build in windows, i found user earlier in this thread that said I needed to run a boost batch file that comes inside the source code, but when I try to run it it fails. So if I am starting from scratch on Windows 7 x64 and Visual C++ express, can anyone tell me what I need to do to be able to build successfully?

Hi,

if you have clone git from cfetzer then try to run script at "xbmc-pvr-addons\project\BuildDependencies\scripts\boost_d.bat"

I finally got it... I had to run "xbmc-pvr-addons\project\BuildDependencies\DownloadBuildDeps.bat" then everything ran perfectly!


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

Cool, thanks Janbar. As I mentioned earlier, you know more about this than me and I trust what you are doing. I just happen to have a setup that takes about 3s between shows and about 8s for channel switches so I have been looking into this for a while hoping for a good solution. I should be the perfect person for testing this once you are ready. I use a Hauppague HD-PVR which is pretty common so I imagine others are out there with the same issues as me.

I agree that the locks can get hung forever (I've seen this) and the front end hangs forever unless we have a max timeout. I didn't think about adding those additional events but I like it better than what I was doing. I'm really more of a .NET developer that C++ but I figured I'd play around since I know enough to be dangerous.


RE: New MythTV add-on using libcmyth - janbar - 2012-10-06

Good news. Now i can confirm that "livetv stops at show end" is an old story. I committed on my master (commit 9cccc08).
I tried to merge with last xbmc/master, but at the moment it is too buggy. So I came back to my fork of xbmc (updated since 10 days ago).
If you want to test it then use my fork of xbmc: git://github.com/janbar/xbmc.git .
Now i am starting the merge with cfetzer. br


RE: New MythTV add-on using libcmyth - janbar - 2012-10-06

@Aubrien,

If you want to try and update for you, look in file src/cmyth/libcmyth/livetv.c line 814: The delay is set to 4 (x0.5 sec) for each retry (the player make lot of retry ~50!) . Try with it and if it is not enough then set it to 6 or more.



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

Janbar,
I compiled and installed your xbmc and xbmc-pvr-addons repos and was able to get the addon to load. I changed the channel change delay as I still need that to tune. I watched a show and when it got to the end it stopped playback. It takes the HD-PVR a few seconds to stop and restart recording (~ 3s) so I wasn't surprised it didn't work the first time. I am about to adjust the values in the file as you recommended and I will report back as soon as I know more.

EDIT
OK I tried a value of 4, 10, and 20 and it still stops between shows. No matter what I set the value to it seems to stop playback and the error occurs at about 7 or 8 seconds after the transition. I don't see any of the next show ever because it tries to read a 0 size file. I attached my xbmc log.

xbmc.log
http://pastebin.com/dAuC5nHP


RE: New MythTV add-on using libcmyth - janbar - 2012-10-07

(2012-10-06, 22:08)Aubrien Wrote: Janbar,
I compiled and installed your xbmc and xbmc-pvr-addons repos and was able to get the addon to load. I changed the channel change delay as I still need that to tune. I watched a show and when it got to the end it stopped playback. It takes the HD-PVR a few seconds to stop and restart recording (~ 3s) so I wasn't surprised it didn't work the first time. I am about to adjust the values in the file as you recommended and I will report back as soon as I know more.

EDIT
OK I tried a value of 4, 10, and 20 and it still stops between shows. No matter what I set the value to it seems to stop playback and the error occurs at about 7 or 8 seconds after the transition. I don't see any of the next show ever because it tries to read a 0 size file. I attached my xbmc log.

xbmc.log
http://pastebin.com/dAuC5nHP

I need content of log file starting with "Open Live Stream..." to known what append before. Also before retry, please can you enable extra debug logging (setting in the addon) and then restart xbmc and retry. Thanks.




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

Janbar,
i couldn't get pastebin to take the log as it was loo large. Its quite alot of info for 5 mins of logging, but I know you need it to troubleshoot my issue. I used the email feature in the forum to send an email with the log and it says it sent successfully. Let me know if you get it or not. Thanks!

Here are some interesting things though...
Code:
19:54:45 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=0 , dir=0
19:55:01 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=0 , dir=1
19:55:03 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=1 , dir=0
19:55:03 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=1 , dir=0
20:00:06 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=1 , dir=1
20:00:07 T:2644073280   DEBUG: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: switch file: current=2 , dir=1

Started at 19:54:45. 15s channel switch delay. 19:55:01 channel is changed. Next show is at 20:00:00.

This repeats for a while...
Code:
20:00:07 T:2644073280   ERROR: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: no more file
20:00:07 T:2644073280   ERROR: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: no more file
20:00:07 T:2644073280   ERROR: AddOnLog: PVR MythTV Client (cmyth): LibCMyth: (cmyth)cmyth_livetv_chain_switch: no more file

"wait until recorder is ready for watching" is never posted in the log so it is like the delay loop from below is never triggered. I changed i=20.

cmyth_livetv_chain_switch
Code:
for ( i = 0; i < 20; i++ ) {
                                pthread_mutex_unlock(&mutex);
                                usleep(500000);
                                pthread_mutex_lock(&mutex);
                                if ( rec->rec_livetv_chain->livetv_watch == 1 )
                                        break;
                        }

I think what is happening is it is setting the watch flag right away but there is a period of a few seconds where the hardware becomes ready and then begins to record while the file remains 0 size. Basically the backend says go and the hardware takes a few seconds. The same is true for the channel changes except it is more like 7s instead of 3s because it has to IR blast before the little blue light on the recorder comes on. If it were to wait until the file had a non 0 size AND the watch flag was ready then it may solve both the channel change delay and this issue in one swoop. You probably wouldn't need the watch flag at all really if you just checked the file size. I was playing around with the LiveTVDuration property and if it were 0 i wouldn't let it play or if it stopped increasing and then began increasing again then it was done with the program break. That might be a cheesy way of doing it though but it worked.

Hopefully you get my full log, but maybe the above will help too.