FileDocCategorySizeDatePackage
BasicOutputConnector.javaAPI DocJMF 2.1.1e3753Mon May 12 12:20:48 BST 2003com.sun.media

BasicOutputConnector

public class BasicOutputConnector extends BasicConnector implements OutputConnector
implementation of the OutputConnector interface

Fields Summary
protected InputConnector
inputConnector
the connected input connector
private boolean
reset
Constructors Summary
Methods Summary
public javax.media.FormatcanConnectTo(com.sun.media.InputConnector inputConnector, javax.media.Format useThisFormat)
check if a connection to the specified InputConnector would succeed.

        if ( getProtocol() != inputConnector.getProtocol() )
           throw new RuntimeException("protocols do not match:: ");
        return null;
    
public javax.media.FormatconnectTo(com.sun.media.InputConnector inputConnector, javax.media.Format useThisFormat)
Connects an InputConnector to this OutputConnector.



               
          


        Format format=canConnectTo(inputConnector,useThisFormat);
//        if (format==null)
//           return null;

        this.inputConnector=inputConnector;
        inputConnector.setOutputConnector(this);
        int bufferSize=Math.max(getSize(),inputConnector.getSize());

        circularBuffer = new CircularBuffer(bufferSize);
        inputConnector.setCircularBuffer(circularBuffer);
        return null;
    
public javax.media.BuffergetEmptyBuffer()
Get an empty buffer object.

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

        switch ( protocol ) {
            case ProtocolPush:
                if (!isEmptyBufferAvailable () && reset)
		    return null;
		reset = false;
                return circularBuffer.getEmptyBuffer();
            case ProtocolSafe:
		synchronized (circularBuffer) {
		    reset = false;
		    while (!reset && !isEmptyBufferAvailable()) {
                       try {
                         circularBuffer.wait();
                       } catch (Exception e) {}
		    }
		    if (reset)
			return null;
                    Buffer buffer = circularBuffer.getEmptyBuffer();
                    circularBuffer.notifyAll();
                    return buffer;
		}

            default:
                  throw new RuntimeException();
        }
    
public com.sun.media.InputConnectorgetInputConnector()
Return the InputConnectore this OutputConnector is connected to. If this Connector is unconnected return null.

        return inputConnector;
    
public booleanisEmptyBufferAvailable()
checks if there are empty Buffer objects in the Connector's queue.

        return circularBuffer.canWrite();
    
public voidreset()

        synchronized (circularBuffer) {
            reset = true;
            super.reset();
	    if (inputConnector != null)
		inputConnector.reset();
            circularBuffer.notifyAll();
        }
    
public voidwriteReport()
put media chunk in the queue

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

        switch ( protocol ) {
            case ProtocolPush:
		synchronized (circularBuffer) {
		    if (reset /* && pendingWriteReport */)
			return;
		    circularBuffer.writeReport();
		}
		getInputConnector().getModule().connectorPushed( getInputConnector() );
                 return;
            case ProtocolSafe:
                synchronized (circularBuffer ) {
		   if (reset)
			return;
                   circularBuffer.writeReport();
                   circularBuffer.notifyAll();
                   return;
                }
            default:
                  throw new RuntimeException();
        }