net.sf.fmj.media.MergingPushBufferDataSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fmj Show documentation
Show all versions of fmj Show documentation
Freedom for Media in Java
The newest version!
package net.sf.fmj.media;
import java.io.*;
import java.util.*;
import javax.media.*;
import javax.media.protocol.*;
/**
* Merges multiple {@link PushBufferDataSource}.
*
* @author Ken Larson
*
*/
public class MergingPushBufferDataSource extends PushBufferDataSource
{
protected final List sources;
public MergingPushBufferDataSource(List sources)
{
super();
this.sources = sources;
}
@Override
public void connect() throws IOException
{
for (PushBufferDataSource source : sources)
source.connect();
}
@Override
public void disconnect()
{
for (PushBufferDataSource source : sources)
source.disconnect();
}
@Override
public String getContentType()
{
// if all content types the same, use it, otherwise,
// ContentDescriptor.MIXED.
for (int i = 0; i < sources.size(); ++i)
{
if (!sources.get(i).getContentType()
.equals(sources.get(0).getContentType()))
return ContentDescriptor.MIXED;
}
return sources.get(0).getContentType();
}
@Override
public Object getControl(String controlType)
{
for (PushBufferDataSource source : sources)
{
Object control = source.getControl(controlType);
if (control != null)
return control;
}
return null;
}
@Override
public Object[] getControls()
{
final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy