FileDocCategorySizeDatePackage
CloneableSourceStreamAdapter.javaAPI DocJMF 2.1.1e11717Mon May 12 12:21:04 BST 2003com.ibm.media.protocol

CloneableSourceStreamAdapter

public class CloneableSourceStreamAdapter extends Object

Fields Summary
SourceStream
master
SourceStream
adapter
Vector
slaves
private static JMFSecurity
jmfSecurity
private static boolean
securityPrivelege
private Method[]
m
private Class[]
cl
private Object[]
args
protected int
numTracks
protected Format[]
trackFormats
Constructors Summary
CloneableSourceStreamAdapter(SourceStream master)
Constructor



     
	try {
	    jmfSecurity = JMFSecurityManager.getJMFSecurity();
	    securityPrivelege = true;
	} catch (SecurityException e) {
	}
    
    
	this.master = master;

	// create the matching adapter according to the stream's type
	if (master instanceof PullSourceStream)
	    adapter = new PullSourceStreamAdapter();
	if (master instanceof PullBufferStream)
	    adapter = new PullBufferStreamAdapter();
	if (master instanceof PushSourceStream)
	    adapter = new PushSourceStreamAdapter();
	if (master instanceof PushBufferStream)
	    adapter = new PushBufferStreamAdapter();
    
Methods Summary
voidcopyAndRead(javax.media.Buffer b)


	if (master instanceof PullBufferStream) 
	    ((PullBufferStream)master).read(b);
    
	if (master instanceof PushBufferStream) 
	    ((PushBufferStream)master).read(b);
    
	for (Enumeration e = slaves.elements(); e.hasMoreElements();) {
	    Object stream = e.nextElement(); 
	    ((PushBufferStreamSlave)stream).setBuffer((Buffer)b.clone());
	    Thread.yield();
	}
    
intcopyAndRead(byte[] buffer, int offset, int length)


	int totalRead = 0;
	if (master instanceof PullSourceStream)
	    totalRead = ((PullSourceStream)master).read(buffer, offset, length);
	if (master instanceof PushSourceStream)
	    totalRead = ((PushSourceStream)master).read(buffer, offset, length);
 
	for (Enumeration e = slaves.elements(); e.hasMoreElements();) {
	    Object stream = e.nextElement(); 
	    byte[] copyBuffer = new byte[totalRead];
	    System.arraycopy(buffer, offset, copyBuffer, 0, totalRead);
	    ((PushSourceStreamSlave)stream).setBuffer(copyBuffer);
	}
    
	return totalRead;
    
javax.media.protocol.SourceStreamcreateSlave()
This method should be could only by the CloneableDataSource.

return
a slave SourceStream which will either a PushSourceStream or a PushBufferStream.


	SourceStream slave = null;

	if ((master instanceof PullSourceStream) ||
	    (master instanceof PushSourceStream))
	    slave = new PushSourceStreamSlave();
	if ((master instanceof PullBufferStream) || 
	    (master instanceof PushBufferStream))
	    slave = new PushBufferStreamSlave();
	slaves.addElement(slave);
    
	return slave;
    
javax.media.protocol.SourceStreamgetAdapter()
Return the stream adapter to be used by the Handler. There is only one adapter per stream since there is only one master stream.

    
	return adapter;