signature:
public class ContainerFormat { /** * Returns a list of all codecs supported for this Object .
 * If this object hasn ' t been set up for output , then
 * we return null .
 * @ return A list of supported codecs , in decreasing preferred order . */
public java . util . Collection < Codec . ID > getSupportedCodecs ( ) { } }

implementation:
final java . util . List < Codec . ID > retval = new java . util . LinkedList < Codec . ID > ( ) ; final java . util . Set < Codec . ID > uniqueSet = new java . util . HashSet < Codec . ID > ( ) ; int numCodecs = getNumSupportedCodecs ( ) ; for ( int i = 0 ; i < numCodecs ; i ++ ) { Codec . ID id = getSupportedCodecId ( i ) ; // remove duplicate IDs
if ( id != Codec . ID . CODEC_ID_NONE && ! uniqueSet . contains ( id ) ) retval . add ( id ) ; uniqueSet . add ( id ) ; } return retval ;


signature:
public class ContainerFormat { /** * Returns a list of all codec tags supported for this container .
 * If this object hasn ' t been set up for output , then
 * we return null .
 * @ return A list of supported codec tags , in decreasing preferred order . */
public java . util . Collection < Long > getSupportedTags ( ) { } }

implementation:
final java . util . List < Long > retval = new java . util . LinkedList < Long > ( ) ; final java . util . Set < Long > uniqueSet = new java . util . HashSet < Long > ( ) ; int numCodecs = getNumSupportedCodecs ( ) ; for ( int i = 0 ; i < numCodecs ; i ++ ) { long tag = getSupportedCodecTag ( i ) ; Codec . ID id = getSupportedCodecId ( i ) ; // remove duplicate tags
if ( id != Codec . ID . CODEC_ID_NONE && ! uniqueSet . contains ( tag ) ) retval . add ( tag ) ; uniqueSet . add ( tag ) ; } return retval ;


signature:
public class ContainerFormat { /** * Get the Codec . ID for the n ' th codec supported by this container . < br >
 * < br >
 * @ param n The n ' th codec supported by this codec . Lower n are higher priority . < br >
 * n must be & lt ; # getNumSupportedCodecs ( ) < br >
 * @ return the Codec . ID at the n ' th slot , or Codec . ID . CODEC _ ID _ NONE if none . */
protected Codec . ID getSupportedCodecId ( int n ) { } }

implementation: return Codec . ID . swigToEnum ( VideoJNI . ContainerFormat_getSupportedCodecId ( swigCPtr , this , n ) ) ;


signature:
public class JNIMemoryManager { /** * Get the number of Ferry objects we believe are still in use .
 * This may be different than what you think because the Java garbage
 * collector may not have collected all objects yet .
 * Also , this method needs to walk the entire ferry reference heap , so it
 * can be expensive and not accurate ( as the value may change even before
 * this method returns ) . Use only for debugging .
 * @ return number of ferry objects in use . */
public long getNumPinnedObjects ( ) { } }

implementation: long numPinnedObjects = 0 ; blockingLock ( ) ; try { int numItems = mNextAvailableReferenceSlot ; for ( int i = 0 ; i < numItems ; i ++ ) { JNIReference ref = mValidReferences [ i ] ; if ( ref != null && ! ref . isDeleted ( ) ) ++ numPinnedObjects ; } } finally { blockingUnlock ( ) ; } return numPinnedObjects ;


signature:
public class JNIMemoryManager { /** * Dump the contents of our memory cache to the log .
 * This method requires a global lock in order to run so only
 * use for debugging . */
public void dumpMemoryLog ( ) { } }

implementation: blockingLock ( ) ; try { int numItems = mNextAvailableReferenceSlot ; log . debug ( "Memory slots in use: {}" , numItems ) ; for ( int i = 0 ; i < numItems ; i ++ ) { JNIReference ref = mValidReferences [ i ] ; if ( ref != null ) log . debug ( "Slot: {}; Ref: {}" , i , ref ) ; } } finally { blockingUnlock ( ) ; } return ;


signature:
public class JNIMemoryManager { /** * Add a reference to the set of references we ' ll collect .
 * @ param ref The reference to collect .
 * @ return true if already in list ; false otherwise . */
final boolean addReference ( final JNIReference ref ) { } }

implementation:
/* Implementation note : This method is extremely
 * hot , and so I ' ve unrolled the lock and unlock
 * methods from above . Take care if you change
 * them to change the unrolled versions here . */
// First try to grab the non blocking lock
boolean gotNonblockingLock = false ; gotNonblockingLock = mSpinLock . compareAndSet ( false , true ) ; if ( gotNonblockingLock ) { final int slot = mNextAvailableReferenceSlot ++ ; if ( slot < mMaxValidReference ) { mValidReferences [ slot ] = ref ; // unlock the non - blocking lock , and progress to a full lock .
final boolean result = mSpinLock . compareAndSet ( true , false ) ; assert result : "Should never be unlocked here" ; return true ; } // try the big lock without blocking
if ( ! mLock . tryLock ( ) ) { // we couldn ' t get the big lock , so release the spin lock
// and try getting the bit lock while blocking
gotNonblockingLock = false ; mSpinLock . compareAndSet ( true , false ) ; } } // The above code needs to make sure that we never
// have gotNonblockingLock set , unless we have both
// the spin lock and the big lock .
if ( ! gotNonblockingLock ) { mLock . lock ( ) ; while ( ! mSpinLock . compareAndSet ( false , true ) ) ; // grab the spin lock
} try { int slot = mNextAvailableReferenceSlot ++ ; if ( slot >= mMaxValidReference ) { sweepAndCollect ( ) ; slot = mNextAvailableReferenceSlot ++ ; } mValidReferences [ slot ] = ref ; } finally { final boolean result = mSpinLock . compareAndSet ( true , false ) ; assert result : "Should never ever be unlocked here" ; mLock . unlock ( ) ; } return true ;


signature:
public class JNIMemoryManager { /** * The actual GC ; */
void gcInternal ( ) { } }

implementation: JNIReference ref = null ; while ( ( ref = ( JNIReference ) mRefQueue . poll ( ) ) != null ) { ref . delete ( ) ; }


signature:
public class JNIMemoryManager { /** * Starts a new Ferry collection thread that will wake up whenever a memory
 * reference needs clean - up from native code .
 * This thread is not started by default as Ferry calls { @ link # gc ( ) }
 * internally whenever a new Ferry object is allocated . But if you ' re
 * caching Ferry objects and hence avoiding new allocations , you may want to
 * call this to ensure all objects are promptly collected .
 * This call is ignored if the collection thread is already running .
 * The thread can be stopped by calling { @ link # stopCollectionThread ( ) } , and
 * will also exit if interrupted by Java . */
public void startCollectionThread ( ) { } }

implementation:
synchronized ( this ) { if ( mCollectionThread != null ) throw new RuntimeException ( "Thread already running" ) ; mCollectionThread = new Thread ( new Runnable ( ) { public void run ( ) { JNIReference ref = null ; try { while ( true ) { ref = ( JNIReference ) mRefQueue . remove ( ) ; if ( ref != null ) ref . delete ( ) ; } } catch ( InterruptedException ex ) { synchronized ( JNIMemoryManager . this ) { mCollectionThread = null ; // reset the interruption
Thread . currentThread ( ) . interrupt ( ) ; } return ; } } } , "Humble Ferry Collection Thread" ) ; mCollectionThread . setDaemon ( true ) ; mCollectionThread . start ( ) ; }


signature:
public class JNIMemoryManager { /** * Internal Only .
 * Immediately frees all active objects in the system . Do not call unless you
 * REALLY know what you ' re doing . */
final public void flush ( ) { } }

implementation:
blockingLock ( ) ; try { int numSurvivors = sweepAndCollect ( ) ; for ( int i = 0 ; i < numSurvivors ; i ++ ) { final JNIReference ref = mValidReferences [ i ] ; if ( ref != null ) ref . delete ( ) ; } sweepAndCollect ( ) ; // finally , reset the valid references to the minimum
mValidReferences = new JNIReference [ mMinimumReferencesToCache ] ; mNextAvailableReferenceSlot = 0 ; mMaxValidReference = mMinimumReferencesToCache ; } finally { blockingUnlock ( ) ; }


signature:
public class JNIMemoryAllocator { /** * Internal Only . Allocate a new block of bytes . Called from native code .
 * Will retry many times if it can ' t get memory , backing off
 * in timeouts to get there .
 * Callers must eventually call { @ link # free ( byte [ ] ) } when done
 * with the bytes or a leak will result .
 * @ param size
 * # of bytes requested
 * @ return An array of size or more bytes long , or null on failure . */
public byte [ ] malloc ( int size ) { } }

implementation:
byte [ ] retval = null ; // first check the parachute
JNIMemoryParachute . getParachute ( ) . packChute ( ) ; try { if ( SHOULD_RETRY_FAILED_ALLOCS ) { int allocationAttempts = 0 ; int backoffTimeout = 10 ; // start at 10 milliseconds
while ( true ) { try { // log . debug ( " attempting malloc of size : { } " , size ) ;
retval = new byte [ size ] ; // log . debug ( " malloced block of size : { } " , size ) ;
// we succeed , so break out
break ; } catch ( final OutOfMemoryError e ) { // try clearing our queue now and do it again . Why ?
// because the first failure may have allowed us to
// catch a RefCounted no longer in use , and the second
// attempt may have freed that memory .
// do a JNI collect before the alloc
++ allocationAttempts ; if ( allocationAttempts >= MAX_ALLOCATION_ATTEMPTS ) { // try pulling our rip cord
JNIMemoryParachute . getParachute ( ) . pullCord ( ) ; // do one last " hope gc " to free our own memory
JNIReference . getMgr ( ) . gcInternal ( ) ; // and throw the error back to the native code
throw e ; } log . debug ( "retrying ({}) allocation of {} bytes" , allocationAttempts , size ) ; try { // give the finalizer a chance
if ( allocationAttempts <= 1 ) { // first just yield
Thread . yield ( ) ; } else { Thread . sleep ( backoffTimeout ) ; // and slowly get longer . . .
backoffTimeout = ( int ) ( backoffTimeout * FALLBACK_TIME_DECAY ) ; } } catch ( InterruptedException e1 ) { // reset the interruption so underlying
// code can also interrupt
Thread . currentThread ( ) . interrupt ( ) ; // and throw the error condition
throw e ; } // do a JNI collect before the alloc
JNIReference . getMgr ( ) . gcInternal ( ) ; } } } else { retval = new byte [ size ] ; } addToBuffer ( retval ) ; retval [ retval . length - 1 ] = 0 ; // log . debug ( " malloc : { } ( { } : { } ) " , new Object [ ]
// retval . hashCode ( ) , retval . length , size
} catch ( Throwable t ) { // do not let an exception leak out since we go back to native code .
retval = null ; } return retval ;


signature:
public class FilterPictureSource { /** * Adds a picture to this source . NOTE : If you add a picture to a FilterSource < br >
 * be careful with re - using or rewriting the underlying data . Filters will < br >
 * try hard to avoid copying data , so if you change the data out from under < br >
 * them unexpected results can occur . < br >
 * @ param picture the picture to add . Must be non - null and complete . < br >
 * @ throws InvalidArgument if picture is null or audio is not complete . */
public void addPicture ( MediaPicture picture ) { } }

implementation: VideoJNI . FilterPictureSource_addPicture ( swigCPtr , this , MediaPicture . getCPtr ( picture ) , picture ) ;


signature:
public class JNILibrary { /** * Load the given library into the given application .
 * This method first searches in the classpath for native libraries that are
 * bundled in there , and only if no matches are found , will it search the
 * run - time paths of each OS .
 * @ param appname
 * the name of the application . This should match what shows up in
 * jar manifests or native property files .
 * @ param library
 * the library object
 * @ throws UnsatisfiedLinkError
 * if library cannot be loaded . */
@ SuppressWarnings ( "deprecation" ) public static void load ( String appname , JNILibrary library ) { } }

implementation:
// we force ALL work on all libraries to be synchronized
synchronized ( mLock ) { deleteTemporaryFiles ( ) ; try { library . load ( appname ) ; } catch ( UnsatisfiedLinkError e ) { // failed ; faill back to old way
JNILibraryLoader . loadLibrary ( library . getName ( ) , library . getVersion ( ) ) ; } }


signature:
public class JNILibrary { /** * Looks for a URL in a classpath , and if found , unpacks it */
private boolean unpackLibrary ( String path ) { } }

implementation:
boolean retval = false ; try { final Enumeration < URL > c = JNILibrary . class . getClassLoader ( ) . getResources ( path ) ; while ( c . hasMoreElements ( ) ) { final URL url = c . nextElement ( ) ; log . trace ( "path: {}; url: {}" , path , url ) ; if ( url == null ) return false ; boolean unpacked = false ; File lib ; if ( url . getProtocol ( ) . toLowerCase ( ) . equals ( "file" ) ) { // it SHOULD already exist on the disk . let ' s look for it .
try { lib = new File ( new URI ( url . toString ( ) ) ) ; } catch ( URISyntaxException e ) { lib = new File ( url . getPath ( ) ) ; } if ( ! lib . exists ( ) ) { log . error ( "Unpacked library not unpacked correctedly;  url: {}" , url ) ; continue ; } } else if ( url . getProtocol ( ) . toLowerCase ( ) . equals ( "jar" ) ) { // sucktastic - - we cannot in a JVM load a shared library
// directly from a JAR , so we need to unpack to a temp
// directory and load from there .
InputStream stream = url . openStream ( ) ; if ( stream == null ) { log . error ( "could not get stream for resource: {}" , url . getPath ( ) ) ; continue ; } FileOutputStream out = null ; try { File dir = getTmpDir ( ) ; // did you know windows REQUIRES . dll . Sigh .
lib = File . createTempFile ( "humble" , JNIEnv . getEnv ( ) . getOSFamily ( ) == JNIEnv . OSFamily . WINDOWS ? ".dll" : null , dir ) ; lib . deleteOnExit ( ) ; out = new FileOutputStream ( lib ) ; int bytesRead = 0 ; final byte [ ] buffer = new byte [ 2048 ] ; while ( ( bytesRead = stream . read ( buffer , 0 , buffer . length ) ) > 0 ) { out . write ( buffer , 0 , bytesRead ) ; } unpacked = true ; } catch ( IOException e ) { log . error ( "could not create temp file: {}" , e ) ; continue ; } finally { try { stream . close ( ) ; } catch ( IOException e ) { } if ( out != null ) try { out . close ( ) ; } catch ( IOException e ) { } } try { doJNILoad ( lib . getAbsolutePath ( ) ) ; retval = true ; break ; } catch ( UnsatisfiedLinkError e ) { // expected in some cases , try the next case .
} finally { if ( unpacked ) { // Well let ' s try to clean up after ourselves since
// we had ot unpack .
deleteUnpackedFile ( lib . getAbsolutePath ( ) ) ; } } } } } catch ( IOException e1 ) { retval = false ; } return retval ;


signature:
public class JNILibrary { /** * Finds all " . humble " temp files in the temp directory and nukes them . */
private static void deleteTemporaryFiles ( ) { } }

implementation: final File dir = getTmpDir ( ) ; final FilenameFilter filter = new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( HUMBLE_TEMP_EXTENSION ) ; } } ; final File markers [ ] = dir . listFiles ( filter ) ; for ( File marker : markers ) { final String markerName = marker . getName ( ) ; final String libName = markerName . substring ( 0 , markerName . length ( ) - HUMBLE_TEMP_EXTENSION . length ( ) ) ; final File lib = new File ( marker . getParentFile ( ) , libName ) ; if ( ! lib . exists ( ) || lib . delete ( ) ) marker . delete ( ) ; }


signature:
public class AudioChannel { /** * Return default channel layout for a given number of channels . */
public static AudioChannel . Layout getDefaultLayout ( int numChannels ) { } }

implementation: return AudioChannel . Layout . swigToEnum ( VideoJNI . AudioChannel_getDefaultLayout ( numChannels ) ) ;


signature:
public class AudioChannel { /** * Get the index of a channel in channel _ layout . < br >
 * < br >
 * < p > < br >
 * Use this method to find out which index into channel data corresponds < br >
 * to the channel you care about . The way you use this differs depending < br >
 * on whether your audio is packed or planar . To illustrate , let ' s assume < br >
 * you have CH _ LAYOUT _ STEREO audio , and you ask for the index of CH _ FRONT _ LEFT , < br >
 * and we return 1 ( indexes are zero based ) . < br >
 * < / p > < p > < br >
 * If packed , then audio is laid out in one big buffer as " RLRLRLRLRLRLRLRL " audio , < br >
 * and every 2nd ( 1 + 1 ) sample is the left channel < br >
 * < / p > < p > < br >
 * If planar , then audio is out in two buffer as " RRRRR " and " LLLLL " , and the < br >
 * second plan ( 1 + 1 ) is the left channel . < br >
 * < / p > < br >
 * < br >
 * @ param channel a channel layout describing exactly one channel which must be < br >
 * present in channel _ layout . < br >
 * < br >
 * @ return index of channel in channel _ layout on success , a negative AVERROR < br >
 * on error . */
public static int getIndexOfChannelInLayout ( AudioChannel . Layout layout , AudioChannel . Type channel ) { } }

implementation: return VideoJNI . AudioChannel_getIndexOfChannelInLayout ( layout . swigValue ( ) , channel . swigValue ( ) ) ;


signature:
public class AudioChannel { /** * Get the channel with the given index in channel _ layout . */
public static AudioChannel . Type getChannelFromLayoutAtIndex ( AudioChannel . Layout layout , int index ) { } }

implementation: return AudioChannel . Type . swigToEnum ( VideoJNI . AudioChannel_getChannelFromLayoutAtIndex ( layout . swigValue ( ) , index ) ) ;


signature:
public class PixelFormat { /** * Return the pixel format corresponding to name . < br >
 * < br >
 * If there is no pixel format with name name , then looks for a < br >
 * pixel format with the name corresponding to the native endian < br >
 * format of name . < br >
 * For example in a little - endian system , first looks for " gray16 " , < br >
 * then for " gray16le " . < br >
 * < br >
 * Finally if no pixel format has been found , returns AV _ PIX _ FMT _ NONE . */
public static PixelFormat . Type getFormat ( String name ) { } }

implementation: return PixelFormat . Type . swigToEnum ( VideoJNI . PixelFormat_getFormat ( name ) ) ;


signature:
public class PixelFormat { /** * Returns the ' i ' th pixel format descriptor that is known to humble video < br >
 * < br >
 * @ param i The i ' th pixel format descriptor in the list of installed descriptors . */
public static PixelFormatDescriptor getInstalledFormatDescriptor ( int i ) { } }

implementation: long cPtr = VideoJNI . PixelFormat_getInstalledFormatDescriptor ( i ) ; return ( cPtr == 0 ) ? null : new PixelFormatDescriptor ( cPtr , false ) ;


signature:
public class PixelFormat { /** * Utility function to swap the endianness of a pixel format . < br >
 * < br >
 * pix _ fmt the pixel format < br >
 * < br >
 * @ return pixel format with swapped endianness if it exists , < br >
 * otherwise AV _ PIX _ FMT _ NONE */
public static PixelFormat . Type swapEndianness ( PixelFormat . Type pix_fmt ) { } }

implementation: return PixelFormat . Type . swigToEnum ( VideoJNI . PixelFormat_swapEndianness ( pix_fmt . swigValue ( ) ) ) ;


signature:
public class PixelFormat { /** * Find the buffer size that would be necessary to store an image < br >
 * with the given qualities . */
public static int getBufferSizeNeeded ( int width , int height , PixelFormat . Type pix_fmt ) { } }

implementation: return VideoJNI . PixelFormat_getBufferSizeNeeded ( width , height , pix_fmt . swigValue ( ) ) ;


signature:
public class MediaPacket { /** * Create a new Packet */
public static MediaPacket make ( ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_make__SWIG_0 ( ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Allocate a new packet that wraps an existing Buffer . < br >
 * < br >
 * NOTE : At least 16 bytes of the passed in buffer will be used < br >
 * for header information , so the resulting Packet . getSize ( ) < br >
 * will be smaller than Buffer . getBufferSize ( ) . < br >
 * < br >
 * @ param buffer The Buffer to wrap . < br >
 * @ return a new packet or null on error . */
public static MediaPacket make ( Buffer buffer ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_make__SWIG_1 ( Buffer . getCPtr ( buffer ) , buffer ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Allocate a new packet wrapping the existing contents of < br >
 * a passed in packet . Callers can then modify < br >
 * # getPts ( ) , < br >
 * # getDts ( ) and other get / set methods without < br >
 * modifying the original packet . < br >
 * < br >
 * @ param packet Packet to reuse buffer from and to < br >
 * copy settings from . < br >
 * @ param copyData if true copy data from packet < br >
 * into our own buffer . If false , share the same < br >
 * data buffer that packet uses < br >
 * < br >
 * @ return a new packet or null on error . */
public static MediaPacket make ( MediaPacket packet , boolean copyData ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_make__SWIG_2 ( MediaPacket . getCPtr ( packet ) , packet , copyData ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Allocate a new packet . < br >
 * < p > < br >
 * Note that any buffers this packet needs will be < br >
 * lazily allocated ( i . e . we won ' t actually grab all < br >
 * the memory until we need it ) . < br >
 * < / p > < br >
 * @ param size The maximum size , in bytes , of data you < br >
 * want to put in this packet . < br >
 * < br >
 * @ return a new packet , or null on error . */
public static MediaPacket make ( int size ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_make__SWIG_3 ( size ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Get any underlying raw data available for this packet . < br >
 * < br >
 * @ return The raw data , or null if not accessible . */
public Buffer getData ( ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_getData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Buffer ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Get the n ' th item of SideData . < br >
 * < p > < br >
 * WARNING : Callers must ensure that the the packet object < br >
 * this is called form is NOT reset or destroyed while using this buffer , < br >
 * as unfortunately we cannot ensure this buffer survives the < br >
 * underlying packet data . < br >
 * < / p > < br >
 * < br >
 * @ param n The n ' th item to get . < br >
 * @ return the data , or null if none found < br >
 * @ throws InvalidArgument if n & lt ; 0 | | n & gt ; = # getNumSideDataElems ( ) */
public Buffer getSideData ( int n ) { } }

implementation: long cPtr = VideoJNI . MediaPacket_getSideData ( swigCPtr , this , n ) ; return ( cPtr == 0 ) ? null : new Buffer ( cPtr , false ) ;


signature:
public class MediaPacket { /** * Get the n ' th item of SideData . < br >
 * < br >
 * @ param n The n ' th item to get . < br >
 * @ return the data , or SideDataType . DATA _ UNKNOWN if none found < br >
 * @ throws InvalidArgument if n & lt ; 0 | | n & gt ; = # getNumSideDataElems ( ) */
public MediaPacket . SideDataType getSideDataType ( int n ) { } }

implementation: return MediaPacket . SideDataType . swigToEnum ( VideoJNI . MediaPacket_getSideDataType ( swigCPtr , this , n ) ) ;


signature:
public class FilterType { /** * Find a given filter by name . < br >
 * < br >
 * @ param name name of filter . */
public static FilterType findFilterType ( String name ) { } }

implementation: long cPtr = VideoJNI . FilterType_findFilterType ( name ) ; return ( cPtr == 0 ) ? null : new FilterType ( cPtr , false ) ;


signature:
public class DataInputOutputHandler { /** * { @ inheritDoc } */
public int open ( String url , int flags ) { } }

implementation: if ( mOpenStream != null ) { log . debug ( "attempting to open already open handler: {}" , mOpenStream ) ; return - 1 ; } switch ( flags ) { case URL_RDWR : if ( mDataInput != null && mDataOutput != null && mDataInput == mDataOutput && mDataInput instanceof RandomAccessFile ) { mOpenStream = mDataInput ; } else { log . debug ( "do not support read/write mode for Java IO Handlers" ) ; return - 1 ; } break ; case URL_WRONLY_MODE : mOpenStream = mDataOutput ; if ( mOpenStream == null ) { log . error ( "No OutputStream specified for writing: {}" , url ) ; return - 1 ; } break ; case URL_RDONLY_MODE : mOpenStream = mDataInput ; if ( mOpenStream == null ) { log . error ( "No InputStream specified for reading: {}" , url ) ; return - 1 ; } break ; default : log . error ( "Invalid flag passed to open: {}" , url ) ; return - 1 ; } return 0 ;


signature:
public class DataInputOutputHandler { /** * { @ inheritDoc } */
public int read ( byte [ ] buf , int size ) { } }

implementation:
int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof DataInput ) ) return - 1 ; try { if ( mOpenStream instanceof RandomAccessFile ) { RandomAccessFile file = ( RandomAccessFile ) mOpenStream ; return file . read ( buf , 0 , size ) ; } else if ( mOpenStream instanceof DataInputStream ) { DataInputStream stream = ( DataInputStream ) mOpenStream ; return stream . read ( buf , 0 , size ) ; } else { DataInput input = ( DataInput ) mOpenStream ; try { input . readFully ( buf , 0 , size ) ; ret = size ; } catch ( EOFException e ) { // man ; we have no idea how many bytes were actually
// read now . . . so we truncate the data
// what a sucky interface !
ret = - 1 ; } return ret ; } } catch ( IOException e ) { log . error ( "Got IO exception reading from channel: {}; {}" , mOpenStream , e ) ; return - 1 ; }


signature:
public class DataInputOutputHandler { /** * { @ inheritDoc }
 * This method is not supported on this class and always return - 1; */
public long seek ( long offset , int whence ) { } }

implementation:
if ( mOpenStream == null ) return - 1 ; if ( ! ( mOpenStream instanceof RandomAccessFile ) ) return - 1 ; final RandomAccessFile file = ( RandomAccessFile ) mOpenStream ; try { final long seek ; if ( whence == SEEK_SET ) seek = offset ; else if ( whence == SEEK_CUR ) seek = file . getFilePointer ( ) + offset ; else if ( whence == SEEK_END ) seek = file . length ( ) + offset ; else if ( whence == SEEK_SIZE ) // odd feature of the protocol handler ; this request
// just returns the file size without actually seeking
return ( int ) file . length ( ) ; else { log . error ( "invalid seek value \"{}\" for file: {}" , whence , file ) ; return - 1 ; } file . seek ( seek ) ; return seek ; } catch ( IOException e ) { log . debug ( "got io exception \"{}\" while seeking in: {}" , e . getMessage ( ) , file ) ; return - 1 ; }


signature:
public class DataInputOutputHandler { /** * { @ inheritDoc } */
public int write ( byte [ ] buf , int size ) { } }

implementation: if ( mOpenStream == null || ! ( mOpenStream instanceof DataOutput ) ) return - 1 ; try { DataOutput output = ( DataOutput ) mOpenStream ; output . write ( buf , 0 , size ) ; return size ; } catch ( IOException e ) { log . error ( "Got error writing to file: {}; {}" , mOpenStream , e ) ; return - 1 ; }


signature:
public class DataInputOutputHandler { /** * { @ inheritDoc }
 * Always true , unless we ' re inputting or outputting to a
 * { @ link RandomAccessFile } . */
public boolean isStreamed ( String url , int flags ) { } }

implementation: if ( mDataInput != null && mDataInput instanceof RandomAccessFile ) return false ; if ( mDataOutput != null && mDataOutput instanceof RandomAccessFile ) return false ; return true ;


signature:
public class PixelFormatDescriptor { /** * Parameters that describe how pixels are packed . < br >
 * If the format has 2 or 4 components , then alpha is last . < br >
 * If the format has 1 or 2 components , then luma is 0 . < br >
 * If the format has 3 or 4 components , < br >
 * if the RGB flag is set then 0 is red , 1 is green and 2 is blue ; < br >
 * otherwise 0 is luma , 1 is chroma - U and 2 is chroma - V . */
public PixelComponentDescriptor getComponentDescriptor ( int component ) { } }

implementation: long cPtr = VideoJNI . PixelFormatDescriptor_getComponentDescriptor ( swigCPtr , this , component ) ; return ( cPtr == 0 ) ? null : new PixelComponentDescriptor ( cPtr , false ) ;


signature:
public class Version { /** * Prints the version of this library to System . out along with
 * some information on what this jar is . */
public static String getVersionInfo ( ) { } }

implementation: final Class < ? > c = Version . class ; final StringBuilder b = new StringBuilder ( ) ; final Package p = c . getPackage ( ) ; b . append ( "Class: " + c . getCanonicalName ( ) + "; " ) ; b . append ( "Specification Vendor: " + p . getSpecificationVendor ( ) + "; " ) ; b . append ( "Specification Title: " + p . getSpecificationTitle ( ) + "; " ) ; b . append ( "Specification Version: " + p . getSpecificationVersion ( ) + "; " ) ; b . append ( "Implementation Vendor: " + p . getImplementationVendor ( ) + "; " ) ; b . append ( "Implementation Title: " + p . getImplementationTitle ( ) + "; " ) ; b . append ( "Implementation Version: " + p . getImplementationVersion ( ) + ";" ) ; return b . toString ( ) ;


signature:
public class Global { /** * The default timebase used by media if not otherwise specified . */
public static Rational getDefaultTimeBase ( ) { } }

implementation: long cPtr = VideoJNI . Global_getDefaultTimeBase ( ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Property { /** * If this IProperty is of the type Type # PROPERTY _ FLAGS , this method will < br >
 * give you another IProperty representing a constant setting for that flag . < br >
 * < br >
 * @ param position The position number for the flag ; Must be in range 0 & lt ; = position & lt ; = # getNumFlagSettings ( ) . < br >
 * < br >
 * @ return An IProperty object for the flag setting , or null if not available . */
public Property getFlagConstant ( int position ) { } }

implementation: long cPtr = VideoJNI . Property_getFlagConstant__SWIG_0 ( swigCPtr , this , position ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ;


signature:
public class Property { /** * If this IProperty is of the type Type # PROPERTY _ FLAGS , this method will < br >
 * give you another IProperty representing a constant setting for that flag . < br >
 * < br >
 * @ param name The name of the constant . < br >
 * < br >
 * @ return An IProperty object for the flag setting , or null if not available . */
public Property getFlagConstant ( String name ) { } }

implementation: long cPtr = VideoJNI . Property_getFlagConstant__SWIG_1 ( swigCPtr , this , name ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ;


signature:
public class Demuxer { /** * Create a new Demuxer */
public static Demuxer make ( ) { } }

implementation: long cPtr = VideoJNI . Demuxer_make ( ) ; return ( cPtr == 0 ) ? null : new Demuxer ( cPtr , false ) ;


signature:
public class Demuxer { /** * Get the DemuxerFormat associated with this Demuxer < br >
 * or null if unknown . */
public DemuxerFormat getFormat ( ) { } }

implementation: long cPtr = VideoJNI . Demuxer_getFormat ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new DemuxerFormat ( cPtr , false ) ;


signature:
public class Demuxer { /** * Open this container and make it ready for reading , optionally < br >
 * reading as far into the container as necessary to find all streams . < br >
 * < p > The caller must call # close ( ) when done , but if not , the < br >
 * Demuxer will eventually close < br >
 * them later but warn to the logging system . < br >
 * < br >
 * @ param url The resource to open ; The format of this string is any < br >
 * url that FFMPEG supports ( including additional protocols if added < br >
 * through the video . customio library ) . < br >
 * < br >
 * @ param format A pointer to a InputFormat object specifying < br >
 * the format of this container , or null if you want us to guess . < br >
 * @ param streamsCanBeAddedDynamically If true , open ( ) will expect that new < br >
 * streams can be added at any time , even after the format header has been read . < br >
 * @ param queryStreamMetaData If true , open ( ) will call # queryStreamMetaData ( ) < br >
 * on this container , which will potentially block until it has ready < br >
 * enough data to find all streams in a container . If false , it will only < br >
 * block to read a minimal header for this container format . < br >
 * @ param options If not null , a set of key - value pairs that will be set on the container immediately < br >
 * the format is determined . Some options cannot be set on input formats until < br >
 * the system has had a chance to determine what the format is , so this < br >
 * is the only way to set InputFormat - specific options . < br >
 * @ param optionsNotSet If not null , on return this KeyValueBag object will be cleared out , and < br >
 * replace with any key / value pairs that were in < code > options < / code > but could not be set on this < br >
 * Demuxer . < br >
 * < br >
 * @ return & gt ; = 0 on success ; & lt ; 0 on error . */
public void open ( String url , DemuxerFormat format , boolean streamsCanBeAddedDynamically , boolean queryStreamMetaData , KeyValueBag options , KeyValueBag optionsNotSet ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Demuxer_open ( swigCPtr , this , url , DemuxerFormat . getCPtr ( format ) , format , streamsCanBeAddedDynamically , queryStreamMetaData , KeyValueBag . getCPtr ( options ) , options , KeyValueBag . getCPtr ( optionsNotSet ) , optionsNotSet ) ;


signature:
public class Demuxer { /** * Close the container . open ( ) must have been called first , or < br >
 * else an error is returned . < br >
 * < p > < br >
 * If this method exits because of an interruption , < br >
 * all resources will be closed anyway . < br > */
public void close ( ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Demuxer_close ( swigCPtr , this ) ;


signature:
public class Demuxer { /** * Get the stream at the given position . < br >
 * < br >
 * @ param streamIndex the index of this stream in the container < br >
 * @ return The stream at that position in the container , or null if none there . */
public DemuxerStream getStream ( int streamIndex ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: long cPtr = VideoJNI . Demuxer_getStream ( swigCPtr , this , streamIndex ) ; return ( cPtr == 0 ) ? null : new DemuxerStream ( cPtr , false ) ;


signature:
public class Demuxer { /** * Reads the next packet in the Demuxer into the Packet . This method will < br >
 * release any buffers currently held by this packet and allocate < br >
 * new ones . < br >
 * < p > < br >
 * For non - blocking IO data sources , it is possible for this method < br >
 * to return as successful but with no complete packet . In that case < br >
 * the caller should retry again later ( think EAGAIN ) semantics . < br >
 * < / p > < br >
 * < br >
 * @ param packet [ In / Out ] The packet the Demuxer will read into . < br >
 * < br >
 * @ return 0 if successful , or & lt ; 0 if not . < br >
 * @ throws RuntimeException if an error occurs except for EOF ( in which case & lt ; 0 returned ) < br >
 * or EAGAIN ( in which case 0 returned with an incomplete packet ) . */
public int read ( MediaPacket packet ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: return VideoJNI . Demuxer_read ( swigCPtr , this , MediaPacket . getCPtr ( packet ) , packet ) ;


signature:
public class Demuxer { /** * Attempts to read all the meta data in this stream , potentially by reading ahead < br >
 * and decoding packets . < br >
 * < p > < br >
 * Any packets this method reads ahead will be cached and correctly returned when you < br >
 * read packets , but this method can be non - blocking potentially until end of container < br >
 * to get all meta data . Take care when you call it . < br >
 * < / p > < p > After this method is called , other meta data methods like # getDuration ( ) should < br >
 * work . < / p > */
public void queryStreamMetaData ( ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Demuxer_queryStreamMetaData ( swigCPtr , this ) ;


signature:
public class Demuxer { /** * Set the flag . < br >
 * < br >
 * @ param flag The flag to set < br >
 * @ param value The value to set it to ( true or false ) */
public void setFlag ( Container . Flag flag , boolean value ) { } }

implementation: VideoJNI . Demuxer_setFlag ( swigCPtr , this , flag . swigValue ( ) , value ) ;


signature:
public class Demuxer { /** * Get the KeyValueBag of media MetaData for this object , < br >
 * or null if none . < br >
 * < p > < br >
 * If the Demuxer or IStream object < br >
 * that this KeyValueBag came from was opened < br >
 * for reading , then changes via KeyValueBag # setValue ( String , String ) < br >
 * will have no effect on the underlying media . < br >
 * < / p > < br >
 * < p > < br >
 * If the Demuxer or IStream object < br >
 * that this KeyValueBag came from was opened < br >
 * for writing , then changes via KeyValueBag # setValue ( String , String ) < br >
 * will have no effect after Demuxer # writeHeader ( ) < br >
 * is called . < br >
 * < / p > < br >
 * @ return the KeyValueBag . */
public KeyValueBag getMetaData ( ) { } }

implementation: long cPtr = VideoJNI . Demuxer_getMetaData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new KeyValueBag ( cPtr , false ) ;


signature:
public class Demuxer { /** * Seek to timestamp ts . < br >
 * < br >
 * Seeking will be done so that the point from which all active streams < br >
 * can be presented successfully will be closest to ts and within min / max _ ts . < br >
 * Active streams are all streams that have Stream . getDiscardSetting & lt ; < br >
 * Codec . DISCARD _ ALL . < br >
 * < br >
 * If flags contain SeekFlags . SEEK _ BYTE , then all timestamps are in bytes and < br >
 * are the file position ( this may not be supported by all demuxers ) . < br >
 * If flags contain SeekFlags . SEEK _ FRAME , then all timestamps are in frames < br >
 * in the stream with stream _ index ( this may not be supported by all demuxers ) . < br >
 * Otherwise all timestamps are in units of the stream selected by stream _ index < br >
 * or if stream _ index is - 1 , in ( 1 / Global . DEFAULT _ PTS _ MICROSECONDS } units . < br >
 * If flags contain SeekFlags . SEEK _ ANY , then non - keyframes are treated as < br >
 * keyframes ( this may not be supported by all demuxers ) . < br >
 * < br >
 * @ param stream _ index index of the stream which is used as time base reference < br >
 * @ param min _ ts smallest acceptable timestamp < br >
 * @ param ts target timestamp < br >
 * @ param max _ ts largest acceptable timestamp < br >
 * @ param flags flags < br >
 * @ return & gt ; = 0 on success , error code otherwise < br >
 * < br >
 * Note : This is part of the new seek API which is still under construction . < br >
 * Thus do not use this yet . It may change at any time , do not expect < br >
 * ABI compatibility yet ! */
public int seek ( int stream_index , long min_ts , long ts , long max_ts , int flags ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: return VideoJNI . Demuxer_seek ( swigCPtr , this , stream_index , min_ts , ts , max_ts , flags ) ;


signature:
public class Demuxer { /** * Start playing a network source . Call # pause ( ) to pause . */
public void play ( ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Demuxer_play ( swigCPtr , this ) ;


signature:
public class Demuxer { /** * Pause a playing network source . Call # play ( ) to unpause . < br >
 * < br >
 * @ return 0 on success ; & lt ; 0 if state is not # State . STATE _ PLAYING or error . */
public void pause ( ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Demuxer_pause ( swigCPtr , this ) ;


signature:
public class Rational { /** * Creates a new IRational object by copying ( by value ) this object . < br >
 * < br >
 * @ return the new object */
public Rational copy ( ) { } }

implementation: long cPtr = VideoJNI . Rational_copy ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Compare a rational to this rational < br >
 * @ param other second rational < br >
 * @ return 0 if this = = other , 1 if this & gt ; other and - 1 if this & lt ; other . */
public int compareTo ( Rational other ) { } }

implementation: return VideoJNI . Rational_compareTo ( swigCPtr , this , Rational . getCPtr ( other ) , other ) ;


signature:
public class Rational { /** * Compare two rationals < br >
 * @ param a the first rational < br >
 * @ param b the second rational < br >
 * @ return 0 if a = = b , 1 if a & gt ; b and - 1 if b & lt ; a . */
public static int sCompareTo ( Rational a , Rational b ) { } }

implementation: return VideoJNI . Rational_sCompareTo ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ;


signature:
public class Rational { /** * Reduce a fraction to it ' s lowest common denominators . < br >
 * This is useful for framerate calculations . < br >
 * @ param num the src numerator . < br >
 * @ param den the src denominator . < br >
 * @ param max the maximum allowed for nom & amp ; den in the reduced fraction . < br >
 * @ return 1 if exact , 0 otherwise */
public int reduce ( long num , long den , long max ) { } }

implementation: return VideoJNI . Rational_reduce ( swigCPtr , this , num , den , max ) ;


signature:
public class Rational { /** * Reduce a fraction to it ' s lowest common denominators . < br >
 * This is useful for framerate calculations . < br >
 * @ param dst The destination rational < br >
 * @ param num the src numerator . < br >
 * @ param den the src denominator . < br >
 * @ param max the maximum allowed for nom & amp ; den in the reduced fraction . < br >
 * @ return 1 if exact , 0 otherwise */
public static int sReduce ( Rational dst , long num , long den , long max ) { } }

implementation: return VideoJNI . Rational_sReduce ( Rational . getCPtr ( dst ) , dst , num , den , max ) ;


signature:
public class Rational { /** * Multiplies this number by arg < br >
 * @ param arg number to mulitply by . < br >
 * @ return this * arg . */
public Rational multiply ( Rational arg ) { } }

implementation: long cPtr = VideoJNI . Rational_multiply ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Multiples a by b . < br >
 * @ param a the first number < br >
 * @ param b the second number . < br >
 * @ return a * b */
public static Rational sMultiply ( Rational a , Rational b ) { } }

implementation: long cPtr = VideoJNI . Rational_sMultiply ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Divides this rational by arg . < br >
 * @ param arg The divisor to use . < br >
 * @ return this / arg . */
public Rational divide ( Rational arg ) { } }

implementation: long cPtr = VideoJNI . Rational_divide ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Divides a by b . < br >
 * @ param a The first number . < br >
 * b The second number . < br >
 * @ return a / b . */
public static Rational sDivide ( Rational a , Rational b ) { } }

implementation: long cPtr = VideoJNI . Rational_sDivide ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Subtracts arg from this rational < br >
 * @ param arg The amount to subtract from this . < br >
 * @ return this - arg . */
public Rational subtract ( Rational arg ) { } }

implementation: long cPtr = VideoJNI . Rational_subtract ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Subtracts a from b . < br >
 * @ param a The first number . < br >
 * b The second number . < br >
 * @ return a - b . */
public static Rational sSubtract ( Rational a , Rational b ) { } }

implementation: long cPtr = VideoJNI . Rational_sSubtract ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Adds arg to this rational < br >
 * @ param arg The amount to add to this . < br >
 * @ return this + arg . */
public Rational add ( Rational arg ) { } }

implementation: long cPtr = VideoJNI . Rational_add ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Adds a to b . < br >
 * @ param a The first number . < br >
 * b The second number . < br >
 * @ return a + b . */
public static Rational sAdd ( Rational a , Rational b ) { } }

implementation: long cPtr = VideoJNI . Rational_sAdd ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Takes a value scaled in increments of origBase and gives the < br >
 * equivalent value scaled in terms of this Rational . < br >
 * < br >
 * @ param origValue The original int64 _ t value you care about . < br >
 * @ param origBase The original base Rational that origValue is scaled with . < br >
 * < br >
 * @ return The new integer value , scaled in units of this IRational . */
public long rescale ( long origValue , Rational origBase ) { } }

implementation: return VideoJNI . Rational_rescale__SWIG_0 ( swigCPtr , this , origValue , Rational . getCPtr ( origBase ) , origBase ) ;


signature:
public class Rational { /** * Takes a value scaled in increments of origBase and gives the < br >
 * equivalent value scaled in terms of this Rational . < br >
 * < br >
 * @ param origValue The original int64 _ t value you care about . < br >
 * @ param origBase The original base Rational that origValue is scaled with . < br >
 * @ param newBase The rational you want to rescale origValue into . < br >
 * < br >
 * @ return The new integer value , scaled in units of this IRational . */
public static long sRescale ( long origValue , Rational origBase , Rational newBase ) { } }

implementation: return VideoJNI . Rational_sRescale__SWIG_0 ( origValue , Rational . getCPtr ( origBase ) , origBase , Rational . getCPtr ( newBase ) , newBase ) ;


signature:
public class Rational { /** * Get a new rational that will be set to 0/1 . < br >
 * The rational will not have # init ( ) called < br >
 * and hence will be modifiable by # setValue ( double ) < br >
 * until # init ( ) is called . < br >
 * @ return a rational number object */
public static Rational make ( ) { } }

implementation: long cPtr = VideoJNI . Rational_make__SWIG_0 ( ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Converts a double precision floating point number to a rational . < br >
 * @ param d double to convert < br >
 * @ return A new Rational ; caller must release ( ) when done . */
public static Rational make ( double d ) { } }

implementation: long cPtr = VideoJNI . Rational_make__SWIG_1 ( d ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Creates deep copy of a Rational from another Rational . < br >
 * < br >
 * @ param src The source Rational to copy . < br >
 * @ return A new Rational ; Returns null < br >
 * if src is null . */
public static Rational make ( Rational src ) { } }

implementation: long cPtr = VideoJNI . Rational_make__SWIG_2 ( Rational . getCPtr ( src ) , src ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Create a rational from a numerator and denominator . < br >
 * < br >
 * We will always reduce this to the lowest num / den pair < br >
 * we can , but never having den exceed what was passed in . < br >
 * < br >
 * @ param num The numerator of the resulting Rational < br >
 * @ param den The denominator of the resulting Rational < br >
 * < br >
 * @ return A new Rational ; */
public static Rational make ( int num , int den ) { } }

implementation: long cPtr = VideoJNI . Rational_make__SWIG_3 ( num , den ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ;


signature:
public class Rational { /** * Takes a value scaled in increments of origBase and gives the < br >
 * equivalent value scaled in terms of this Rational . < br >
 * < br >
 * @ param origValue The original int64 _ t value you care about . < br >
 * @ param origBase The original base Rational that origValue is scaled with . < br >
 * @ param rounding How you want rounding to occur < br >
 * @ return The new integer value , scaled in units of this IRational . */
public long rescale ( long origValue , Rational origBase , Rational . Rounding rounding ) { } }

implementation: return VideoJNI . Rational_rescale__SWIG_1 ( swigCPtr , this , origValue , Rational . getCPtr ( origBase ) , origBase , rounding . swigValue ( ) ) ;


signature:
public class Rational { /** * Takes a value scaled in increments of origBase and gives the < br >
 * equivalent value scaled in terms of this Rational . < br >
 * < br >
 * @ param origValue The original int64 _ t value you care about . < br >
 * @ param origBase The original base Rational that origValue is scaled with . < br >
 * @ param newBase The rational you want to rescale origValue into . < br >
 * @ param rounding How you want rounding to occur < br >
 * < br >
 * @ return The new integer value , scaled in units of this IRational . */
public static long sRescale ( long origValue , Rational origBase , Rational newBase , Rational . Rounding rounding ) { } }

implementation: return VideoJNI . Rational_sRescale__SWIG_1 ( origValue , Rational . getCPtr ( origBase ) , origBase , Rational . getCPtr ( newBase ) , newBase , rounding . swigValue ( ) ) ;


signature:
public class Rational { /** * Rescales a long value to another long value . < br >
 * < p > < br >
 * This method doesn ' t use IRational values , but < br >
 * instead uses numerators and denominators < br >
 * passed in by the caller . It will not result < br >
 * in any memory allocations . < br >
 * < / p > < br >
 * < br >
 * @ param srcValue The value to rescale . < br >
 * @ param dstNumerator The numerator of the units < br >
 * you want to scale to . Must be non - zero . < br >
 * @ param dstDenominator The denominator of the units < br >
 * you want to scale to . Must be non - zero . < br >
 * @ param srcNumerator The numerator of the units < br >
 * < code > srcValue < / code > is expressed in . < br >
 * Must be non - zero . < br >
 * @ param srcDenominator The denominator of the units < br >
 * < code > srcValue < / code > is expressed in . < br >
 * Must be non - zero . < br >
 * @ param rounding How you want rounding to occur < br >
 * < br >
 * @ return The new integer value , scaled in units of < br >
 * dstNumerator / dstNumerator , or 0 if there < br >
 * is a parameter error . */
public static long rescale ( long srcValue , int dstNumerator , int dstDenominator , int srcNumerator , int srcDenominator , Rational . Rounding rounding ) { } }

implementation: return VideoJNI . Rational_rescale__SWIG_2 ( srcValue , dstNumerator , dstDenominator , srcNumerator , srcDenominator , rounding . swigValue ( ) ) ;


signature:
public class DecodeAndPlayVideo { /** * Takes the video picture and displays it at the right time . */
private static BufferedImage displayVideoAtCorrectTime ( long streamStartTime , final MediaPicture picture , final MediaPictureConverter converter , BufferedImage image , final ImageFrame window , long systemStartTime , final Rational systemTimeBase , final Rational streamTimebase ) throws InterruptedException { } }

implementation:
long streamTimestamp = picture . getTimeStamp ( ) ; // convert streamTimestamp into system units ( i . e . nano - seconds )
streamTimestamp = systemTimeBase . rescale ( streamTimestamp - streamStartTime , streamTimebase ) ; // get the current clock time , with our most accurate clock
long systemTimestamp = System . nanoTime ( ) ; // loop in a sleeping loop until we ' re within 1 ms of the time for that video frame .
// a real video player needs to be much more sophisticated than this .
while ( streamTimestamp > ( systemTimestamp - systemStartTime + 1000000 ) ) { Thread . sleep ( 1 ) ; systemTimestamp = System . nanoTime ( ) ; } // finally , convert the image from Humble format into Java images .
image = converter . toImage ( image , picture ) ; // And ask the UI thread to repaint with the new image .
window . setImage ( image ) ; return image ;


signature:
public class BitStreamFilterType { /** * Gets a collection of ALL codecs installed on this
 * system .
 * @ return A collection of all installed codecs . */
public static java . util . Collection < BitStreamFilterType > getInstalledBitStreamFilterTypes ( ) { } }

implementation: java . util . Collection < BitStreamFilterType > retval = new java . util . HashSet < BitStreamFilterType > ( ) ; int count = getNumBitStreamFilterTypes ( ) ; for ( int i = 0 ; i < count ; i ++ ) { BitStreamFilterType t = getBitStreamFilterType ( i ) ; if ( t != null ) retval . add ( t ) ; } return retval ;


signature:
public class MediaAudioConverterFactory { /** * Create a converter .
 * @ param description A descriptor string for the converter .
 * @ param protoAudio A MediaAudio object to copy the input audio parameters from .
 * @ return */
public static MediaAudioConverter createConverter ( String description , MediaAudio protoAudio ) { } }

implementation: return createConverter ( description , protoAudio . getSampleRate ( ) , protoAudio . getChannelLayout ( ) , protoAudio . getFormat ( ) ) ;


signature:
public class MediaAudioConverterFactory { /** * Create a converter .
 * @ param description A descriptor string for the converter .
 * @ param sampleRate Sample rate of MediaAudio objects that will be converted to / from .
 * @ param layout Channel layout of MediaAudio objects that will be converted to / from .
 * @ param format Sample format of MediaAudio objets that will be converted to / from .
 * @ return A converter to use */
public static MediaAudioConverter createConverter ( String description , int sampleRate , Layout layout , Type format ) { } }

implementation: if ( description != DEFAULT_JAVA_AUDIO ) throw new RuntimeException ( "Unsupported converter type" ) ; return new StereoS16AudioConverter ( sampleRate , layout , format ) ;


signature:
public class Encoder { /** * Create a Encoder that will use the given Codec . < br >
 * < br >
 * @ return a Encoder < br >
 * @ throws InvalidArgument if codec is null or codec cannot decode . */
public static Encoder make ( Codec codec ) { } }

implementation: long cPtr = VideoJNI . Encoder_make__SWIG_0 ( Codec . getCPtr ( codec ) , codec ) ; return ( cPtr == 0 ) ? null : new Encoder ( cPtr , false ) ;


signature:
public class Encoder { /** * Creates a Encoder from a given Encoder < br >
 * @ return a Encoder < br >
 * @ throws InvalidArgument if src is null */
public static Encoder make ( Coder src ) { } }

implementation: long cPtr = VideoJNI . Encoder_make__SWIG_1 ( Coder . getCPtr ( src ) , src ) ; return ( cPtr == 0 ) ? null : new Encoder ( cPtr , false ) ;


signature:
public class Encoder { /** * Open this Coder , using the given bag of Codec - specific options . < br >
 * < br >
 * @ param inputOptions If non - null , a bag of codec - specific options . < br >
 * @ param unsetOptions If non - null , the bag will be emptied and then filled with < br >
 * the options in < code > inputOptions < / code > that were not set . */
public void open ( KeyValueBag inputOptions , KeyValueBag unsetOptions ) { } }

implementation: VideoJNI . Encoder_open ( swigCPtr , this , KeyValueBag . getCPtr ( inputOptions ) , inputOptions , KeyValueBag . getCPtr ( unsetOptions ) , unsetOptions ) ;


signature:
public class Encoder { /** * Encode the given MediaPicture using this encoder . < br >
 * < br >
 * The MediaPicture will allocate a buffer to use internally for this , and < br >
 * will free it when the frame destroys itself . < br >
 * < br >
 * Also , when done in order to flush the encoder , caller should call < br >
 * this method passing in 0 ( null ) for frame to tell the encoder < br >
 * to flush any data it was keeping a hold of . < br >
 * < br >
 * @ param output [ out ] The packet to encode into . Caller should check < br >
 * MediaPacket . isComplete ( ) after call to find out if we had enough < br >
 * information to encode a full packet . < br >
 * @ param picture [ in ] The picture to encode < br >
 * < br >
 * Note : caller must ensure that output has sufficient space to < br >
 * contain a full packet . Alas , there is currently no way to < br >
 * query an encoder to find out the maximum packet size that < br >
 * can be output ( bummer , I know ) . That leaves the caller two < br >
 * options . ( 1 ) You can call Packet . make ( ) before each encode < br >
 * call , and then the encoder will automagically create the correct < br >
 * sized buffer for that call ( but if you reuse the packet , it < br >
 * may be too small for the next caller ) . Or ( 2 ) you can call < br >
 * Packet . make ( int ) with a value that will be larger than your < br >
 * max packet size ( in which case you can reuse the packet ) . */
public void encodeVideo ( MediaPacket output , MediaPicture picture ) { } }

implementation: VideoJNI . Encoder_encodeVideo ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaPicture . getCPtr ( picture ) , picture ) ;


signature:
public class Encoder { /** * Encode the given MediaAudio using this encoder . < br >
 * < br >
 * Callers should call this repeatedly on a set of samples until < br >
 * we consume all the samples . < br >
 * < br >
 * Also , when done in order to flush the encoder , caller should call < br >
 * this method passing in 0 ( null ) for samples to tell the encoder < br >
 * to flush any data it was keeping a hold of . < br >
 * < br >
 * @ param output [ out ] The packet to encode into . Caller should check < br >
 * MediaPacket . isComplete ( ) after call to find out if we had enough < br >
 * information to encode a full packet . < br >
 * @ param samples [ in ] The samples to consume < br >
 * < br >
 * Note : caller must ensure that output has sufficient space to < br >
 * contain a full packet . Alas , there is currently no way to < br >
 * query an encoder to find out the maximum packet size that < br >
 * can be output ( bummer , I know ) . That leaves the caller two < br >
 * options . ( 1 ) You can call Packet . make ( ) before each encode < br >
 * call , and then the encoder will automagically create the correct < br >
 * sized buffer for that call ( but if you reuse the packet , it < br >
 * may be too small for the next caller ) . Or ( 2 ) you can call < br >
 * Packet . make ( int ) with a value that will be larger than your < br >
 * max packet size ( in which case you can reuse the packet ) . */
public void encodeAudio ( MediaPacket output , MediaAudio samples ) { } }

implementation: VideoJNI . Encoder_encodeAudio ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaAudio . getCPtr ( samples ) , samples ) ;


signature:
public class Encoder { /** * Encode the given Media using this encoder . < br >
 * < br >
 * Callers should call this repeatedly on a media object ntil < br >
 * we consume all the media . < br >
 * < br >
 * Also , when done in order to flush the encoder , caller should call < br >
 * this method passing in 0 ( null ) for media to tell the encoder < br >
 * to flush any data it was keeping a hold of . < br >
 * < br >
 * @ param output [ out ] The packet to encode into . Caller should check < br >
 * MediaPacket . isComplete ( ) after call to find out if we had enough < br >
 * information to encode a full packet . < br >
 * < br >
 * < br >
 * Note : caller must ensure that output has sufficient space to < br >
 * contain a full packet . Alas , there is currently no way to < br >
 * query an encoder to find out the maximum packet size that < br >
 * can be output ( bummer , I know ) . That leaves the caller two < br >
 * options . ( 1 ) You can call Packet . make ( ) before each encode < br >
 * call , and then the encoder will automagically create the correct < br >
 * sized buffer for that call ( but if you reuse the packet , it < br >
 * may be too small for the next caller ) . Or ( 2 ) you can call < br >
 * Packet . make ( int ) with a value that will be larger than your < br >
 * max packet size ( in which case you can reuse the packet ) . < br >
 * < br >
 * @ throws throws an exception if getCodecType ( ) and the underlying < br >
 * media object do not align ( e . g . if you pass in a MediaPicture but the < br >
 * CodecType is audio data ) . */
public void encode ( MediaPacket output , MediaSampled media ) { } }

implementation: VideoJNI . Encoder_encode ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaSampled . getCPtr ( media ) , media ) ;


signature:
public class BgrConverter { /** * { @ inheritDoc } */
@ Override public MediaPicture toPicture ( MediaPicture output , final BufferedImage input , long timestamp ) { } }

implementation:
// validate the image
validateImage ( input ) ; if ( output == null ) { output = MediaPicture . make ( mPictureWidth , mPictureHeight , getPictureType ( ) ) ; } // get the image byte buffer buffer
DataBuffer imageBuffer = input . getRaster ( ) . getDataBuffer ( ) ; byte [ ] imageBytes = null ; int [ ] imageInts = null ; // handle byte buffer case
if ( imageBuffer instanceof DataBufferByte ) { imageBytes = ( ( DataBufferByte ) imageBuffer ) . getData ( ) ; } // handle integer buffer case
else if ( imageBuffer instanceof DataBufferInt ) { imageInts = ( ( DataBufferInt ) imageBuffer ) . getData ( ) ; } // if it ' s some other type , throw
else { throw new IllegalArgumentException ( "Unsupported BufferedImage data buffer type: " + imageBuffer . getDataType ( ) ) ; } // create the video picture and get it ' s underlying buffer
final AtomicReference < JNIReference > ref = new AtomicReference < JNIReference > ( null ) ; final MediaPicture picture = willResample ( ) ? mResampleMediaPicture : output ; try { Buffer buffer = picture . getData ( 0 ) ; int size = picture . getDataPlaneSize ( 0 ) ; ByteBuffer pictureByteBuffer = buffer . getByteBuffer ( 0 , size , ref ) ; buffer . delete ( ) ; buffer = null ; if ( imageInts != null ) { pictureByteBuffer . order ( ByteOrder . BIG_ENDIAN ) ; IntBuffer pictureIntBuffer = pictureByteBuffer . asIntBuffer ( ) ; pictureIntBuffer . put ( imageInts ) ; } else { pictureByteBuffer . put ( imageBytes ) ; } pictureByteBuffer = null ; picture . setTimeStamp ( timestamp ) ; picture . setComplete ( true ) ; // resample as needed
if ( willResample ( ) ) { resample ( output , picture , mToPictureResampler ) ; } return output ; } finally { if ( ref . get ( ) != null ) ref . get ( ) . delete ( ) ; }


signature:
public class BgrConverter { /** * { @ inheritDoc } */
@ Override public BufferedImage toImage ( BufferedImage output , final MediaPicture input ) { } }

implementation:
validatePicture ( input ) ; // test that the picture is valid
if ( output == null ) { final byte [ ] bytes = new byte [ willResample ( ) ? mResampleMediaPicture . getDataPlaneSize ( 0 ) : input . getDataPlaneSize ( 0 ) ] ; // create the data buffer from the bytes
final DataBufferByte db = new DataBufferByte ( bytes , bytes . length ) ; // create an a sample model which matches the byte layout of the
// image data and raster which contains the data which now can be
// properly interpreted
int w = mImageWidth ; int h = mImageHeight ; final SampleModel sm = new PixelInterleavedSampleModel ( db . getDataType ( ) , w , h , 3 , 3 * w , mBandOffsets ) ; final WritableRaster wr = Raster . createWritableRaster ( sm , db , null ) ; // create a color model
final ColorModel colorModel = new ComponentColorModel ( mColorSpace , false , false , ColorModel . OPAQUE , db . getDataType ( ) ) ; // return a new image created from the color model and raster
output = new BufferedImage ( colorModel , wr , false , null ) ; } MediaPicture picture ; // resample as needed
AtomicReference < JNIReference > ref = new AtomicReference < JNIReference > ( null ) ; try { if ( willResample ( ) ) { picture = resample ( mResampleMediaPicture , input , mToImageResampler ) ; } else { picture = input ; } final Buffer buffer = picture . getData ( 0 ) ; final int size = picture . getDataPlaneSize ( 0 ) ; final ByteBuffer byteBuf = buffer . getByteBuffer ( 0 , size , ref ) ; buffer . delete ( ) ; // get the bytes out of the image
final DataBufferByte db = ( DataBufferByte ) output . getRaster ( ) . getDataBuffer ( ) ; final byte [ ] bytes = db . getData ( ) ; // and copy them in .
byteBuf . get ( bytes , 0 , size ) ; // return a new image created from the color model and raster
return output ; } finally { if ( ref . get ( ) != null ) ref . get ( ) . delete ( ) ; }


signature:
public class CodecDescriptor { /** * Get the descriptor for the given id . */
public static CodecDescriptor make ( Codec . ID id ) { } }

implementation: long cPtr = VideoJNI . CodecDescriptor_make ( id . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new CodecDescriptor ( cPtr , false ) ;


signature:
public class Configuration { /** * Print out all configurable options on the { @ link Configurable } object .
 * @ param stream stream to print to
 * @ param configObj { @ link Configurable } object . */
public static void printConfigurable ( java . io . PrintStream stream , Configurable configObj ) { } }

implementation: stream . println ( "=======================================" ) ; stream . println ( "  " + configObj . getClass ( ) . getName ( ) + " Properties" ) ; stream . println ( "=======================================" ) ; int numOptions = configObj . getNumProperties ( ) ; for ( int i = 0 ; i < numOptions ; i ++ ) { Property prop = configObj . getPropertyMetaData ( i ) ; printOption ( stream , configObj , prop ) ; }


signature:
public class Configuration { /** * Print information about the property on the configurable object .
 * @ param stream stream to print to
 * @ param configObj configurable object
 * @ param prop property on object */
public static void printOption ( java . io . PrintStream stream , Configurable configObj , Property prop ) { } }

implementation:
if ( prop . getType ( ) != Property . Type . PROPERTY_FLAGS ) { stream . printf ( "  %s; default= %s; type=%s;\n" , prop . getName ( ) , configObj . getPropertyAsString ( prop . getName ( ) ) , prop . getType ( ) ) ; } else { // it ' s a flag
stream . printf ( "  %s; default= %d; valid values=(" , prop . getName ( ) , configObj . getPropertyAsLong ( prop . getName ( ) ) ) ; int numSettings = prop . getNumFlagSettings ( ) ; long value = configObj . getPropertyAsLong ( prop . getName ( ) ) ; for ( int i = 0 ; i < numSettings ; i ++ ) { Property fprop = prop . getFlagConstant ( i ) ; long flagMask = fprop . getDefault ( ) ; boolean isSet = ( value & flagMask ) > 0 ; stream . printf ( "%s%s; " , isSet ? "+" : "-" , fprop . getName ( ) ) ; } stream . printf ( "); type=%s;\n" , prop . getType ( ) ) ; } stream . printf ( "    help for %s: %s\n" , prop . getName ( ) , prop . getHelp ( ) == null ? "no help available" : prop . getHelp ( ) ) ;


signature:
public class Configuration { /** * Configures an { @ link Configurable } from a set of Java { @ link Properties } .
 * Here ' s some sample code that shows configuring a IStreamCoder
 * from a FFmpeg preset file :
 * < pre >
 * Properties props = new Properties ( ) ;
 * props . load ( new FileInputStream ( file ) ) ;
 * IStreamCoder coder = IStreamCoder . make ( Direction . ENCODING ) ;
 * int retval = Configuration . configure ( props , coder ) ;
 * if ( retval < 0)
 * throw new RuntimeException ( " Could not configure object " ) ;
 * < / pre >
 * @ param properties The properties to use .
 * @ param config The item to configure . */
@ SuppressWarnings ( "unchecked" ) public static void configure ( final Properties properties , final Configurable config ) { } }

implementation: for ( final Enumeration < String > names = ( Enumeration < String > ) properties . propertyNames ( ) ; names . hasMoreElements ( ) ; ) { final String name = names . nextElement ( ) ; final String value = properties . getProperty ( name ) ; if ( value != null ) { try { config . setProperty ( name , value ) ; } catch ( PropertyNotFoundException e ) { log . warn ( "Could not find property on object {}; name=\"{}\"; value=\"{}\"" , new Object [ ] { config , name , value } ) ; } } }


signature:
public class Configuration { /** * Configures an { @ link Configurable } from a file .
 * This is a handy way to configure a Humble Video { @ link Configurable }
 * object , and will also work with FFmpeg preset files .
 * @ param file A filename for the properties file .
 * @ param config The item to configure .
 * @ throws IOException
 * @ throws FileNotFoundException */
@ SuppressWarnings ( "unchecked" ) public static void configure ( final String file , final Configurable config ) throws FileNotFoundException , IOException { } }

implementation: Properties props = new Properties ( ) ; props . load ( new FileInputStream ( file ) ) ; Configuration . configure ( props , config ) ;


signature:
public class MediaEncoded { /** * Set the time base that time stamps of this object are represented in . < br >
 * < br >
 * @ param aBase the new time base . If null an exception is thrown . */
public void setTimeBase ( Rational aBase ) { } }

implementation: VideoJNI . MediaEncoded_setTimeBase ( swigCPtr , this , Rational . getCPtr ( aBase ) , aBase ) ;


signature:
public class MediaPictureConverterFactory { /** * Find a descriptor given a { @ link BufferedImage } .
 * @ param image a buffered image for which to find a descriptor
 * @ return the descriptor which matches the image or NULL if it was
 * not found */
public static String findDescriptor ( BufferedImage image ) { } }

implementation: for ( Type converterType : getRegisteredConverters ( ) ) if ( converterType . getImageType ( ) == image . getType ( ) ) return converterType . getDescriptor ( ) ; return null ;


signature:
public class MediaPictureConverterFactory { /** * Create a converter which translates betewen { @ link BufferedImage }
 * and { @ link MediaPicture } types . The { @ link
 * io . humble . video . PixelFormat . Type } and size are extracted from
 * the passed in picture . This factory will attempt to create a
 * converter which can perform the translation . If no converter can
 * be created , a descriptive { @ link UnsupportedOperationException } is
 * thrown .
 * @ param converterDescriptor the unique string descriptor of the
 * converter which is to be created
 * @ param picture the picture from which size and type are extracted
 * @ throws UnsupportedOperationException if the converter can not be
 * found
 * @ throws UnsupportedOperationException if the found converter can
 * not be properly initialized
 * @ throws IllegalArgumentException if the passed { @ link
 * MediaPicture } is NULL ; */
public static MediaPictureConverter createConverter ( String converterDescriptor , MediaPicture picture ) { } }

implementation: if ( picture == null ) throw new IllegalArgumentException ( "The picture is NULL." ) ; return createConverter ( converterDescriptor , picture . getFormat ( ) , picture . getWidth ( ) , picture . getHeight ( ) ) ;


signature:
public class MediaPictureConverterFactory { /** * Create a converter which translates between { @ link BufferedImage }
 * and { @ link MediaPicture } . This factory will attempt to
 * create a converter which can perform the translation . If no
 * converter can be created , a descriptive { @ link
 * UnsupportedOperationException } is thrown .
 * @ param image a prototypical { @ link BufferedImage } that is in the format you want to convert to / from .
 * @ param picture a prototypical { @ link MediaPicture } in the format you want to convert to / from .
 * @ throws UnsupportedOperationException if the converter can not be
 * found
 * @ throws UnsupportedOperationException if the found converter can
 * not be properly initialized */
public static MediaPictureConverter createConverter ( BufferedImage image , MediaPicture picture ) { } }

implementation: if ( image == null ) throw new IllegalArgumentException ( "cannot pass null image" ) ; if ( picture == null ) throw new IllegalArgumentException ( "cannot pass null picture" ) ; return createConverter ( image , picture . getFormat ( ) ) ;


signature:
public class MediaPictureConverterFactory { /** * Create a converter which translates between { @ link BufferedImage }
 * and { @ link MediaPicture } types . The { @ link BufferedImage } type and
 * size are extracted from the passed in image . This factory will
 * attempt to create a converter which can perform the translation .
 * If no converter can be created , a descriptive { @ link
 * UnsupportedOperationException } is thrown .
 * @ param image the image from which size and type are extracted
 * @ param pictureType the picture type of the converter
 * @ throws UnsupportedOperationException if no converter for the
 * specified BufferedImage type exists
 * @ throws UnsupportedOperationException if the found converter can
 * not be properly initialized
 * @ throws IllegalArgumentException if the passed { @ link
 * BufferedImage } is NULL ; */
public static MediaPictureConverter createConverter ( BufferedImage image , PixelFormat . Type pictureType ) { } }

implementation:
if ( image == null ) throw new IllegalArgumentException ( "The image is NULL." ) ; // find the converter type based in image type
String converterDescriptor = findDescriptor ( image ) ; if ( converterDescriptor == null ) throw new UnsupportedOperationException ( "No converter found for BufferedImage type #" + image . getType ( ) ) ; // create and return the converter
return createConverter ( converterDescriptor , pictureType , image . getWidth ( ) , image . getHeight ( ) ) ;


signature:
public class MediaPictureConverterFactory { /** * Create a converter which translates between { @ link BufferedImage }
 * and { @ link MediaPicture } types . This factory will attempt to
 * create a converter which can perform the translation . If no
 * converter can be created , a descriptive { @ link
 * UnsupportedOperationException } is thrown .
 * @ param converterDescriptor the unique string descriptor of the
 * converter which is to be created
 * @ param pictureType the picture type of the converter
 * @ param width the width of pictures and images
 * @ param height the height of pictures and images
 * @ throws UnsupportedOperationException if the converter can not be
 * found
 * @ throws UnsupportedOperationException if the found converter can
 * not be properly initialized */
public static MediaPictureConverter createConverter ( String converterDescriptor , PixelFormat . Type pictureType , int width , int height ) { } }

implementation: return createConverter ( converterDescriptor , pictureType , width , height , width , height ) ;


signature:
public class MediaPictureConverterFactory { /** * Create a converter which translates betewen { @ link BufferedImage }
 * and { @ link MediaPicture } types . This factory will attempt to
 * create a converter which can perform the translation . If different
 * image and pictures sizes are passed the converter will resize
 * during translation . If no converter can be created , a descriptive
 * { @ link UnsupportedOperationException } is thrown .
 * @ param converterDescriptor the unique string descriptor of the
 * converter which is to be created
 * @ param pictureType the picture type of the converter
 * @ param pictureWidth the width of pictures
 * @ param pictureHeight the height of pictures
 * @ param imageWidth the width of images
 * @ param imageHeight the height of images
 * @ throws UnsupportedOperationException if the converter can not be
 * found
 * @ throws UnsupportedOperationException if the converter can not be
 * properly created or initialized */
public static MediaPictureConverter createConverter ( String converterDescriptor , PixelFormat . Type pictureType , int pictureWidth , int pictureHeight , int imageWidth , int imageHeight ) { } }

implementation:
MediaPictureConverter converter = null ; // establish the converter type
Type converterType = findRegisteredConverter ( converterDescriptor ) ; if ( null == converterType ) throw new UnsupportedOperationException ( "No converter \"" + converterDescriptor + "\" found." ) ; // create the converter
try { // establish the constructor
Constructor < ? extends MediaPictureConverter > converterConstructor = converterType . getConverterClass ( ) . getConstructor ( PixelFormat . Type . class , int . class , int . class , int . class , int . class ) ; // create the converter
converter = converterConstructor . newInstance ( pictureType , pictureWidth , pictureHeight , imageWidth , imageHeight ) ; } catch ( NoSuchMethodException e ) { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " requries a constructor of the form " + "(PixelFormat.Type, int, int, int, int)" ) ; } catch ( InvocationTargetException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } catch ( IllegalAccessException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } catch ( InstantiationException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } // return the newly created converter
return converter ;


signature:
public class MediaPictureConverterFactory { /** * Convert a { @ link BufferedImage } of any type , to { @ link
 * BufferedImage } of a specified type . If the source image is the
 * same type as the target type , then original image is returned ,
 * otherwise new image of the correct type is created and the content
 * of the source image is copied into the new image .
 * @ param sourceImage the image to be converted
 * @ param targetType the desired BufferedImage type
 * @ return a BufferedImage of the specifed target type .
 * @ see BufferedImage */
public static BufferedImage convertToType ( BufferedImage sourceImage , int targetType ) { } }

implementation:
BufferedImage image ; // if the source image is already the target type , return the source image
if ( sourceImage . getType ( ) == targetType ) image = sourceImage ; // otherwise create a new image of the target type and draw the new
// image
else { image = new BufferedImage ( sourceImage . getWidth ( ) , sourceImage . getHeight ( ) , targetType ) ; image . getGraphics ( ) . drawImage ( sourceImage , 0 , 0 , null ) ; } return image ;


signature:
public class JNIMemoryParachute { /** * Checks the current parachute and recreates ( reloads ) our payload
 * if needed .
 * @ return true on success pretty much all the time because . . .
 * @ throws OutOfMemoryError if we can ' t reload the parachute */
boolean packChute ( ) throws OutOfMemoryError { } }

implementation:
if ( mPayload != null ) return true ; // otherwise the payload is null
synchronized ( this ) { if ( mPayload != null ) return true ; try { // System . out . println ( " Packing the parachute ! this = " + this ) ;
mPayload = new byte [ PAYLOAD_BYTES ] ; mPayload [ 0 ] = 'P' ; mPayload [ 1 ] = 'A' ; mPayload [ 2 ] = 'R' ; mPayload [ 3 ] = 'A' ; mPayload [ 4 ] = 'C' ; mPayload [ 5 ] = 'H' ; mPayload [ 6 ] = 'U' ; mPayload [ 7 ] = 'T' ; mPayload [ 8 ] = 'E' ; mPayload [ 9 ] = '!' ; return true ; } catch ( OutOfMemoryError e ) { // we failed to create the parachute . Also known as bad .
// forward it on .
throw e ; } }


signature:
public class ReadableWritableChannelHandler { /** * { @ inheritDoc } */
public int close ( ) { } }

implementation: int retval = 0 ; try { if ( mOpenStream != null && mCloseStreamOnClose ) { mOpenStream . close ( ) ; } } catch ( IOException e ) { log . error ( "could not close stream {}: {}" , mOpenStream , e ) ; retval = - 1 ; } mOpenStream = null ; return retval ;


signature:
public class ReadableWritableChannelHandler { /** * { @ inheritDoc } */
public int open ( String url , int flags ) { } }

implementation: if ( mOpenStream != null ) { log . debug ( "attempting to open already open handler: {}" , mOpenStream ) ; return - 1 ; } switch ( flags ) { case URL_RDWR : log . debug ( "do not support read/write mode for Java IO Handlers" ) ; return - 1 ; case URL_WRONLY_MODE : mOpenStream = mWriteChannel ; if ( mOpenStream == null ) { log . error ( "No OutputStream specified for writing: {}" , url ) ; return - 1 ; } break ; case URL_RDONLY_MODE : mOpenStream = mReadChannel ; if ( mOpenStream == null ) { log . error ( "No InputStream specified for reading: {}" , url ) ; return - 1 ; } break ; default : log . error ( "Invalid flag passed to open: {}" , url ) ; return - 1 ; } return 0 ;


signature:
public class ReadableWritableChannelHandler { /** * { @ inheritDoc } */
public int read ( byte [ ] buf , int size ) { } }

implementation: int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof ReadableByteChannel ) ) return - 1 ; try { ReadableByteChannel channel = ( ReadableByteChannel ) mOpenStream ; ByteBuffer buffer = ByteBuffer . allocate ( size ) ; ret = channel . read ( buffer ) ; if ( ret > 0 ) { buffer . flip ( ) ; buffer . get ( buf , 0 , ret ) ; } return ret ; } catch ( IOException e ) { log . error ( "Got IO exception reading from channel: {}; {}" , mOpenStream , e ) ; return - 1 ; }


signature:
public class ReadableWritableChannelHandler { /** * { @ inheritDoc } */
public int write ( byte [ ] buf , int size ) { } }

implementation: if ( mOpenStream == null || ! ( mOpenStream instanceof WritableByteChannel ) ) return - 1 ; try { WritableByteChannel channel = ( WritableByteChannel ) mOpenStream ; ByteBuffer buffer = ByteBuffer . allocate ( size ) ; buffer . put ( buf , 0 , size ) ; buffer . flip ( ) ; return channel . write ( buffer ) ; } catch ( IOException e ) { log . error ( "Got error writing to file: {}; {}" , mOpenStream , e ) ; return - 1 ; }


signature:
public class HumbleIO { /** * Register a new protocol name for this factory that Humble . IO will use for
 * the given protocol .
 * A default factory for the protocol { @ value # DEFAULT _ PROTOCOL } will already
 * be registered . This just allows you to register the same factory under
 * different strings if you want .
 * < strong > NOTE : Protocol can only contain alpha characters . < / strong >
 * @ param protocolPrefix The protocol ( e . g . " yourapphandler " ) .
 * @ return The factory registered */
static HumbleIO registerFactory ( String protocolPrefix ) { } }

implementation: URLProtocolManager manager = URLProtocolManager . getManager ( ) ; manager . registerFactory ( protocolPrefix , mFactory ) ; return mFactory ;


signature:
public class HumbleIO { /** * Generates a unique name suitable for using in the map methods for the URL
 * parameter .
 * @ param src The object you want to generate a unique name for , or null if
 * you don ' t have one .
 * @ param extension an option extension to append to the generated URL .
 * @ return A unique name ( will be unique across time and space ) . */
static public String generateUniqueName ( Object src , String extension ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( UUID . randomUUID ( ) . toString ( ) ) ; if ( src != null ) { builder . append ( "-" ) ; builder . append ( src . getClass ( ) . getName ( ) ) ; builder . append ( "-" ) ; builder . append ( Integer . toHexString ( src . hashCode ( ) ) ) ; } if ( extension != null ) { builder . append ( extension ) ; } return builder . toString ( ) ;


signature:
public class HumbleIO { /** * Maps a { @ link IURLProtocolHandler } to a url that Humble can open .
 * { @ link # unmap ( String ) } will be called automatically after this URL is
 * opened .
 * @ param url the unique string to use for the mapping .
 * @ param handler the handler
 * @ return a string that is suitable for passing to { @ link Container } ' s open
 * methods . */
public static String map ( String url , IURLProtocolHandler handler ) { } }

implementation: return map ( url , handler , DEFAULT_UNMAP_URL_ON_OPEN ) ;


signature:
public class HumbleIO { /** * Maps a { @ link DataInput } object to a URL for use by Humble .
 * @ param input the { @ link DataInput }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( DataInput input ) { } }

implementation: return map ( generateUniqueName ( input ) , input , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link DataInput } object to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param input the { @ link DataInput }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , DataInput input ) { } }

implementation: return map ( url , input , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link DataOutput } object to a URL for use by Humble .
 * @ param output the { @ link DataOutput }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( DataOutput output ) { } }

implementation: return map ( generateUniqueName ( output ) , null , output , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link DataOutput } object to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param output the { @ link DataOutput }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , DataOutput output ) { } }

implementation: return map ( url , null , output , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link RandomAccessFile } object to a URL for use by Humble .
 * @ param file the { @ link RandomAccessFile }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( RandomAccessFile file ) { } }

implementation: return map ( generateUniqueName ( file ) , file , file , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link RandomAccessFile } object to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param file the { @ link RandomAccessFile }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , RandomAccessFile file ) { } }

implementation: return map ( url , file , file , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link ReadableByteChannel } to a URL for use by Humble .
 * @ param channel the { @ link ReadableByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( ReadableByteChannel channel ) { } }

implementation: return map ( generateUniqueName ( channel ) , channel , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link ReadableByteChannel } to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param channel the { @ link ReadableByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , ReadableByteChannel channel ) { } }

implementation: return map ( url , channel , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link WritableByteChannel } to a URL for use by Humble .
 * @ param channel the { @ link WritableByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( WritableByteChannel channel ) { } }

implementation: return map ( generateUniqueName ( channel ) , null , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link WritableByteChannel } to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param channel the { @ link WritableByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , WritableByteChannel channel ) { } }

implementation: return map ( url , null , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link ByteChannel } to a URL for use by Humble .
 * @ param channel the { @ link ByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( ByteChannel channel ) { } }

implementation: return map ( generateUniqueName ( channel ) , channel , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link ByteChannel } to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param channel the { @ link ByteChannel }
 * @ return a string that can be passed to { @ link Container } ' s open methods . */
public static String map ( String url , ByteChannel channel ) { } }

implementation: return map ( url , channel , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps an { @ link InputStream } to a URL for use by Humble .
 * @ param in the stream
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( InputStream in ) { } }

implementation: return map ( generateUniqueName ( in ) , in , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps an { @ link InputStream } to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param in the stream
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( String url , InputStream in ) { } }

implementation: return map ( url , in , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps an { @ link OutputStream } to a URL for use by Humble .
 * @ param out the stream
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( OutputStream out ) { } }

implementation: return map ( generateUniqueName ( out ) , null , out , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps an { @ link OutputStream } to a URL for use by Humble .
 * @ param url the URL to use .
 * @ param out the stream
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( String url , OutputStream out ) { } }

implementation: return map ( url , null , out , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ;


signature:
public class HumbleIO { /** * Maps a { @ link DataInput } or { @ link DataOutput } object to a URL for use by
 * Humble .
 * @ param url the url
 * @ param in the input to use
 * @ param out the output to use
 * @ param unmapOnOpen should we remove the mapping as soon as the resulting
 * handler is opened ?
 * @ param closeOnClose should we call { @ link Closeable # close ( ) } on the
 * underlying input or output objects when
 * { @ link IURLProtocolHandler # close ( ) } is called ( if supported by the
 * underlying object ) ?
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( String url , DataInput in , DataOutput out , boolean unmapOnOpen , boolean closeOnClose ) { } }

implementation: return map ( url , new DataInputOutputHandler ( in , out , closeOnClose ) ) ;


signature:
public class HumbleIO { /** * Maps an { @ link ReadableByteChannel } or { @ link WritableByteChannel } to a URL
 * for use by Humble .
 * @ param url the url
 * @ param in the input to use
 * @ param out the output to use
 * @ param unmapOnOpen should we remove the mapping as soon as the resulting
 * handler is opened ?
 * @ param closeOnClose should we call { @ link Closeable # close ( ) } on the
 * underlying input or output objects when
 * { @ link IURLProtocolHandler # close ( ) } is called ( if supported by the
 * underlying object ) ?
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( String url , ReadableByteChannel in , WritableByteChannel out , boolean unmapOnOpen , boolean closeOnClose ) { } }

implementation: return map ( url , new ReadableWritableChannelHandler ( in , out , closeOnClose ) ) ;


signature:
public class HumbleIO { /** * Maps an { @ link InputStream } or { @ link OutputStream } to a URL for use by
 * Humble .
 * @ param url the url
 * @ param in the input to use
 * @ param out the output to use
 * @ param unmapOnOpen should we remove the mapping as soon as the resulting
 * handler is opened ?
 * @ param closeOnClose should we call { @ link Closeable # close ( ) } on the
 * underlying input or output objects when
 * { @ link IURLProtocolHandler # close ( ) } is called ?
 * @ return Returns a URL that can be passed to Humble ' s { @ link Container } ' s
 * open method , and will result in IO being performed on the passed in
 * streams . */
public static String map ( String url , InputStream in , OutputStream out , boolean unmapOnOpen , boolean closeOnClose ) { } }

implementation: return map ( url , new InputOutputStreamHandler ( in , out , closeOnClose ) ) ;


signature:
public class HumbleIO { /** * Maps a { @ link IURLProtocolHandler } to a url that Humble can open .
 * @ param url the unique string to use for the mapping .
 * @ param handler the handler
 * @ param unmapUrlOnOpen if true , when Humble opens the
 * { @ link IURLProtocolHandler } , { @ link # unmap ( String ) } will be called
 * automatically .
 * @ return a string that is suitable for passing to { @ link Container } ' s open
 * methods . */
public static String map ( String url , IURLProtocolHandler handler , boolean unmapUrlOnOpen ) { } }

implementation: if ( mFactory . mapIO ( url , handler , unmapUrlOnOpen ) != null ) throw new RuntimeException ( "url is already mapped: " + url ) ; return DEFAULT_PROTOCOL + ":" + URLProtocolManager . getResourceFromURL ( url ) ;


signature:
public class HumbleIO { /** * Maps the given url or file name to the given { @ link IURLProtocolHandler } or
 * so that Humble calls to open the URL it will call back to the handler .
 * If you set unmapOnOpen to false , or you never actually open this mapping ,
 * then you must ensure that you call { @ link # unmapIO ( String ) } at some point
 * in time to remove the mapping , or we will hold onto references to the
 * handler you passed in .
 * @ param url A file or URL . If a URL , the protocol will be stripped off and
 * replaced with { @ link # DEFAULT _ PROTOCOL } when registering .
 * @ param handler An { @ link IURLProtocolHandler } for the url
 * @ param unmapUrlOnOpen If true , the handler will unmap itself after an
 * { @ link Container } opens the registered URL . If true , you do not
 * need to call { @ link # unmapIO ( String ) } for this url .
 * @ return The previous handler for this url , or null if none .
 * @ throws IllegalArgumentException if url is null or zero length
 * @ throws IllegalArgumentException if handler is null */
public IURLProtocolHandler mapIO ( String url , IURLProtocolHandler handler , boolean unmapUrlOnOpen ) { } }

implementation: { if ( url == null || url . length ( ) <= 0 ) throw new IllegalArgumentException ( "must pass in non-zero url" ) ; if ( handler == null ) { throw new IllegalArgumentException ( "must pass in a non null handler" ) ; } String streamName = URLProtocolManager . getResourceFromURL ( url ) ; RegistrationInformation tuple = new RegistrationInformation ( streamName , handler , unmapUrlOnOpen ) ; RegistrationInformation oldTuple = mURLs . putIfAbsent ( streamName , tuple ) ; return oldTuple == null ? null : oldTuple . getHandler ( ) ; }


signature:
public class HumbleIO { /** * Unmaps a registration between a URL and the underlying i / o objects .
 * If URL contains a protocol it is ignored when trying to find the matching
 * IO stream .
 * @ param url The stream name to unmap
 * @ return the { @ link IURLProtocolHandler } that had been registered for that
 * url , or null if none . */
public IURLProtocolHandler unmapIO ( String url ) { } }

implementation: if ( url == null || url . length ( ) <= 0 ) throw new IllegalArgumentException ( "must pass in non-zero url" ) ; String streamName = URLProtocolManager . getResourceFromURL ( url ) ; RegistrationInformation oldTuple = mURLs . remove ( streamName ) ; return oldTuple == null ? null : oldTuple . getHandler ( ) ;