Kodi Community Forum
Support for streaming from a ReplayTV - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: Support for streaming from a ReplayTV (/showthread.php?tid=786)

Pages: 1 2 3 4 5 6 7 8


- rtvguy - 2004-02-05

(cyberplague @ feb. 05 2004,08:06 Wrote:rtvguy - i guess you got my guide.dat i sent, yes i do record that show.  do you think you could change the library to remove those charaters?  if so could you make the changes and post alink to the changed files so i can test it out?

cp
yeah, if that is the problem, i'll definitely fix it. i'm recording that show tonight, so i'll be able to test here to confirm (hopefully). btw, the guide you sent me parsed fine. so, seemingly it is either the invalid character thing or something else entirely.


- cyberplague - 2004-02-05

well from the logging that i added, it seems that maybe the ip is getting messed up.

Quote:18-02-2004 05:59:11   entered discovering all replaytvs
18-02-2004 05:59:11  sent request for identification
18-02-2004 05:59:18   entered discovering all replaytvs
18-02-2004 05:59:18 using ip address:ƒä v‹ëè)ùÿÿ_^‹ã[]â
18-02-2004 05:59:18 exception in capplication::framemove()

the varialible that is suppose to be listed after using ip address: is strurl.

i am going to have to figure out what is wrong, any clues?  i am going to add some further logging, that is basically going to just contain your comments to see how far it is getting before it fails, and some values of variables, should help us figure out where is it crapping out and where to put our focus.

still not sure why others can get it working but i can't...hrm

cp


- dinzdale - 2004-02-05

cyber -
how are you directing your log output ? are you sending them to a file on xbox and then just ftping back to the pc ? do you have a debug environment setup (i briefly read about of ways to do this, but don't want mess with the bios, etc.).

thanks
dinzdale


- cyberplague - 2004-02-05

dinz - with the latest cvs it has logging capabilities, all i did was modify the rtvdirectory.cpp with some logging commands to create log entries like you saw above. i am in the process of logging everything, to the xbmc.log file on the xbox. hopefully that will help figure out what the heck the problem is so we can narrow our focus. once i get all the logging in and confirm it doesn't mess anything up, i can send it to ya if you like so you can get a log as well so we can compare.

cp


- dinzdale - 2004-02-05

cyber -

sounds like a good plan ... let me know if there's anything else i can do -- in the meantime, i'll continue investigating on my own.

dinzdale


- cyberplague - 2004-02-06

here is my updated rtvdirectory.cpp file with logging, please use this with the current cvs then load xbmc, and browse to the replay, post the resulting xbmc.log file here please.

Quote:// rtvdirectory.cpp: implementation of the crtvdirectory class.
//
//////////////////////////////////////////////////////////////////////

#include "rtvdirectory.h"
#include "tinyxml/tinyxml.h"
#include "../url.h"
#include "../util.h"
#include "../utils/log.h"
#include "../sectionloader.h"

extern "c" {
#include "../lib/librtv/interface.h"
}

//////////////////////////////////////////////////////////////////////
// construction/destruction
//////////////////////////////////////////////////////////////////////

crtvdirectory::crtvdirectory(void)
{
csectionloader::load("librtv");
}

crtvdirectory::~crtvdirectory(void)
{
csectionloader::unload("librtv");
}

//******************************************************************************************
***
bool crtvdirectory::getdirectory(const cstdstring& strpath,vecfileitems &items)
{
curl url(strpath);

cstdstring strroot=strpath;
if (!cutil::hasslashatend(strpath) )
strroot+="/";

// host name is "*" so we try to discover all replaytvs. this requires some trickery but works.
if (url.gethostname() == "*")
{
clog::log(" entered discovering all replaytvs");
// check to see whether the url's path is blank or "video"
if (url.getfilename() == "" || url.getfilename() == "video")
{
struct rtv * rtv = null;
int numrtv;

// request that all replaytvs on the lan identify themselves. each replaytv
// is given 3000ms to respond to the request. rtv_discovery returns an array
// of structs containing the ip and friendly name of all replaytvs found on the lan.
// for some reason, dvarchive doesn't respond to this request (probably only responds
// to requests from an ip address of a real replaytv).
clog::log("sent request for identification");
numrtv = rtv_discovery(&rtv, 3000);

// run through the array and add the replaytvs found as folders in xbmc.
// we must add the ip of each replaytv as if it is a file name at the end of a the
// auto-discover url--e.g. rtv://*/192.168.1.100--because xbmc does not permit
// dyamically added shares and will not play from them. this little trickery is
// the best workaround i could come up with.
clog::log("numrtv = %s", numrtv);
for (int i=0; i < numrtv; i++)
{
cfileitem* pitem = new cfileitem(rtv[i].friendlyname);
// this will keep the /video or / and allow one to set up an auto replaytv
// share of either type--simple file listing or replayguide listing.
pitem->m_strpath = strroot + rtv[i].hostname;
pitem->m_bisfolder = true;
items.push_back(pitem);
}
free(rtv);
return true;
// else the url's path should be an ip address of the replaytv
} else {
cstdstring strurl, strrtv;
int pos;

// isolate the ip from the url and replace the "*" with the real ip
// of the replaytv. e.g., rtv://*/video/192.168.1.100/ becomes
// rtv://192.168.1.100/video/ . this trickery makes things work.
strurl = strroot.trimright('/');
pos = strurl.reversefind('/');
strrtv = strurl.left(pos + 1);
strrtv.replace("*", strurl.mid(pos + 1));
curl tmpurl(strrtv);
clog::log("strurl = %s", strurl);
clog::log("strrtv = %s", strrtv);
// force the newly constructed share into the right variables to
// be further processed by the remainder of getdirectory.
url = tmpurl;
strroot = strrtv;
clog::log("strrtv = %s", strroot);
}
}

// allow for replaytvs on ports other than 80
clog::log("allowing for rtvs on ports other than 80");
cstdstring strhostandport;
strhostandport = url.gethostname();
if (url.hasport())
{
char buffer[10];
strhostandport += ':';
strhostandport += itoa(url.getport(), buffer, 10);
clog::log("strhostandport - %s", strhostandport);
}

// no path given, list shows from replayguide
if (url.getfilename() == "")
{
unsigned char * data = null;

// get the rtv guide data in xml format
clog::log("no path given, listing show from replayguide");
rtv_get_guide_xml(&data, strhostandport.c_str());

// begin parsing the xml data
clog::log("begin parsing xml data");

tixmldocument xmldoc;
xmldoc.parse( (const char *) data );
if ( xmldoc.iserror() )
{
free(data);
return false;
}
tixmlelement* prootelement =xmldoc.rootelement();
if (!prootelement)
{
free(data);
return false;
}

const tixmlnode *pchild = prootelement->firstchild();
while (pchild>0)
{
cstdstring strtagname=pchild->value();

if ( !cutil::cmpnocase(strtagname.c_str(),"item") )
{
const tixmlnode *namenode=pchild->firstchild("displayname");
const tixmlnode *qualitynode=pchild->firstchild("quality");
const tixmlnode *recordednode=pchild->firstchild("recorded");
const tixmlnode *pathnode=pchild->firstchild("path");
const tixmlnode *durationnode=pchild->firstchild("duration");
const tixmlnode *sizenode=pchild->firstchild("size");
const tixmlnode *atrbnode=pchild->firstchild("attrib");

systemtime dtdatetime;
__int64 dwfilesize=0;
memset(&dtdatetime,0,sizeof(dtdatetime));

// displayname
const char* szname = null;
if (namenode)
{
szname = namenode->firstchild()->value();
}
else
{
// something went wrong, the recording has no name
clog::log("something went wrong, the recording has no name");

free(data);
return false;
}

// quality
const char* szquality = null;
if (qualitynode)
{
szquality = qualitynode->firstchild()->value();
}

// recorded
if (recordednode)
{
cstdstring strrecorded=recordednode->firstchild()->value();
int iyear,imonth,iday;

iyear=atoi(strrecorded.left(4).c_str());
imonth=atoi(strrecorded.mid(5,2).c_str());
iday=atoi(strrecorded.mid(8,2).c_str());
dtdatetime.wyear=iyear;
dtdatetime.wmonth=imonth;
dtdatetime.wday=iday;

int ihour,imin,isec;
ihour=atoi(strrecorded.mid(11,2).c_str());
imin=atoi(strrecorded.mid(14,2).c_str());
isec=atoi(strrecorded.mid(17,2).c_str());
dtdatetime.whour=ihour;
dtdatetime.wminute=imin;
dtdatetime.wsecond=isec;
}

// path
const char* szpath = null;
if (pathnode)
{
szpath = pathnode->firstchild()->value();
}
else
{
// something went wrong, the recording has no filename
clog::log("something went wrong, the recording has no filename");
free(data);
return false;
}

// duration
const char* szduration = null;
if (durationnode)
{
szduration = durationnode->firstchild()->value();
}

// size
// note: size here is actually just duration in minutes because
// filesize is not reported by the stripped down guideparser i use
if (sizenode)
{
dwfilesize=_atoi64( sizenode->firstchild()->value() );
}

// attrib
// note: not currently reported in the xml guide data, nor is it particularly
// needed unless someone wants to add the ability to sub-divide the recordings
// into categories, as on a real rtv.
int attrib = 0;
if (atrbnode)
{
attrib = atoi( atrbnode->firstchild()->value() );
}

bool bisfolder(false);
if (attrib & file_attribute_directory)
bisfolder=true;

if ( bisfolder || isallowed( szpath) )
{
cfileitem* pitem = new cfileitem(szname);
memcpy(&pitem->m_sttime, &dtdatetime,sizeof(dtdatetime));
pitem->m_strpath=strroot + szpath;
// hack to show duration of show in minutes as kb in xmbc because
// it doesn't currently permit showing duration in minutes.
// e.g., a 30 minute show will show as 29.3 kb in xbmc.
pitem->m_dwsize=dwfilesize * 1000;
pitem->m_bisfolder = bisfolder;
items.push_back(pitem);
}
}

pchild=pchild->nextsibling();
}

free(data);

// path given (usually video), list filenames only
} else {
clog::log("path given (usually video), list filenames only");
unsigned char * data;
char * p, * q;
unsigned long status;

// return a listing of all files in the given path
clog::log("return all listing of files in path");
clog::log("data - %s", &data);

status = rtv_list_files(&data, strhostandport.c_str(),url.getfilename().c_str());
if (status == 0) {
clog::log("status is zero, returning false");
return false;
}

// loop through the file list using pointers p and q, where p will point to the current
// filename and q will point to the next filename
p = (char *) data;
while (p) {
clog::log("p is %s", p);
// look for the end of the current line of the file listing
q = strchr(p, '\n');
// if found, replace the newline character with the null terminator
if (q) {
*q = '\0';
// increment q so that it points to the next filename
q++;
// *p should be the current null-terminated filename in the list
if (*p)
{
// only display mpeg files in xbmc (but not circular.mpg, as that is the rtv
// video buffer and xbmc may cause problems if it tries to play it)
if (strstr(p, ".mpg") && !strstr(p, "circular"))
{
cfileitem* pitem = new cfileitem(p);
pitem->m_strpath=strroot + p;
pitem->m_bisfolder=false;
// the list returned by the rtv doesn't include file sizes, unfortunately
//pitem->m_dwsize = atol(szsize);
items.push_back(pitem);
}
}
}
// point p to the next filename in the list and loop
p = q;
}

free(data);
}

return true;
}

cp


- rtvguy - 2004-02-06

well, i have a series of good news/bad news to report.

good news: i added a show title with an "é" to xbmc, and it displayed without problem.

bad news: this means the problem probably lies elsewhere.

good news: i have no problems listing shows either filenames only or by title with the cvs build. (this is with either stack or unstack set too).

bad news: when i actually click on a file to play it, i get a debug exception. if i let it continue, i get a pink screen of death (which i had never seen before).

good news: i get this same error when i try to play *any* video file, even via relax/xns.

bad news: the problem seems to lie somewhere within mplayer.dll, and it doesn't seem to contain debug information. diagnosing the problem there is tough with disassembly only.

good news: there is an updated mplayer.dll in the cvs i just updated to, so maybe that fixes the problem.

bad news: it didn't. i still get an error like so for video files:
"msg:mplayer_open_file(rtv://192.168.1.41/video/1075084198.mpg) done 1.0000

cmplayer::openfile() rtv://192.168.1.41/video/1075084198.mpg failed"

again, since this error occurs even using xns to play other video files, it doesn't appear to be replaytv related. i'm not sure what the deal is now.


- cyberplague - 2004-02-06

rtvguy - did you check the mplayer cvs to see if the open.c changes need to be used again?

cp


- rtvguy - 2004-02-06

(cyberplague @ feb. 05 2004,16:17 Wrote:rtvguy - did you check the mplayer cvs to see if the open.c changes need to be used again?

cp
yeah, they don't appear to be needed.

i'm not sure why i'm getting these psods when i play all videos now. have you tried playing other videos via relax using the current cvs build? if so, any problems?

fwiw, i did notice something else that probably has no bearing on our current issues (it didn't fix my psods). "librtv" didn't get put into the suppress preloading property for the xbmc project. i think it should be there, but it may make no difference whatsoever that it's not.


- cyberplague - 2004-02-06

ok, i will add it in and recompile and test. i will have to setup my xns shares when i get home and try it out.

very strange, i will let you know. will be home in about an hour.

cp


- rtvguy - 2004-02-06

ok,
now things just got really weird. all of my work has been done with a debug build of xbmc. i just tried a release build with interesting results. the good news is i don't get a psod when i try to play video using xns. the bad news is that i do now get lockups when i try choose the name of a replaytv in the list. so, it appears that the reason it works for me and not for you is that i have been using the debug default.xbe. now, why listing works in debug but not release while video playback works in release but not debug is a mystery to me. it also makes it difficult for me to figure out what is going on here.


- cyberplague - 2004-02-06

well i am home and compiling with my new logging in, hopefully it will help figure out what is wrong, we will know in about 5 mins.

cp


- dinzdale - 2004-02-06

Quote:xbmc\filesystem\rtvdirectory.cpp(32) : warning c4518: 'bool ' : storage-class or type specifier(s) unexpected here; ignored
xbmc\filesystem\rtvdirectory.cpp(33) : error c2501: 'directory::crtvdirectory::getdirectory' : missing storage-class or type specifiers
xbmc\filesystem\rtvdirectory.cpp(33) : error c2556: 'int ***directory::crtvdirectory::getdirectory(const cstdstringa &,vecfileitems &) ' : overloaded function differs only by return type from 'bool directory::crtvdirectory::getdirectory(const cstdstringa &,vecfileitems &)'
d:\xbmcs2\xbmc\xbmc\filesystem\rtvdirectory.h(17) : see declaration of 'directory::crtvdirectory::getdirectory'
xbmc\filesystem\rtvdirectory.cpp(33) : error c2040: 'directory::crtvdirectory::getdirectory' : 'int ***(const cstdstringa &,vecfileitems &) ' differs in levels of indirection from 'bool (const cstdstringa &,vecfileitems &)'

cyber - trying your mod file but getting compiler errors. before i spend alot of time on this, did you change the header file too ?

dinz


- cyberplague - 2004-02-06

nope just that file, must be formatting issues with the copy and paste you did, i will upload the file to my webhost later tonight if i get a chance or first thing in the morning.

cp


- rtvguy - 2004-02-06

ok, i've partially figured out where things are going wrong.  the exceptions and lockups result when execution reaches this code at line 1060 of guideparser.cpp (part of librtv.lib):
printf("%s\n",lpsztitle);
printf("%s\n\n",lpszcopyright);
printf("%s\n",lpszcomment);

commenting out those lines seems to fix the problem.  i cannot figure that out, however, as there are many other uses of printf later that *don't* cause any problem apparently.  maybe it is the fact that those variable are really #define's?  i don't know.

unfortunately, even with this fix in place i still get general instability, especially when switching between different shows.  i'm not sure why.  i never had such problems with the cvs source i originally used to implement this patch.  there seem to be some strange things going on, and i'm having difficulty reconciling them.  next, i will try getting rid of all the uses of printf/fprint in librtv.  i really would like to do this with an xbox specific #define to keep librtv compatible for both xbox and (future) win32 use.