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

RawBufferParser

public class RawBufferParser extends RawStreamParser
Parser for a raw stream of buffers from a PushBufferDataSource.

Fields Summary
static final String
NAMEBUFFER
private boolean
started
static AudioFormat
mpegAudio
static VideoFormat
mpegVideo
static VideoFormat
jpegVideo
static VideoFormat
h261Video
static VideoFormat
h263Video
static VideoFormat
h263_1998Video
final int[]
h261Widths
Track class
final int[]
h261Heights
final int[]
h263Widths
final int[]
h263Heights
final float[]
MPEGRateTbl
public static int[]
MPASampleTbl
Constructors Summary
Methods Summary
public voidclose()

	if (source != null) {
	    try {
		source.stop();
		// stop every tracks, so that readFrame() can be released.
		// close every tracks to unblock the transfer handlers.
		for (int i = 0; i < tracks.length; i++) {
		    ((FrameTrack)tracks[i]).stop();
		    ((FrameTrack)tracks[i]).close();
		}
		
		source.disconnect();
	    } catch (Exception e) {
		// Internal error?
	    }
	    source = null;
	}
	started = false;
    
public java.lang.StringgetName()


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

	for (int i = 0; i < tracks.length; i++)
	    ((FrameTrack)tracks[i]).parse();
	return tracks;
    
booleanisRTPFormat(javax.media.Format fmt)

	return  fmt != null &&
		fmt.getEncoding() != null &&
		(fmt.getEncoding().endsWith("rtp") ||
		 fmt.getEncoding().endsWith("RTP"));
    
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, (PushBufferStream)streams[i], 1);
	}
    
public voidreset()
Resets the state of the plug-in. Typically at end of media or when media is repositioned.

	for (int i = 0; i < tracks.length; i++)
	    ((FrameTrack)tracks[i]).reset();
    
public voidsetSource(javax.media.protocol.DataSource source)


	if (!(source instanceof PushBufferDataSource)) {
	    throw new IncompatibleSourceException("DataSource not supported: " + source);
	} else {
	    streams = ((PushBufferDataSource) 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;
    
public voidstart()
Start the parser.

	for (int i = 0; i < tracks.length; i++)
	    ((FrameTrack)tracks[i]).start();
	source.start();
	started = true;
    
public voidstop()
Stop the parser.

	try {
	    source.stop();
	    // stop each of the tracks, so that readFrame can be released
	    for (int i = 0; i < tracks.length; i++)
		((FrameTrack)tracks[i]).stop();
	    
	} catch (Exception e) {
	    // Internal errors?
	}
	started = false;
    
protected booleansupports(javax.media.protocol.SourceStream[] streams)
Override this if the Parser has additional requirements from the PushSourceStream

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