|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.luniks.linux.jv4linfo.JV4LInfo
Class providing some static methods to query and set video
for linux (two) devices using the JNI.
The methods work a little bit like the ioctl's of the v4l and v4l2
API's: An instance of a class representing a particular struct
is given as argument to the corresponding method, which sets all
fields to the values provided by the ioctl call. The classes
have getters and some convenience methods, and setters for the
changeable fields of the structs.
This class can also return instances of type V4LCtrl and V4L2Ctrl
that hold information about a particular video device and provide
some methods to control the device, such as setting the selected
video norm/standard.
The methods getV4LInfo() and getV4L2Info() are in a way redundant
because the returned instances are also available as members of
V4LCtrl and V4L2Ctrl, respectively.
This class requires the shared library "libjv4linfo.so" to be in the
LD_LIBRARY_PATH or the java.library.path system property.
PLEASE NOTE, that this API is not only incomplete but also pretty
experimental, so it might not do things the way they should be done.
It has currently been tested only with a Hauppauge WinTV PCI on
Kernel 2.4 and 2.6.
The source can be found here: jv4linfo-0.2.1-src.jar
Example:
// Get/set the frequency of the tuner associated with the // input with index '0' using the native methods of JV4LInfo try { // Open the video device JV4LInfo.open("/dev/video0"); // Get the input with index '0' V4L2Input input = new V4L2Input(); input.setIndex(0); JV4LInfo.getV4L2Input(input); System.out.println("Input: " + input.getName()); if(input.isTuner()) { // Get the index of the tuner associated with the input int tunerIndex = input.getTuner(); // Get the frequency of the tuner V4L2Frequency freq = new V4L2Frequency(); freq.setTuner(tunerIndex); JV4LInfo.getV4L2Frequency(freq); System.out.println("Current frequency is: " + freq.getFrequency()); // Set a frequency freq.setFrequency(2999); JV4LInfo.setV4L2Frequency(freq); } } catch(JV4LInfoException e) { e.printStackTrace(); } // Make sure the device will be closed in any case finally { JV4LInfo.close(); } // Get/set the frequency using a convenience method of V4L2Ctrl. // The method will look at all inputs starting with index '0' // until an input of type tuner has been found. Then it gets/sets // the frequency of the tuner associated with that index. try { V4L2Ctrl ctrl = JV4LInfo.getV4L2Ctrl("/dev/video0"); int frequency = ctrl.getSelectedFrequency().getFrequency(); System.out.println("Current frequency is: " + frequency); ctrl.setSelectedFrequency(2999); } catch(JV4LInfoException e) { e.printStackTrace(); }
Field Summary | |
private static int |
file
Reference to the device file, only used from within the C code |
static java.lang.String |
LIBRARY
Platform independent library name |
static java.lang.String |
V4L
API name "v4l" |
static java.lang.String |
V4L2
API name "v4l2" |
Constructor Summary | |
JV4LInfo()
|
Method Summary | |
static int |
close()
Native method to close the device |
static long |
getSelectedFrequency()
Native method to get the selected v4l frequency |
static int |
getSelectedV4L2Input()
Native method to get the selected v4l2 input |
static int |
getSelectedV4L2Standard()
Native method to get the selected v4l2 standard |
static void |
getV4L2Capability(V4L2Capability cap)
Native method to get v4l2 capabilies |
static void |
getV4L2Control(V4L2Control control)
Native method to get a v4l2 control |
static V4L2Ctrl |
getV4L2Ctrl(java.lang.String device)
Returns an instance of the class V4L2Ctrl which allows to
get information about and to control the video device specified as
argument using the v4l2 API. |
static void |
getV4L2Frequency(V4L2Frequency frequency)
Native method to get a v4l2 frequency |
static V4L2Info |
getV4L2Info(java.lang.String device)
Queries the device specified as argument using the v4l2 API and returns an instance of the class V4L2Info which holds the gathered
information about the device. |
static void |
getV4L2Input(V4L2Input input)
Native method to get a v4l2 input |
static void |
getV4L2Standard(V4L2Standard std)
Native method to get a v4l2 standard |
static void |
getV4L2Tuner(V4L2Tuner tuner)
Native method to get a v4l2 tuner |
static V4LCtrl |
getV4LCtrl(java.lang.String device)
Returns an instance of the class V4LCtrl which allows to
get information about and to control the video device specified as
argument using the v4l API. |
static V4LInfo |
getV4LInfo(java.lang.String device)
Queries the device specified as argument using the v4l API and returns an instance of the class V4LInfo which holds the gathered
information about the device. |
static void |
getVideoAudio(VideoAudio audio)
Native method to get a v4l audio |
static void |
getVideoCapability(VideoCapability cap)
Native method to get v4l capabilies |
static void |
getVideoChannel(VideoChannel chan)
Native method to get a v4l channel (input) |
static void |
getVideoTuner(VideoTuner tuner)
Native method to get a v4l tuner |
static boolean |
isV4L2Available(java.lang.String device)
Tries to get the capabilties of the device specified as argument using the V4L2 API, and returns true if that was successful, false otherwise. |
static void |
main(java.lang.String[] args)
For testing, takes the API (v4l|v4l2) as first and the device for example /dev/video0 , as second argument |
static void |
open(java.lang.String device)
Native method to open the device |
static void |
setSelectedFrequency(long freq)
Native method to set the selected frequency |
static void |
setSelectedV4L2Input(int index)
Native method to set the selected v4l2 input |
static void |
setSelectedV4L2Standard(long id)
Native method to set the selected v4l2 standard |
static void |
setV4L2Control(V4L2Control control)
Native method to set a v4l2 control Sets the fields id and value |
static void |
setV4L2Frequency(V4L2Frequency frequency)
Native method to set a v4l2 frequency Sets the fields tuner and frequency |
static void |
setV4L2Tuner(V4L2Tuner tuner)
Native method to set a v4l2 tuner Sets the fields index and audmode |
static void |
setVideoAudio(VideoAudio audio)
Native method to set a v4l audio Sets the fields audio, volume, bass, treble, balance, flags and mode |
static void |
setVideoChannel(VideoChannel chan)
Native method to set a v4l channel Sets the fields channel and norm |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String V4L
public static final java.lang.String V4L2
public static final java.lang.String LIBRARY
private static final int file
Constructor Detail |
public JV4LInfo()
Method Detail |
public static boolean isV4L2Available(java.lang.String device) throws JV4LInfoException
device
- the device to be used for the test
JV4LInfoException
public static V4LInfo getV4LInfo(java.lang.String device) throws JV4LInfoException
V4LInfo
which holds the gathered
information about the device.
device
- the device to be queried
V4LInfo
holding info about the device
JV4LInfoException
public static V4L2Info getV4L2Info(java.lang.String device) throws JV4LInfoException
V4L2Info
which holds the gathered
information about the device.
device
- the device to be queried
V4L2Info
holding info about the device
JV4LInfoException
public static V4LCtrl getV4LCtrl(java.lang.String device) throws JV4LInfoException
V4LCtrl
which allows to
get information about and to control the video device specified as
argument using the v4l API.
device
- the device to be controlled
V4LCtrl
allowing to control the device
JV4LInfoException
public static V4L2Ctrl getV4L2Ctrl(java.lang.String device) throws JV4LInfoException
V4L2Ctrl
which allows to
get information about and to control the video device specified as
argument using the v4l2 API.
device
- the device to be controlled
V4L2Ctrl
allowing to control the device
JV4LInfoException
public static void open(java.lang.String device) throws JV4LInfoException
device
- the device file to be opened
JV4LInfoException
public static int close()
public static void getVideoCapability(VideoCapability cap) throws JV4LInfoException
cap
- the VideoCapability to be filled in
JV4LInfoException
public static void getVideoChannel(VideoChannel chan) throws JV4LInfoException
chan
- the VideoChannel to be filled in
JV4LInfoException
public static void getVideoTuner(VideoTuner tuner) throws JV4LInfoException
tuner
- the VideoTuner to be filled in
JV4LInfoException
public static void getVideoAudio(VideoAudio audio) throws JV4LInfoException
audio
- the VideoAudio to be filled in
JV4LInfoException
public static void setVideoChannel(VideoChannel chan) throws JV4LInfoException
chan
- the VideoChannel to be set
JV4LInfoException
public static void setVideoAudio(VideoAudio audio) throws JV4LInfoException
audio
- the VideoAudio to be set
JV4LInfoException
public static long getSelectedFrequency() throws JV4LInfoException
JV4LInfoException
public static void setSelectedFrequency(long freq) throws JV4LInfoException
freq
- the frequency value in 62.5 (k)Hz units
JV4LInfoException
public static void getV4L2Capability(V4L2Capability cap) throws JV4LInfoException
cap
- the V4L2Capability to be filled in
JV4LInfoException
public static void getV4L2Input(V4L2Input input) throws JV4LInfoException
input
- the V4L2Input to be filled in
JV4LInfoException
public static void getV4L2Standard(V4L2Standard std) throws JV4LInfoException
std
- the V4L2Standard to be filled in
JV4LInfoException
public static void getV4L2Tuner(V4L2Tuner tuner) throws JV4LInfoException
tuner
- the V4L2Tuner to be filled in
JV4LInfoException
public static void getV4L2Frequency(V4L2Frequency frequency) throws JV4LInfoException
frequency
- the V4L2Frequency to be filled in
JV4LInfoException
public static void getV4L2Control(V4L2Control control) throws JV4LInfoException
control
- the V4L2Control to be filled in
JV4LInfoException
public static void setV4L2Tuner(V4L2Tuner tuner) throws JV4LInfoException
tuner
- the V4L2Tuner to be set
JV4LInfoException
public static void setV4L2Frequency(V4L2Frequency frequency) throws JV4LInfoException
frequency
- the V4L2Frequency to be set
JV4LInfoException
public static void setV4L2Control(V4L2Control control) throws JV4LInfoException
control
- the V4L2Control to be set
JV4LInfoException
public static int getSelectedV4L2Input() throws JV4LInfoException
JV4LInfoException
public static int getSelectedV4L2Standard() throws JV4LInfoException
JV4LInfoException
public static void setSelectedV4L2Input(int index) throws JV4LInfoException
index
- the index specifying the input to select
JV4LInfoException
public static void setSelectedV4L2Standard(long id) throws JV4LInfoException
id
- the id specifying the standard to select
JV4LInfoException
public static void main(java.lang.String[] args)
/dev/video0
, as second argument
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |