All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.fmj.media.protocol.CloneablePushBufferDataSource Maven / Gradle / Ivy

There is a newer version: 1.0.2-jitsi
Show newest version
package net.sf.fmj.media.protocol;

import java.io.*;

import javax.media.*;
import javax.media.protocol.*;

/**
 * This is a utility class for creating clones of PushBufferDataSource. THe
 * class reflects the functionality of a PushBufferDataSource and provides a
 * getClone() method for generating clones. The generated clone will be of type
 * PushBufferDataSource and its streams will generate a trasferData() call each
 * time the PushBufferDataSource's streams call transferData().
 */
public class CloneablePushBufferDataSource extends PushBufferDataSource
        implements SourceCloneable
{
    private SuperCloneableDataSource superClass;

    /**
     * Constructor
     *
     * @param source
     *            the source to be cloned
     */
    public CloneablePushBufferDataSource(PushBufferDataSource source)
    {
        superClass = new SuperCloneableDataSource(source);
    }

    /**
     * Open a connection to the source described by the MediaLocator.
     * 

* * The connect method initiates communication with the source. * * @exception IOException * Thrown if there are IO problems when connect is * called. */ @Override public void connect() throws IOException { superClass.connect(); } /** * Clone the original datasource, returning an object of the type * PushDataSource or PushBufferDataSource. If the original * data source was a PullDataSource, then this will be a PushDataSource * which pushes at the same rate at which the CloneableDataSource is being * pulled. * * @return a slave DataSource for this DataSource. */ public DataSource createClone() { return superClass.createClone(); } /** * Close the connection to the source described by the locator. *

* The disconnect method frees resources used to maintain a * connection to the source. If no resources are in use, disconnect * is ignored. If stop hasn't already been called, calling * disconnect implies a stop. * */ @Override public void disconnect() { superClass.disconnect(); } /** * Get a string that describes the content-type of the media that the source * is providing. *

* It is an error to call getContentType if the source is not * connected. * * @return The name that describes the media content. */ @Override public String getContentType() { return superClass.getContentType(); } /** * 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 the object that implements the control, or null. */ @Override public Object getControl(String controlType) { return superClass.getControl(controlType); } /** * 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 the collection of object controls */ @Override public Object[] getControls() { return superClass.getControls(); } /** * Get the duration of the media represented by this object. The value * returned is the media's duration when played at the default rate. If the * duration can't be determined (for example, the media object is presenting * live video) getDuration returns DURATION_UNKNOWN. * * @return A Time object representing the duration or * DURATION_UNKNOWN. */ @Override public Time getDuration() { return superClass.getDuration(); } /** * Get the collection of streams that this source manages. The collection of * streams is entirely content dependent. The ContentDescriptor of * this DataSource provides the only indication of what streams can * be available on this connection. * * @return The collection of streams for this source. */ @Override public PushBufferStream[] getStreams() { if (superClass.streams == null) { superClass.streams = new PushBufferStream[superClass.streamsAdapters.length]; for (int i = 0; i < superClass.streamsAdapters.length; i++) superClass.streams[i] = superClass.streamsAdapters[i] .getAdapter(); } return (PushBufferStream[]) superClass.streams; } /** * Initiate data-transfer. The start method must be called before * data is available. (You must call connect before calling * start.) * * @exception IOException * Thrown if there are IO problems with the source when * start is called. */ @Override public void start() throws IOException { superClass.start(); } /** * Stop the data-transfer. If the source has not been connected and started, * stop does nothing. */ @Override public void stop() throws IOException { superClass.stop(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy