PDA

View Full Version : any sample c code ???


Xsec
05-19-2004, 05:50 AM
are there any sample c codes, about extracting - inserting
data into the MFS.

where would i get the latest cross compiler and libraries,

is it better to write code in c and export the executable onto the
tivo, why Tcl ???

Please let me what libraries are required on my pc so that
i could write c code

any links ????

cojonesdetoro
05-19-2004, 12:24 PM
search for 'tivo' on sourceforge. There's a cross compiler there that should work on most linux distros. There are also lots of projects that provide source and do some of what you're looking for.

edit: MFS_FTP has binaries included for extraction and insertion of streams. I'm not sure if the source code is available for these binaries but I would guess that it is.

sanderton
05-19-2004, 12:49 PM
For dealing with aspects of MFS other than video data mainipulation, TCL is by far the easier route, as most of the MFS manipulation commands are built in.

But if you want c source, look here:

http://tivo.samba.org/download/tridge/

Waruwaru
05-20-2004, 05:44 PM
While we are on the same subject, any recommendations on which path/projects to learn from? For Ty file format, would TyStudio be a good place to start (and learn C, I guess)?

Any comments on environment? Seems like alot of hard core contributors here have multiple Tivos and cross compilers to start out with. :) Any info for newbies are greatly appreciated. :)

BTUx9
05-20-2004, 07:08 PM
Getting started in tivo development has a VERY high learning curve. Over the next few weeks/months, I hope to start work on condensing some of the resources, so new developers don't have to wade through 100-page threads to find the few pieces of info they want.

Anyone interested can join me on irc channel #TivoDev on irc.freenode.net
or check my profile for ways to contact me.

P.S. Sanderton: Is your wiki an appropriate place to host this sort of info?

sanderton
05-21-2004, 06:58 AM
Not my wiki, it's dtype's, I've just been promoting it as it could be a very useful resource.

I would have thought it would be a sensible starting place.

(Actually, I don't agree that the learning curve is that steep, at least not for TCL/MFS based hacks. I've not tried deconstructing ty's in C mind. :) )

Xsec
05-21-2004, 08:12 AM
i am using a intel pentium 3
with redhat 8.0 running on it.
can anybody suggest me the right cross compiler, and the steps
required to install it.

is this the right one -> usr.local.mips-tivo.tar.bz2
found at http://tivoutils.sourceforge.net

thank u

malfunct
05-21-2004, 12:51 PM
i am using a intel pentium 3
with redhat 8.0 running on it.
can anybody suggest me the right cross compiler, and the steps
required to install it.

is this the right one -> usr.local.mips-tivo.tar.bz2
found at http://tivoutils.sourceforge.net

thank u

I know there is a long thread here about getting a cross compiler built under cygwin, I assume that it would have links to the required packages to create the cross compiler under linux.

lgkahn
05-21-2004, 01:00 PM
I also don't agree the learning curse is that steep (if you are a developer)
I wrote my media server hack with sanderton's help in a few weeks and also other hacks/mods to add ratings to tivoweb plus editor etc. etc.

I also do have a masters and bachelors in computer science however so that helps so take what I say accordingly...

tcl is like any other scripting language and with a little help and examples it is not that difficult...

the orielly nutshell book seems passable.. but not great...
code examples seem better..

while we are on the topic of c

anyone know of api's/libraries that the tcl calls for the event handling because the event bug seems to be the biggest problem with the tcl approach to hacks currently... I was wondering if there was a way to call an api in "c" and try to bypass it to see if the problem went away ... my guess would be probably not because down deep in the OS there probably is still only one event table somewhere but it is worth a try....

thanks again for all your help sanderton...

BTUx9
05-21-2004, 05:21 PM
...with sanderton's help in a few weeks and also other hacks/mods to add ratings to tivoweb plus editor etc. etc.

I also do have a masters and bachelors in computer science however so that helps so take what I say accordingly...
Aye, there's the rub.
If you already have an extensive knowledge of computers/programming AND you can find someone knowledgable to give you a hand, it's not that bad, but many wannabe developers find it awfully difficult to pick up a new system by reading through others' code. And, getting someone to help is VERY hit-or-miss. You're much more likely to be yelled at for asking inappropriate newbie questions.

I'm just hoping to change that, or at least make a dent.

Xsec
05-24-2004, 02:28 AM
while i try to build my cross compiler...
can anybody please help me get some
c - source code files, so that i could get to know,
and program better and faster....

need some sample files , which give a nice example
of extracting data...from the MFS. (tyDb, tyDir, tyFile, tyStream)

i.e any sample code out there .... -> MFS

Waruwaru
05-24-2004, 05:34 AM
ummm... maybe you should read the replies above... ;)

Xsec
05-24-2004, 07:47 AM
ummm... maybe you should read the replies above... ;)

Ok lets get some c code...

can u help me convert the following tcl script to a c-source

### the following script returns a dump of all the strings from the
### MFS resource groups

#!/tvbin/tivosh
EnableTransactionHoldoff true
set db [dbopen]
RetryTransaction {
set swsysa [db $db open "/SwSystem/ACTIVE"]
set resgrp [dbobj $swsysa get ResourceGroup]
set groupn 0
foreach group $resgrp {
set items [dbobj $group get Item]
set itemn 0
foreach item $items {
puts "$groupn $item [dbobj $item get "String"]"
incr itemn
}
incr groupn
}
}


i am unaware of the libraries that tivo uses, it would be nice
that if u converted the above script to a c-source, rather
that pointing me to tridges code.
i've gone through some of the files, there; but it would be nice if
u posted the c - code here itself , rather than redirecting me.
this way u could save me a lot of time.

lets get some sample c-code here, so that everybody can learn

one more thing, if u've been coding in c [ for TiVo ], then converting this script should'nt take u time. so please post the code here itself.

- thankx

sanderton
05-24-2004, 08:36 AM
Ok lets get some c code...

can u help me convert the following tcl script to a c-source

### the following script returns a dump of all the strings from the
### MFS resource groups

#!/tvbin/tivosh
EnableTransactionHoldoff true
set db [dbopen]
RetryTransaction {
set swsysa [db $db open "/SwSystem/ACTIVE"]
set resgrp [dbobj $swsysa get ResourceGroup]
set groupn 0
foreach group $resgrp {
set items [dbobj $group get Item]
set itemn 0
foreach item $items {
puts "$groupn $item [dbobj $item get "String"]"
incr itemn
}
incr groupn
}
}


i am unaware of the libraries that tivo uses, it would be nice
that if u converted the above script to a c-source, rather
that pointing me to tridges code.
i've gone through some of the files, there; but it would be nice if
u posted the c - code here itself , rather than redirecting me.
this way u could save me a lot of time.

lets get some sample c-code here, so that everybody can learn

one more thing, if u've been coding in c [ for TiVo ], then converting this script should'nt take u time. so please post the code here itself.

- thankx

What's wrong with the TCL?

It may be possible to access MFS data with C, but I've not seen it done. If you look at the methods used by TyTool, TyStudio etc the MFS metadata extract is done in TCL, and the data is then passed to a C program to do whatever needs to be done.

Xsec
05-24-2004, 10:04 AM
What's wrong with the TCL?

It may be possible to access MFS data with C, but I've not seen it done. If you look at the methods used by TyTool, TyStudio etc the MFS metadata extract is done in TCL, and the data is then passed to a C program to do whatever needs to be done.

with C/C++ u can have a library
and can understand better.

when u have functions, one can probably understand fast, and probably code
once u have a library.

for .e.g we have function's

char *getSchema( char * path,...){ }
int insertObj( Obj, Type,...) { }
Obj getObj(Type,...) { }


why go through the entire TCL script inorder to understand, whats happening.
when u ppl have already understood most of it.

why dont u have a c function created immediately,
once u have understood the script, make a c-function and outsource it.
add it to the library.
lets get a GLOBAL Library built up

i know writing TCL scripts is easy to write, due to its access to MFS via
other scripts, and exe's. but then most ppl out here understand
c.

the reason i guess Tivo developers used TCL, must be for debugging
the problems. i believe most of the system code is in C.
if they can write in C, why cant we ?
and why do we have Coss- compilers built up then, for whom ???

just give me simple c- code, that accesses the MFS.

is there anything in TCL that cannot be done in C ?

if yes, then one should program in tcl. No problem then... ( use Tcl )
if no, then why TCL ???? when C exists

alldeadhomiez
05-24-2004, 10:24 AM
with C/C++ u can have a library
and can understand better.

when u have functions, one can probably understand fast, and probably code
once u have a library.

for .e.g we have function's

char *getSchema( char * path,...){ }
int insertObj( Obj, Type,...) { }
Obj getObj(Type,...) { }


why go through the entire TCL script inorder to understand, whats happening.
when u ppl have already understood most of it.

why dont u have a c function created immediately,
once u have understood the script, make a c-function and outsource it.
add it to the library.
lets get a GLOBAL Library built up

i know writing TCL scripts is easy to write, due to its access to MFS via
other scripts, and exe's. but then most ppl out here understand
c.

the reason i guess Tivo developers used TCL, must be for debugging
the problems. i believe most of the system code is in C.
if they can write in C, why cant we ?
and why do we have Coss- compilers built up then, for whom ???

just give me simple c- code, that accesses the MFS.

is there anything in TCL that cannot be done in C ?

if yes, then one should program in tcl. No problem then... ( use Tcl )
if no, then why TCL ???? when C exists

First off, cut out the AOL-speak if you want people to take you seriously. This is not a chat room.

Secondly, read the vplay sources if you want to see how we access MFS from C. The interface is substantially different from the TCL API; fortunately, it's not too hard to follow.

And finally, tridge's C code is unable to access the mfsd caches, properly handle concurrency, or write to the MFS (with the exception of filling existing tystreams). It's also quite a bit more cumbersome to use than TCL. If you feel like reworking the tridge code into a library, go ahead and post it.

malfunct
05-24-2004, 10:25 AM
is there anything in TCL that cannot be done in C ?

if yes, then one should program in tcl. No problem then... ( use Tcl )
if no, then why TCL ???? when C exists

I'd say for the applications we are doing TCL is probably the better language even though it is likely that we could write anything in C that can be written in TCL given enough time.

The biggest problem with C on the tivo platform is that it is compiled. When you have multiple platforms you are supporting (right now PPC and MIPS) it means distributing multiple binaries and hoping that people know which ones they need for thier machines. It also requires the developer or anyone that wants to play with the source to set up a cross compilation environment to build the source into binary for the platform they would like to target.

Contrast this with TCL where you can build a single tcl script that (with proper checking and handling of multiple OS versions) will run on all tivo platforms and there is no compiling necessary so you don't need to spend the time it takes to set up the cross compilation environment.

I don't know about you but learning to use another language seems worth it compared to the disadvantages I see with using C. I plan to use TCL for any tivo development I decide to do.

sanderton
05-24-2004, 10:25 AM
The C apps which exist are to perform non-MFS functions (like an FTP daemon) where the xtra speed of compiled C is useful as the TiVo procesor is slow. The cross compiler has also been used to create TiVo binaries of teh common Linux utils like ps, tar and ls.

You can have libraries in TCL too, by the way. In fact several exist on your TiVo if you have a rummage.

lgkahn
05-24-2004, 06:19 PM
that's kind of what I was alluding at...

the only advantages I see for C code...

1. speed is required...

2. to get around bugs in tcl such as the event bug....

malfunct
05-24-2004, 06:40 PM
that's kind of what I was alluding at...

the only advantages I see for C code...

1. speed is required...


I'll give you that point though the speed is hardly necessary for many of the hacks I've seen that do little more than scan a bit of the database and maybe make some changes (not to oversimplify the complexity of the scripts, just to state that they aren't necessarily processor intensive inside the script, MFS access of course is a different story as the tivo may spend a lot of time inside its libraries fetching the data but C would not speed that up).


2. to get around bugs in tcl such as the event bug....

The event switcher bug is in the event switcher, not in the tcl scripts, so if you register for events using C (if you can even swing that), you are still subject to the event switcher bug.

alldeadhomiez
05-24-2004, 07:39 PM
that's kind of what I was alluding at...

the only advantages I see for C code...

1. speed is required...

2. to get around bugs in tcl such as the event bug....

It sounds like you haven't used TCL much on the TiVo platform. tivosh startup time (and thus CPU time) is high, memory usage is obnoxious, and you don't have anywhere near as much control over things as you do in C. Furthermore, you can write "native" modules in C for almost any other scripting language, so you can always use the right tool for the job.

Unfortunately, the closed source MFS libraries we access from tivosh are pretty darn handy, so a lot of tasks require the use of TCL.

Zirak
05-24-2004, 07:53 PM
Furthermore, you can write "native" modules in C for almost any other scripting language, so you can always use the right tool for the job.


Except that facility is broken in the tivosh TCL implementation.

Xsec
05-25-2004, 07:32 AM
are the source codes for the following available anywhere ??

mfs_stdinsert
mfs_stream
mfs_tarstream

sanderton
05-25-2004, 10:11 AM
http://www.dealdatabase.com/forum/showthread.php?t=34027

Search button works well. :)

You should also look at alt.org.

lgkahn
05-25-2004, 10:11 AM
I actually have written a fair amount of tcl by now...

and also quite a lot of C (just not for the tivo)