net.sf.dvbcentral.lib
Class Frontend

java.lang.Object
  extended by net.sf.dvbcentral.lib.Frontend
All Implemented Interfaces:
Closeable, Channel, ReadableByteChannel

public final class Frontend
extends Object
implements ReadableByteChannel

Abstraction over a DVB frontend. Instances can be created using find(int) method and allows one to tune to any frequency (see Tune), subscribe to certain PIDs using openPID(int) and read the transmitted data through ReadableByteChannel.read(java.nio.ByteBuffer) method.


Nested Class Summary
static class Frontend.PID
          Represents one pid.
static class Frontend.Stats
          A structure representing a snapshot of frontends' radio performance statistics.
 
Method Summary
 void close()
           
static Frontend createVirtual(ReadableByteChannel channel, Collection<? super Frontend.PID> pids, Collection<? super Tune> tunes)
          Creates a fake, virtual frontend that delegates all of its operations on provided interfaces.
static Frontend find(int device)
          Basic factory method for creating frontend for devices registered in the system.
 Frontend.Stats getStats()
          Retrieves the radio performance statistics from the frontend.
 boolean isOpen()
           
 Frontend.PID openPID(int pid)
          Opens new PID for reading.
 int read(ByteBuffer byteBuffer)
           
 void tune(Tune tune)
          Tunes the frontend to new frequency and other aspects provided by given tune.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

find

public static Frontend find(int device)
                     throws IOException
Basic factory method for creating frontend for devices registered in the system.

Parameters:
device - number of the adapter to create frontend for
Throws:
IOException

createVirtual

public static Frontend createVirtual(ReadableByteChannel channel,
                                     Collection<? super Frontend.PID> pids,
                                     Collection<? super Tune> tunes)
Creates a fake, virtual frontend that delegates all of its operations on provided interfaces. All the methods that read delegate to the provided ReadableByteChannel implementation. The other arguments are not necessary, but if one of them is provided, their methods are going to be called as follows: frontend.openPID(...) results in a call to pids.add(theNewlyCreatedPid) and closing the pid results in pids.remove(theClosedPid). Calls to tune are going to result in a call to tunes.add(theTune).

Parameters:
channel - the channel to read the data from
pids - the collection to add and remove opened pids from, can be null
tunes - the collection to add the tunes called on this frontend to, can be null
Returns:
an new instance of a virtual frontend
Since:
1.4

tune

public void tune(Tune tune)
          throws IOException
Tunes the frontend to new frequency and other aspects provided by given tune.

Parameters:
tune - the tune to tune to
Throws:
IOException - if tuning failed

openPID

public Frontend.PID openPID(int pid)
                     throws IOException
Opens new PID for reading. This is method returns a handle, which one has to hold to receive the packets for the given pid.

Parameters:
pid - integer number describing the PID
Returns:
handle to control the receiver
Throws:
IOException - if opening pid fails

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Channel

read

public int read(ByteBuffer byteBuffer)
         throws IOException
Specified by:
read in interface ReadableByteChannel
Throws:
IOException

getStats

public Frontend.Stats getStats()
Retrieves the radio performance statistics from the frontend.

Returns:
a structure containing a snapshot of frontend statistics.


Built on May 22 2009.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.