FileDocCategorySizeDatePackage
Handler.javaAPI DocFobs4JMF API 0.4.18219Wed Jan 10 11:09:32 GMT 2007com.omnividea.media.content.unknown

Handler

public class Handler extends Object implements Processor
ChangeLog: 2005-02-01: Masato Alemayehu Global changes. Now it compiles ;) 2005-01-31: Masato Alemayehu Original code submission.

Fields Summary
protected int
currentState
protected int
previousState
protected int
targetState
protected TimeBase
timebase
protected Time
startTime
protected Component
controllerCanvas
protected DataSource
dataSource
protected ArrayList
controllerListeners
protected GainControl
gainControl
protected float
desiredRate
protected Demultiplexer
parser
protected Component
visualComponent
protected VideoRenderer
renderer
protected Codec
decoder
protected Track[]
tracks
protected Track
videoTrack
Constructors Summary
public Handler()

    
     
    	controllerListeners = new ArrayList();
    
Methods Summary
public voidaddController(javax.media.Controller controller)

    
public voidaddControllerListener(javax.media.ControllerListener controllerListener)

    	controllerListeners.add(controllerListener);
    
public voidclose()

    
public voidconfigure()

    try{
	tracks = parser.getTracks();
	for(int i=0;i<tracks.length; i++)
		if(tracks[i].getFormat() instanceof VideoFormat)
			videoTrack = tracks[i];
	} catch(Exception e){}
    
public voiddeallocate()

    
public javax.media.protocol.ContentDescriptorgetContentDescriptor()

    	return null;
    
public javax.media.ControlgetControl(java.lang.String str)

    	return null;
    
public java.awt.ComponentgetControlPanelComponent()

    	return null;
    
public javax.media.Control[]getControls()

    	return null;
    
public javax.media.protocol.DataSourcegetDataOutput()

    	return null;
    
public javax.media.TimegetDuration()

    	return null;
    
public javax.media.GainControlgetGainControl()

    	return null;
    
public longgetMediaNanoseconds()

    	return 0;
    
public javax.media.TimegetMediaTime()

    	return null;
    
public floatgetRate()

    	return 0f;
    
public javax.media.TimegetStartLatency()

    	return null;
    
public intgetState()

	    return currentState;
    
public javax.media.TimegetStopTime()

    	return null;
    
public javax.media.protocol.ContentDescriptor[]getSupportedContentDescriptors()

	    return new ContentDescriptor[0];
    
public javax.media.TimegetSyncTime()

    	return null;
    
public intgetTargetState()

    	return targetState;
    
public javax.media.TimeBasegetTimeBase()

	    return timebase;
    
public javax.media.control.TrackControl[]getTrackControls()

    	return null;
    
public java.awt.ComponentgetVisualComponent()

    	return visualComponent;
    
public static voidmain(java.lang.String[] args)

	String url = args[0];
        MediaLocator ml = new MediaLocator(url);
        com.omnividea.media.protocol.file.DataSource ds = new com.omnividea.media.protocol.file.DataSource(null);
	ds.setLocator(ml);
	System.out.println(ds.getUrlName());
	Demultiplexer parser = new com.omnividea.media.parser.video.Parser();
	parser.setSource(ds);
	Track[] tracks = parser.getTracks();
	Track video = null;
	for(int i=0;i<tracks.length; i++)
		if(tracks[i].getFormat() instanceof VideoFormat)
			video = tracks[i];
	Codec decoder = new com.omnividea.media.codec.video.NativeDecoder();
	decoder.setInputFormat(video.getFormat());
	decoder.open();
	VideoRenderer renderer = new com.sun.media.renderer.video.LightWeightRenderer();
	renderer.open();
	Format outputFormat = decoder.setOutputFormat(renderer.getSupportedInputFormats()[0]);
	if(outputFormat==null)
		outputFormat=new RGBFormat(new Dimension(720, 576),
				Format.NOT_SPECIFIED,
				int[].class,
				Format.NOT_SPECIFIED,
				24,
				3, 2, 1,
				3, Format.NOT_SPECIFIED,
				Format.TRUE,
				Format.NOT_SPECIFIED);
	renderer.open();
	renderer.setInputFormat(outputFormat);
	JFrame f = new JFrame();
	f.add(renderer.getComponent());
	f.pack();
	f.setVisible(true);
	
	Buffer in = new Buffer();
	Buffer out = new Buffer();
	while(true){
		video.readFrame(in);
		Thread.sleep(30);
		decoder.process(in, out);
		//renderer.process(out);
	}
    
public javax.media.TimemapToTimeBase(javax.media.Time time)

    	return time;
    
public voidprefetch()

    	realize();
    
public voidrealize()

    try{
	decoder = new com.omnividea.media.codec.video.NativeDecoder();
	decoder.setInputFormat(videoTrack.getFormat());
	decoder.open();
	renderer = new com.sun.media.renderer.video.LightWeightRenderer();
	renderer.open();
	Format outputFormat = decoder.setOutputFormat(renderer.getSupportedInputFormats()[0]);
	if(outputFormat==null)
		outputFormat=new RGBFormat(new Dimension(720, 576),
				Format.NOT_SPECIFIED,
				int[].class,
				Format.NOT_SPECIFIED,
				24,
				3, 2, 1,
				3, Format.NOT_SPECIFIED,
				Format.TRUE,
				Format.NOT_SPECIFIED);
	renderer.open();
	renderer.setInputFormat(outputFormat);
	visualComponent = renderer.getComponent();
	} catch(Exception e){}
    
public voidremoveController(javax.media.Controller controller)

    
public voidremoveControllerListener(javax.media.ControllerListener controllerListener)

    	controllerListeners.remove(controllerListener);
    
public javax.media.protocol.ContentDescriptorsetContentDescriptor(javax.media.protocol.ContentDescriptor contentDescriptor)

	    return null;
    
public voidsetMediaTime(javax.media.Time time)

    
public floatsetRate(float rate)

    	return desiredRate = rate;
    
public voidsetSource(javax.media.protocol.DataSource dataSource)

    	this.dataSource = dataSource;
	parser = new com.omnividea.media.parser.video.Parser();
	parser.setSource(dataSource);
    
public voidsetStopTime(javax.media.Time time)

    
public voidsetTimeBase(javax.media.TimeBase timeBase)

	    throw new IncompatibleTimeBaseException();
    
public voidstart()

    	syncStart(Manager.getSystemTimeBase().getTime());
    
public voidstop()

    
public voidsyncStart(javax.media.Time time)

     	startTime = time;
	//videoTrack.setStartTime(time);
	Buffer in = new Buffer();
 	Buffer out = new Buffer();
	while(true){
		try{
		videoTrack.readFrame(in);
		Thread.sleep(30);
		decoder.process(in, out);
		renderer.process(out);
		}catch(InterruptedException ie){}
	}
    
public java.lang.StringtoString()


        String retValue;
        
        retValue = "Media Player";
        return retValue;