FileDocCategorySizeDatePackage
RawPullStreamParser.javaAPI DocJMF 2.1.1e4145Mon May 12 12:20:52 BST 2003com.sun.media.parser

RawPullStreamParser

public class RawPullStreamParser extends RawParser

Fields Summary
protected SourceStream[]
streams
protected Track[]
tracks
static final String
NAME
Constructors Summary
public RawPullStreamParser()

    
Methods Summary
public voidclose()
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.

	if (source != null) {
	    try {
		source.stop();
		source.disconnect();
	    } catch (IOException e) {
		// Internal error?
	    }
	    source = null;
	}
    
public java.lang.StringgetName()


       
	return NAME;
    
public javax.media.Track[]getTracks()

	return tracks;
    
public voidopen()
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.

	if (tracks != null)
	    return;
	tracks = new Track[streams.length];
	for (int i = 0; i < streams.length; i++) {
	    tracks[i] = new FrameTrack(this, (PullSourceStream)streams[i]);
	}
    
public voidsetSource(javax.media.protocol.DataSource source)


	if (!(source instanceof PullDataSource)) {
	    throw new IncompatibleSourceException("DataSource not supported: " + source);
	} else {
	    streams = ((PullDataSource) source).getStreams();
	}


	if ( streams == null) {
	    throw new IOException("Got a null stream from the DataSource");
	}

	if (streams.length == 0) {
	    throw new IOException("Got a empty stream array from the DataSource");
	}

	if (!supports(streams))
	    throw new IncompatibleSourceException("DataSource not supported: " + source);

	this.source = source;
	this.streams = streams;
	
	// System.out.println("content length is " + streams[0].getContentLength());
    
public voidstart()
Start the parser.

	source.start();
    
public voidstop()
Stop the parser.

	try {
	    source.stop();
	} catch (IOException e) {
	    // Internal errors?
	}
    
protected booleansupports(javax.media.protocol.SourceStream[] streams)
Override this if the Parser has additional requirements from the PullSourceStream

	return ( (streams[0] != null) &&
		 (streams[0] instanceof PullSourceStream) );