Methods Summary |
---|
public boolean | endOfStream()Find out if the end of the stream has been reached.
return false;
|
public javax.media.protocol.ContentDescriptor | getContentDescriptor()Get the current content type for this stream.
return new ContentDescriptor(ContentDescriptor.RAW);
|
public long | getContentLength()Get the size, in bytes, of the content on this stream.
LENGTH_UNKNOWN is returned if the length is not known.
return LENGTH_UNKNOWN;
|
public java.lang.Object | getControl(java.lang.String controlType)Obtain the object that implements the specified
Class or Interface
The full class or interface name must be used.
If the control is not supported then null
is returned.
return null;
|
public java.lang.Object[] | getControls()Obtain the collection of objects that
control the object that implements this interface.
If no controls are supported, a zero length
array is returned.
return new Object[0];
|
public javax.media.Format | getFormat()Get the format tupe of the data that this source stream provides.
if (format == null) {
BitMapInfo bmi = new BitMapInfo();
getVideoFormat(bmi);
float frameRate = getFrameRate();
Format directShowFormat = bmi.createVideoFormat(Format.byteArray,
frameRate);
if (directShowFormat instanceof VideoFormat)
format = (VideoFormat)directShowFormat;
else
return new Format("DirectShowUnknown");
}
return format;
|
private native float | getFrameRate()Get the DirectShow reported frame rate
|
private native void | getVideoFormat(com.sun.media.vfw.BitMapInfo bmi)Fill the BitMapInfo object
|
private native boolean | isFilled()Checks if buffer was filled with data
|
public void | read(javax.media.Buffer buffer)Read from the stream without blocking.
// System.out.println("read");
Object data = buffer.getData();
int length = format.getMaxDataLength();
if (data == null || !(data instanceof byte[]) || ((byte[])data).length != length)
data = new byte[length];
buffer.setFormat(format);
setBuffer((byte[])data, buffer.getOffset());
try {
while (!isFilled())
Thread.sleep(50);
}
catch (InterruptedException e) {
System.out.println("Exception: " + e);
}
buffer.setData(data);
buffer.setOffset(0);
buffer.setLength(length);
buffer.setTimeStamp(Buffer.TIME_UNKNOWN);
|
public void | run()Runnable implementation
while (started) {
transferHandler.transferData(this);
/* WE ASSUME transferData IS A BLOCKING CALL - THIS MAY NOT BE THE
CASE FOR DIFFERENT IMPLEMENTATIONS OF Processors */
}
synchronized(this) {
notify(); // notify the stop method that the triggerThread has finished
}
|
private native void | setBuffer(byte[] data, int offset)Sets a buffer
|
public void | setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)Register an object to service data transfers to this stream.
If a handler is already registered when
setTransferHandler is called,
the handler is replaced;
there can only be one handler at a time.
this.transferHandler = transferHandler;
|
void | start()Start a thread to generate the transferData calls
if (started)
return;
triggerThread = new Thread(this);
started = true;
triggerThread.start();
|
void | stop()Stops the triggerThread
if (!started)
return;
synchronized(this) {
started = false;
try {
wait(); // wait till the triggerThread ended
}
catch (InterruptedException e) {
System.out.println("Exception: " + e);
}
}
|