// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:41
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   DataSource.java

package project;

import java.io.IOException;
import java.io.PrintStream;
import javax.media.Duration;
import javax.media.Time;
import javax.media.protocol.PushBufferDataSource;
import javax.media.protocol.PushBufferStream;

// Referenced classes of package project:
//            LiveStream

public class DataSource extends PushBufferDataSource
{

    public DataSource()
    {
        controls = new Object[0];
        started = false;
        contentType = "raw";
        connected = false;
        duration = Duration.DURATION_UNKNOWN;
        streams = null;
        stream = null;
    }

    public String getContentType()
    {
        if(!connected)
        {
            System.err.println("Error: DataSource not connected");
            return null;
        } else
        {
            return contentType;
        }
    }

    public void connect()
        throws IOException
    {
        if(connected)
        {
            return;
        } else
        {
            connected = true;
            return;
        }
    }

    public void disconnect()
    {
        try
        {
            if(started)
                stop();
        }
        catch(IOException e) { }
        connected = false;
    }

    public void start()
        throws IOException
    {
        if(!connected)
            throw new Error("DataSource must be connected before it can be started");
        if(started)
        {
            return;
        } else
        {
            started = true;
            stream.start(true);
            return;
        }
    }

    public void stop()
        throws IOException
    {
        if(!connected || !started)
        {
            return;
        } else
        {
            started = false;
            stream.start(false);
            return;
        }
    }

    public Object[] getControls()
    {
        return controls;
    }

    public Object getControl(String controlType)
    {
        Class cls;
        Object cs[];
        int i;
        cls = Class.forName(controlType);
        cs = getControls();
        i = 0;
_L1:
        if(i >= cs.length)
            break MISSING_BLOCK_LABEL_42;
        if(cls.isInstance(cs[i]))
            return cs[i];
        i++;
          goto _L1
        return null;
        Exception e;
        e;
        return null;
    }

    public Time getDuration()
    {
        return duration;
    }

    public PushBufferStream[] getStreams()
    {
        if(streams == null)
        {
            streams = new LiveStream[1];
            stream = streams[0] = new LiveStream();
        }
        return streams;
    }

    protected Object controls[];
    protected boolean started;
    protected String contentType;
    protected boolean connected;
    protected Time duration;
    protected LiveStream streams[];
    protected LiveStream stream;
}