Methods Summary |
---|
public void | close()Closes the plug-in component and releases resources. No more data
will be accepted by the plug-in after a call to this method. The
plug-in can be reinstated after being closed by calling
open .
// sub class can override
|
protected abstract int | doProcess(javax.media.Buffer buffer)
|
public java.awt.Rectangle | getBounds()Returns the region in the component where the video will be
rendered to. Returns null if the entire component is being used.
return bounds;
|
public java.awt.Component | getComponent()Returns an AWT component that it will render to. Returns null
if it is not rendering to an AWT component.
if (component == null) {
// TODO: Try MSHeavyComponent for MS VM
try {
Class mshc = Class.forName("com.sun.media.renderer.video.MSHeavyComponent");
if (mshc != null)
component = (Component) mshc.newInstance();
} catch (Throwable t) {
component = new HeavyComponent();
}
((HeavyComponent)component).setRenderer( this );
component.setBackground(getPreferredBackground());
if (compListener == null)
compListener = new CompListener();
component.addComponentListener(compListener);
}
return component;
|
public java.awt.Component | getControlComponent()
return null;
|
public java.lang.Object[] | getControls()Controls methods
if (controls != null)
return controls;
frameGrabber = (FrameGrabbingControl) this;
controls = new Control[1];
controls[0] = frameGrabber;
return controls;
|
public java.lang.String | getName()Returns a descriptive name for the plug-in.
This is a user readable string.
return name;
|
protected java.awt.Color | getPreferredBackground()Local methods
return Color.black;
|
public javax.media.Format[] | getSupportedInputFormats()Lists the possible input formats supported by this plug-in.
return supportedFormats;
|
public javax.media.Buffer | grabFrame()
synchronized (lastBuffer) {
Buffer newBuffer = new Buffer();
newBuffer.setFormat(lastBuffer.getFormat());
newBuffer.setFlags(lastBuffer.getFlags());
newBuffer.setLength(lastBuffer.getLength());
newBuffer.setOffset(0);
newBuffer.setHeader(lastBuffer.getHeader());
newBuffer.setData(lastBuffer.getData());
Object data = lastBuffer.getData();
int length = lastBuffer.getLength();
Object newData;
if (data instanceof byte[])
newData = new byte[length];
else if (data instanceof short[])
newData = new short[length];
else if (data instanceof int[])
newData = new int[length];
else
return newBuffer;
System.arraycopy(data, lastBuffer.getOffset(),
newData, 0,
length);
newBuffer.setData(newData);
return newBuffer;
}
|
protected boolean | isStarted()
return started;
|
protected java.awt.Dimension | myPreferredSize()
return new Dimension(inWidth, inHeight);
|
public void | open()Opens the plug-in software or hardware component and acquires
necessary resources. If all the needed resources could not be
acquired, it throws a ResourceUnavailableException. Data should not
be passed into the plug-in without first calling this method.
// sub class can override
|
public int | process(javax.media.Buffer inbuffer)
if (inbuffer.getLength() == 0)
return BUFFER_PROCESSED_OK;
int result;
//System.err.println("BasicVideoRenderer.process() not implemented");
synchronized (lastBuffer) {
result = doProcess(inbuffer);
// Keep the last buffer
if ( result == BUFFER_PROCESSED_OK ) {
lastBuffer.copy(inbuffer, true);
}
}
return result;
|
protected void | removingComponent()
|
protected void | repaint()
System.err.println("repaint call not implemented on this renderer");
|
public void | reset()Resets the state of the plug-in. Typically at end of media or when media
is repositioned.
// sub class can override
|
void | resized(java.awt.Component c)
if (c != null && c == component) {
Dimension d = component.getSize();
outWidth = d.width;
outHeight = d.height;
//repaint();
}
|
protected synchronized void | setAvailable(boolean on)
componentAvailable = on;
if (!componentAvailable)
removingComponent();
|
public void | setBounds(java.awt.Rectangle rect)Sets the region in the component where the video is to be
rendered to. Video is to be scaled if necessary. If rect
is null, then the video occupies the entire component.
bounds = rect;
|
public synchronized boolean | setComponent(java.awt.Component comp)Requests the renderer to draw into a specified AWT component.
Returns false if the renderer cannot draw into the specified
component.
reset();
component = comp;
if (compListener == null)
compListener = new CompListener();
component.addComponentListener(compListener);
return true;
|
public javax.media.Format | setInputFormat(javax.media.Format format)Set the data input format.
if (matches(format, supportedFormats) != null) {
inputFormat = (VideoFormat) format;
Dimension size = inputFormat.getSize();
if (size != null) {
inWidth = size.width;
inHeight = size.height;
}
return format;
} else
return null;
|
public void | start()
started = true;
|
public void | stop()
started = false;
|