Methods Summary |
---|
public void | close()close the stream which PullSourceStream handles
try {
stream.close();
stream = null;
} catch (Exception e) {
System.out.println("BasicPullSourceStream close - IOException");
}
|
public boolean | endOfStream()Find out if the end of the stream has been reached.
return eofReached;
|
public javax.media.protocol.ContentDescriptor | getContentDescriptor()Get the current content type for this stream.
return null;
|
public long | getContentLength()
return contentLength;
|
public java.lang.Object | getControl(java.lang.String controlType)Obtain the object that implements the specified Class or Interface The
full class or interface name must be used. If the control is not
supported then null is returned.
return null;
|
public java.lang.Object[] | getControls()Obtain the collection of objects that control the object that implements
this interface. If no controls are supported, a zero length array
is returned.
Object[] objects = new Object[0];
return objects;
|
public boolean | isRandomAccess()Find out if this source can position anywhere in the stream.
If the stream is not random access, it can only be repositioned to the beginning.
return true;
|
public int | read(byte[] buffer, int offset, int length)read will perform a blocking read from stream. If
buffer is null up to length bytes are read and discarded.
int bytesRead;
int len = length;
int off = offset;
do {
bytesRead = stream.read(buffer, off, len);
if (bytesRead == -1) {
eofReached = true;
int totalBytesRead = length - len;
return (totalBytesRead > 0) ? totalBytesRead : -1;
} else {
location += bytesRead;
len -= bytesRead;
off += bytesRead;
}
} while (len != 0);
return length;
|
void | reopenStream()
// reopen the stream and go to new location
// System.out.println("$$$ bpss: seek back");
try {
if (stream!=null) {
stream.close();
}
// System.out.println("bpss: seek: needConnectPermission " +
// needConnectPermission);
if (needConnectPermission) {
if ( /*securityPrivelege && */ (jmfSecurity != null) ) {
try {
if (jmfSecurity.getName().startsWith("jmf-security")) {
jmfSecurity.requestPermission(m, cl, args, JMFSecurity.CONNECT);
m[0].invoke(cl[0], args[0]);
} else if (jmfSecurity.getName().startsWith("internet")) {
PolicyEngine.checkPermission(PermissionID.NETIO);
PolicyEngine.assertPermission(PermissionID.NETIO);
}
} catch (Throwable e) {
if (JMFSecurityManager.DEBUG) {
System.err.println("Unable to get connect " +
" privilege " + e);
}
securityPrivelege = false;
throw new IOException(JMFI18N.getResource("error.connectionerror") +
e.getMessage());
}
}
}
urlC = url.openConnection(); // This will not throw Security Exceptions
try {
if ( (jmfSecurity != null) && (jmfSecurity.getName().startsWith("jdk12"))) {
Constructor cons = jdk12ConnectionAction.cons;
stream = (InputStream) jdk12.doPrivM.invoke(
jdk12.ac,
new Object[] {
cons.newInstance( new Object[] {urlC} )
}
);
} else {
// stream=url.openStream();
stream = urlC.getInputStream();
}
} catch (Exception e) {
System.err.println("Unable to re-open a URL connection " + e);
throw new IOException(JMFI18N.getResource("error.connectionerror") +
e.getMessage());
}
} catch (IOException ex) {
}
|
public long | seek(long where)Seek to the specified point in the stream.
long oldLocation = location;
location = where;
try {
if (where < oldLocation) {
reopenStream();
eofReached = false;
return skip(stream, where);
} else {
return skip(stream, (where - oldLocation));
}
} catch (IOException e) {
// System.err.println("Exception in PullSourceStream::seek(long) " +
// e.toString());
//System.exit(0);
return 0; // dummy
}
|
private long | skip(java.io.InputStream istream, long amount)
long remaining = amount;
while (remaining > 0) {
long actual = istream.skip(remaining);
remaining -= actual;
}
return amount;
|
public long | tell()Obtain the current point in the stream.
return location;
|
public boolean | willReadBlock()willReadBlock indicates whether there data available now.
try {
return (stream.available() == 0);
} catch (IOException e) {
System.err.println("Exception PullSourceStream::willReadBlock " +
e.toString());
return true;
}
|