søn, 02.04.2006 kl. 18.50 skrev J. K. Cliburn:
> On 4/2/06, Kyrre Ness Sjobak <[EMAIL PROTECTED]> wrote:
> > søn, 02.04.2006 kl. 15.35 skrev Kyrre Ness Sjobak:
> 
> > That change isn't really needed anyway. But, i have a suprise for you! A
> > Java API for ivtv-tune, a test-app for testing that that works, and even
> > a small Java app/API for scanning trough channels!
> >
> > Its not interfacing ivtv directly trough API, the ivtv-tune frontend
> > communicates with ivtv-tune trough commands.
> >
> > I am very open for comments on the code - they are more than welcome.
> >
> > Note: in the scanning app, --blah= options are listed under usage, but
> > they are not implemented yet. I know how to do it, i just haven't done
> > it (yet)
> 
> For the Java challenged like myself, how do I go about running your code?

Do you know C++? Its quite similar, except that java gives more
meaningfull error messages :) (i.e. more than "segmentation fault")

The main code is in
gIVTV/src/org/kyrsjo/givtv/backend/TuneInterface.java
, which is the API for ivtv-tune. You create a new instance of this
class, and you have the controll over a tuner (which tuner is specifyed
to the contstructor). You also have a lot of public set* and get*
-methods, which allow you to change channles/frequencymaps etc, and to
read out list of channels/frequencymaps etc. All are nicely documented
with javadoc (the /** */ comments that are something like 1/3 of the
total codesize)

If you just want to read some ligth example code of how to use this
piece of code, take a look in
gIVTV/src/org/kyrsjo/givtv/test/TestTuneInterface.java
It does nothing fancy, and was just a way for me to check that the
methods actually worked. It can only be called directly from a command
line - importing this class into a bigger program is completely
meaningless.

Some more interesting code is to be found at
gIVTV/src/org/kyrsjo/givtv/test/SearchChannels.java
Its not 100% complete (about 75-80% more like it), but it does it main
role: It searches trough channels. You can use the class as an object
within a bigger program (which is exactly what i primarily intend to
do), or you can call it directly from the command line.

Please take a look at the code! Most of the documentation is still in
there.

***** RUNNING THE CODE *****

I just discovered: The Java code i sent won't run on Suns JVM. It worked
nicely in gcj/fedora eclipse, tough... So you have to recompile, so you
need javac, not just java. But if you install java, why drop the
compiler?

This can (from the command line) be done with three commands:
(i am standing in the source folder. Note that the computer i am testing
this on does not have ivtv installed, so i can't really test any of the
commands that calls up ivtv-tune):

[EMAIL PROTECTED] src]$ pwd
/mnt/usb/gIVTV/src
[EMAIL PROTECTED] src]$ javac -d ../bin/ org/kyrsjo/givtv/backend/*
[EMAIL PROTECTED] src]$ javac -d ../bin/
org/kyrsjo/givtv/utils/SearchChannels.java
[EMAIL PROTECTED] src]$ javac -d ../bin/
org/kyrsjo/givtv/test/TestTuneInterface.java

(yes there are some warnings. This is 1.4 code, and i'm compiling with
java 1.5, whitch has some smart features for typechecking. Don't wory,
it doesn't matter)

Now, you may run the code by cd'ing to the bin/ directory:
[EMAIL PROTECTED] src]$ cd ../bin
[EMAIL PROTECTED] bin]$ java org/kyrsjo/givtv/utils/SearchChannels -h
SearchChannels v.0.9
 
Usage: givtv-search [OPTIONS]
 
-h, --help                               Print this help message and
exit
-d, --device=DEVICE              Set video device (default: /dev/video0)
-t, --freqtable=STRING   Set frequency map to use (required for -c)
-L, --list-freqtable     List all available frequency mappings
-c, --search-channels    Search trough current frequency map
-f, --search-frequencies Search trough every frequency aviable (not
implemented)

NOTE: If you are using "tab tab tab" to enter the long directory list,
DO NOT get the .class extension of the file with you. It won't work.

You could, for example, do:
[EMAIL PROTECTED] bin]$ java org/kyrsjo/givtv/utils/SearchChannels -t
europe-west -c

(i can't show you the output, as i don't have ivtv-tune installed on
this machine)

Or to run the "test suite":
[EMAIL PROTECTED] bin]$ java org/kyrsjo/givtv/test/TestTuneInterface

Now: Go out and try it! Tell me if there are any bugs (i know that none
of the --blah= (example: --device=/dev/video0) options in the search
program works.), feature requests etc. I shall pack things up more
nicely later, but for now, this will do it. Note that this is simply a
copy of my eclipse workbench folder, so importing it into eclipse should
be easy peasy.

--- Kyrre


_______________________________________________
ivtv-users mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-users

Reply via email to