Methods Summary |
---|
private void | addToCache(byte[] buffer, int offset, int size)Cache Stuff
if (cacheBuffer == 0) {
cacheBuffer = nCreateCache(384 * 1024);
cacheAllocated = 384 * 1024;
}
if ((cacheTotalSize + size) > cacheAllocated)
return;
nAddToCache(cacheBuffer, cacheTotalSize, buffer, offset, size);
cacheTotalSize += size;
|
native void | amPause()
|
native void | amRun()
|
native void | amStop()
|
native void | amStopWhenReady()
|
public int | canRead(int nBytes)
return controller.canRead(nBytes);
|
public long | canSeek(long seekTo)
return controller.canSeek(seekTo);
|
void | dispose()End Cache Stuff
if (spinner != null) {
spinner.stop();
spinner = null;
}
dispose0(); // native call
if (cacheBuffer != 0) {
nFreeCache(cacheBuffer);
cacheBuffer = 0;
}
|
native void | dispose0()
|
native void | doNRequest(byte[] array)
|
void | doneRealize()
controllerRealized = true;
|
protected void | finalize()
dispose();
|
static native int | findWindow(java.lang.String name)
|
native int | getBitRate()
|
native double | getCurrentPosition()
|
native double | getDuration()
|
native double | getFrameRate()
|
private void | getFromCache(int location, byte[] buffer, int offset, int size)
nGetFromCache(cacheBuffer, location, buffer, offset, size);
|
native double | getRate()
|
native int | getStreamType(byte[] array, int size)
|
native long | getTime()
|
native int | getVideoHeight()
|
native int | getVideoWidth()
|
native int | getVolume()
|
boolean | hasAudio()
return (streamType & 1) == 1;
|
boolean | hasVideo()
return (streamType & 2) == 2;
|
private void | initiateSpin()
spinner = new Thread( this );
spinner.start();
|
boolean | isRealized()
return realized;
|
public void | kill()
deallocated = true;
unPause();
stopDataFlow(true);
amStop();
|
private native void | nAddToCache(int cacheBuffer, int cacheOffset, byte[] buffer, int bufOffset, int size)
|
private native int | nCreateCache(int cacheSize)
|
private native void | nFreeCache(int cacheBuffer)
|
private native void | nGetFromCache(int cacheBuffer, int cacheOffset, byte[] buffer, int bufOffset, int size)
|
native boolean | openFile(java.lang.String file)
|
native boolean | openStream(boolean seekable, boolean randomAccess, int streamType, long contentLength)
|
public synchronized void | pause()
// System.err.println("In ActiveMovie.pause()");
if (paused) return;
donePaused = false;
paused = true;
// Block for the donePaused to clear. This is
// done so that the last read could be completed before
// it returns.
if (!donePaused) {
try {
wait(250);
donePaused = true;
} catch (InterruptedException e) {}
}
|
public int | read(byte[] array, int offset, int length)
int totalRead = 0;
if (deallocated)
return -1;
if (cacheTotalSize > 0 && !randomAccess) {
if (readLocation < cacheTotalSize && streamLocation == cacheTotalSize) {
totalRead = (int) (cacheTotalSize - readLocation);
if (totalRead > length)
totalRead = length;
getFromCache((int) readLocation,
array, offset, totalRead);
readLocation += totalRead;
if (totalRead == length) {
return totalRead;
} else {
length -= totalRead;
offset += totalRead;
}
}
}
int actualRead = 0;
int remaining = length;
while (totalRead < length) {
if (canRead(remaining) > 0)
actualRead = controller.read(array, offset, remaining);
else
actualRead = -1;
if (actualRead == -1) {
// EOS
// cacheTotalSize = 0;
if (totalRead > 0)
return totalRead;
else
return -1;
} else if (actualRead == -2) {
return -2;
} else if (actualRead > 0) {
remaining -= actualRead;
totalRead += actualRead;
// Cache the data if the controller is not realized yet.
if (!controllerRealized && !randomAccess) {
if (streamLocation == cacheTotalSize) {
addToCache(array, offset, actualRead);
}
}
offset += actualRead;
streamLocation += actualRead;
readLocation = streamLocation;
if (streamLocation > cacheTotalSize &&
controllerRealized)
cacheTotalSize = 0;
}
}
if (actualRead > 0)
return totalRead;
else
return actualRead;
|
public void | restart()
// Restart the paused thread.
// System.err.println("In ActiveMovie.restart()");
deallocated = false;
stopDataFlow(false);
unPause();
|
public void | run()
// We need to block the thread if ActiveMovie is paused.
while (true) {
synchronized (this) {
while (paused) {
if (!donePaused) {
donePaused = true;
notifyAll();
}
try {
wait();
} catch (InterruptedException e) {}
}
}
doNRequest(jbuffer);
try {
spinner.sleep(50);
} catch (Exception e) {
System.err.println("Exception in run()" + e);
}
}
|
public long | seek(long seekTo)
if (deallocated)
return 0;
if (seekTo < cacheTotalSize && !randomAccess) {
readLocation = seekTo;
return seekTo;
} else if (seekable && (randomAccess || (seekTo == 0))) {
long seeked = controller.seek(seekTo);
streamLocation = seekTo;
return seeked;
} else {
// Couldn't seek
return -1;
}
|
native void | setCurrentPosition(double pos)
|
native void | setNSeekable(boolean seekable)
|
native void | setOwner(int owner)
|
native void | setRate(double rate)
|
public void | setSeekable(boolean seekable)
if (seekable) {
this.randomAccess = seekable;
this.seekable = seekable;
}
setNSeekable(seekable);
|
native void | setStopTime(double time)
|
native void | setVisible(int visible)
|
native void | setVolume(int volume)
|
native void | setWindowPosition(int left, int top, int right, int bottom)
|
void | stopDataFlow(boolean stop)
if (filterPin != 0)
stopDataFlow(filterPin, stop);
|
native void | stopDataFlow(int filterPin, boolean stop)
|
private void | unPause()
if (!paused) return;
synchronized (this) {
donePaused = true;
paused = false;
notifyAll();
}
|
native boolean | waitForCompletion()
|