FileDocCategorySizeDatePackage
BasicInputConnector.javaAPI DocJMF 2.1.1e2961Mon May 12 12:20:48 BST 2003com.sun.media

BasicInputConnector

public class BasicInputConnector extends BasicConnector implements InputConnector
implementation of the inputConnector interface

Fields Summary
protected OutputConnector
outputConnector
the connected outputConnector
private boolean
reset
Constructors Summary
Methods Summary
public com.sun.media.OutputConnectorgetOutputConnector()
Return the OutputConnector this InputConnector is connected to. If this Connector is unconnected return null.


                         
       
        return outputConnector;
    
public javax.media.BuffergetValidBuffer()
Get buffer object containing media.

//       System.out.println(getClass().getName()+":: getValidBuffer");

        switch (protocol) {
            case ProtocolPush:
		synchronized (circularBuffer) {
		    if ( !isValidBufferAvailable() && reset)
			return null;
		    reset = false;
		    return (Buffer)circularBuffer.read();
		}
            case ProtocolSafe:
                synchronized (circularBuffer ) {
		    reset = false;
                    while ( !reset && !isValidBufferAvailable() ) {
                       try {
                         circularBuffer.wait();
                       } catch (Exception e) {}
		    }
		    if (reset)
			return null;
                    Buffer buffer = (Buffer)circularBuffer.read();
                    circularBuffer.notifyAll();
                    return buffer;
		}
            default:
                  throw new RuntimeException();
        }

    
public booleanisValidBufferAvailable()
returns if there are valid Buffer objects in the Connector's queue.

        return circularBuffer.canRead();
    
public voidreadReport()
Indicates the oldest Buffer object got from this Connector was used and can be "recycled" by the upstream Module.

  //     System.out.println(getClass().getName()+":: readReport");

        switch ( protocol ) {
            case ProtocolPush:
            case ProtocolSafe:
                synchronized (circularBuffer ) {
		   if (reset) return;
                   circularBuffer.readReport();
                   circularBuffer.notifyAll();
                   return;
                }
            default:
                  throw new RuntimeException();
        }
    
public voidreset()

        synchronized (circularBuffer) {
            reset = true;
            super.reset();
            circularBuffer.notifyAll();
        }
    
public voidsetOutputConnector(com.sun.media.OutputConnector outputConnector)
Sets the OutputConnector this InputConnector is connected to. This method is called by the connectTo() method of the OutputConnector.

        this.outputConnector=outputConnector;