public static int[] buildBoxOutMap(int picWidthInMbs, int picHeightInMbs, boolean changeDirection,
            int numberOfMbsInBox) {

        int picSizeInMbs = picWidthInMbs * picHeightInMbs;
        int[] groups = new int[picSizeInMbs];
        int changeDirectionInt = changeDirection ? 1 : 0;

        for (int i = 0; i < picSizeInMbs; i++)
            groups[i] = 1;

        int x = (picWidthInMbs - changeDirectionInt) / 2;
        int y = (picHeightInMbs - changeDirectionInt) / 2;
        int leftBound = x;
        int topBound = y;
        int rightBound = x;
        int bottomBound = y;
        int xDir = changeDirectionInt - 1;
        int yDir = changeDirectionInt;

        boolean mapUnitVacant = false;
        for (int k = 0; k < numberOfMbsInBox; k += (mapUnitVacant ? 1 : 0)) {
            int mbAddr = y * picWidthInMbs + x;
            mapUnitVacant = (groups[mbAddr] == 1);
            if (mapUnitVacant) {
                groups[mbAddr] = 0;
            }
            if (xDir == -1 && x == leftBound) {
                leftBound = Max(leftBound - 1, 0);
                x = leftBound;
                xDir = 0;
                yDir = 2 * changeDirectionInt - 1;
            } else if (xDir == 1 && x == rightBound) {
                rightBound = Min(rightBound + 1, picWidthInMbs - 1);
                x = rightBound;
                xDir = 0;
                yDir = 1 - 2 * changeDirectionInt;
            } else if (yDir == -1 && y == topBound) {
                topBound = Max(topBound - 1, 0);
                y = topBound;
                xDir = 1 - 2 * changeDirectionInt;
                yDir = 0;
            } else if (yDir == 1 && y == bottomBound) {
                bottomBound = Min(bottomBound + 1, picHeightInMbs - 1);
                y = bottomBound;
                xDir = 2 * changeDirectionInt - 1;
                yDir = 0;
            } else {
                x += xDir;
                y += yDir;
            }
        }

        return groups;
    }

public static int [ ] buildBoxOutMap ( int picWidthInMbs , int picHeightInMbs , boolean changeDirection , int numberOfMbsInBox ) { int picSizeInMbs = picWidthInMbs * picHeightInMbs ; int [ ] groups = new int [ picSizeInMbs ] ; int changeDirectionInt = changeDirection ? 1 : 0 ; for ( int i = 0 ; i < picSizeInMbs ; i ++ ) groups [ i ] = 1 ; int x = ( picWidthInMbs - changeDirectionInt ) / 2 ; int y = ( picHeightInMbs - changeDirectionInt ) / 2 ; int leftBound = x ; int topBound = y ; int rightBound = x ; int bottomBound = y ; int xDir = changeDirectionInt - 1 ; int yDir = changeDirectionInt ; boolean mapUnitVacant = false ; for ( int k = 0 ; k < numberOfMbsInBox ; k += ( mapUnitVacant ? 1 : 0 ) ) { int mbAddr = y * picWidthInMbs + x ; mapUnitVacant = ( groups [ mbAddr ] == 1 ) ; if ( mapUnitVacant ) { groups [ mbAddr ] = 0 ; } if ( xDir == - 1 && x == leftBound ) { leftBound = Max ( leftBound - 1 , 0 ) ; x = leftBound ; xDir = 0 ; yDir = 2 * changeDirectionInt - 1 ; } else if ( xDir == 1 && x == rightBound ) { rightBound = Min ( rightBound + 1 , picWidthInMbs - 1 ) ; x = rightBound ; xDir = 0 ; yDir = 1 - 2 * changeDirectionInt ; } else if ( yDir == - 1 && y == topBound ) { topBound = Max ( topBound - 1 , 0 ) ; y = topBound ; xDir = 1 - 2 * changeDirectionInt ; yDir = 0 ; } else if ( yDir == 1 && y == bottomBound ) { bottomBound = Min ( bottomBound + 1 , picHeightInMbs - 1 ) ; y = bottomBound ; xDir = 2 * changeDirectionInt - 1 ; yDir = 0 ; } else { x += xDir ; y += yDir ; } } return groups ; }

A boxout macroblock to slice group mapping. Only applicable when there's
exactly 2 slice groups. Slice group 1 is a background, while slice group
0 is a box in the middle of the frame.

@param picWidthInMbs
@param picHeightInMbs
@param changeDirection
@param numberOfMbsInBox
number of macroblocks in slice group 0
@return

A boxout macroblock to slice group mapping . Only applicable when there s exactly 2 slice groups . Slice group 1 is a background while slice group 0 is a box in the middle of the frame .


public static int[] buildWipeMap(int picWidthInMbs, int picHeightInMbs, int sizeOfUpperLeftGroup,
            boolean changeDirection) {

        int picSizeInMbs = picWidthInMbs * picHeightInMbs;
        int[] groups = new int[picSizeInMbs];
        int changeDirectionInt = changeDirection ? 1 : 0;

        int k = 0;
        for (int j = 0; j < picWidthInMbs; j++) {
            for (int i = 0; i < picHeightInMbs; i++) {
                int mbAddr = i * picWidthInMbs + j;
                if (k++ < sizeOfUpperLeftGroup) {
                    groups[mbAddr] = changeDirectionInt;
                } else {
                    groups[mbAddr] = 1 - changeDirectionInt;
                }
            }
        }

        return groups;
    }

public static int [ ] buildWipeMap ( int picWidthInMbs , int picHeightInMbs , int sizeOfUpperLeftGroup , boolean changeDirection ) { int picSizeInMbs = picWidthInMbs * picHeightInMbs ; int [ ] groups = new int [ picSizeInMbs ] ; int changeDirectionInt = changeDirection ? 1 : 0 ; int k = 0 ; for ( int j = 0 ; j < picWidthInMbs ; j ++ ) { for ( int i = 0 ; i < picHeightInMbs ; i ++ ) { int mbAddr = i * picWidthInMbs + j ; if ( k ++ < sizeOfUpperLeftGroup ) { groups [ mbAddr ] = changeDirectionInt ; } else { groups [ mbAddr ] = 1 - changeDirectionInt ; } } } return groups ; }

A macroblock to slice group map that fills frame column by column

@param picWidthInMbs
@param picHeightInMbs
@param sizeOfUpperLeftGroup
@param changeDirection
@return


protected static UL[] readULBatch(ByteBuffer _bb) {
        int count = _bb.getInt();
        _bb.getInt();
        UL[] result = new UL[count];
        for (int i = 0; i < count; i++) {
            result[i] = UL.read(_bb);
        }
        return result;
    }

protected static UL [ ] readULBatch ( ByteBuffer _bb ) { int count = _bb . getInt ( ) ; _bb . getInt ( ) ; UL [ ] result = new UL [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { result [ i ] = UL . read ( _bb ) ; } return result ; }

Utility method to read a batch of ULS

@param _bb
@return


protected static int[] readInt32Batch(ByteBuffer _bb) {
        int count = _bb.getInt();
        _bb.getInt();
        int[] result = new int[count];
        for (int i = 0; i < count; i++) {
            result[i] = _bb.getInt();
        }
        return result;
    }

protected static int [ ] readInt32Batch ( ByteBuffer _bb ) { int count = _bb . getInt ( ) ; _bb . getInt ( ) ; int [ ] result = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { result [ i ] = _bb . getInt ( ) ; } return result ; }

Utility method to read a batch of int32

@param _bb
@return


public static int calcMVPredictionMedian(int a, int b, int c, int d, boolean aAvb, boolean bAvb, boolean cAvb,
            boolean dAvb, int ref, int comp) {

        if (!cAvb) {
            c = d;
            cAvb = dAvb;
        }

        if (aAvb && !bAvb && !cAvb) {
            b = c = a;
            bAvb = cAvb = aAvb;
        }

        a = aAvb ? a : NULL_VECTOR;
        b = bAvb ? b : NULL_VECTOR;
        c = cAvb ? c : NULL_VECTOR;

        if (mvRef(a) == ref && mvRef(b) != ref && mvRef(c) != ref)
            return mvC(a, comp);
        else if (mvRef(b) == ref && mvRef(a) != ref && mvRef(c) != ref)
            return mvC(b, comp);
        else if (mvRef(c) == ref && mvRef(a) != ref && mvRef(b) != ref)
            return mvC(c, comp);

        return mvC(a, comp) + mvC(b, comp) + mvC(c, comp) - min(mvC(a, comp), mvC(b, comp), mvC(c, comp))
                - max(mvC(a, comp), mvC(b, comp), mvC(c, comp));
    }

public static int calcMVPredictionMedian ( int a , int b , int c , int d , boolean aAvb , boolean bAvb , boolean cAvb , boolean dAvb , int ref , int comp ) { if ( ! cAvb ) { c = d ; cAvb = dAvb ; } if ( aAvb && ! bAvb && ! cAvb ) { b = c = a ; bAvb = cAvb = aAvb ; } a = aAvb ? a : NULL_VECTOR ; b = bAvb ? b : NULL_VECTOR ; c = cAvb ? c : NULL_VECTOR ; if ( mvRef ( a ) == ref && mvRef ( b ) != ref && mvRef ( c ) != ref ) return mvC ( a , comp ) ; else if ( mvRef ( b ) == ref && mvRef ( a ) != ref && mvRef ( c ) != ref ) return mvC ( b , comp ) ; else if ( mvRef ( c ) == ref && mvRef ( a ) != ref && mvRef ( b ) != ref ) return mvC ( c , comp ) ; return mvC ( a , comp ) + mvC ( b , comp ) + mvC ( c , comp ) - min ( mvC ( a , comp ) , mvC ( b , comp ) , mvC ( c , comp ) ) - max ( mvC ( a , comp ) , mvC ( b , comp ) , mvC ( c , comp ) ) ; }

Calculates median prediction
@param a, b, c and d are packed motion vectors


public EncodedFrame encodeFrame(Picture pic, ByteBuffer _out) {
        if (pic.getColor() != ColorSpace.YUV420J)
            throw new IllegalArgumentException("Input picture color is not supported: " + pic.getColor());

        if (frameNumber >= keyInterval) {
            frameNumber = 0;
        }

        SliceType sliceType = frameNumber == 0 ? SliceType.I : SliceType.P;
        boolean idr = frameNumber == 0;

        ByteBuffer data = doEncodeFrame(pic, _out, idr, frameNumber++, sliceType);
        return new EncodedFrame(data, idr);
    }

Encode this picture into h.264 frame. Frame type will be selected by
encoder.

Encode this picture into h . 264 frame . Frame type will be selected by encoder .


public ByteBuffer encodeIDRFrame(Picture pic, ByteBuffer _out) {
        frameNumber = 0;
        return doEncodeFrame(pic, _out, true, frameNumber, SliceType.I);
    }

public ByteBuffer encodeIDRFrame ( Picture pic , ByteBuffer _out ) { frameNumber = 0 ; return doEncodeFrame ( pic , _out , true , frameNumber , SliceType . I ) ; }

Encode this picture as an IDR frame. IDR frame starts a new independently
decodeable video sequence

@param pic
@param _out
@return

Encode this picture as an IDR frame . IDR frame starts a new independently decodeable video sequence


public ByteBuffer encodePFrame(Picture pic, ByteBuffer _out) {
        frameNumber++;
        return doEncodeFrame(pic, _out, true, frameNumber, SliceType.P);
    }

public ByteBuffer encodePFrame ( Picture pic , ByteBuffer _out ) { frameNumber ++ ; return doEncodeFrame ( pic , _out , true , frameNumber , SliceType . P ) ; }

Encode this picture as a P-frame. P-frame is an frame predicted from one
or more of the previosly decoded frame and is usually 10x less in size
then the IDR frame.

@param pic
@param _out
@return

Encode this picture as a P - frame . P - frame is an frame predicted from one or more of the previosly decoded frame and is usually 10x less in size then the IDR frame .


public java.util.Collection<Codec.ID> getSupportedCodecs()
   {
     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;
   }

public
java
.
util
.
Collection
<
Codec
.
ID
>
getSupportedCodecs
(
)
{
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
;
}

Returns a list of all codecs supported for this Object.

<p>

If this object hasn't been set up for output, then
we return null.

</p>

@return A list of supported codecs, in decreasing preferred order.

Returns a list of all codecs supported for this Object .


public java.util.Collection<Long> getSupportedTags()
   {
     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;
   }

public
java
.
util
.
Collection
<
Long
>
getSupportedTags
(
)
{
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
;
}

Returns a list of all codec tags supported for this container.

<p>

If this object hasn't been set up for output, then
we return null.

</p>

@return A list of supported codec tags, in decreasing preferred order.

Returns a list of all codec tags supported for this container .


final boolean addReference(final JNIReference ref)
  {
    /* 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;
  }

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.

Add a reference to the set of references we ll collect .


void gcInternal()
  {
    JNIReference ref = null;
    while ((ref = (JNIReference) mRefQueue.poll()) != null)
    {
      ref.delete();
    }
  }

void gcInternal ( ) { JNIReference ref = null ; while ( ( ref = ( JNIReference ) mRefQueue . poll ( ) ) != null ) { ref . delete ( ) ; } }


final public void flush()
  {
    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();
    }
  }

Internal Only.

Immediately frees all active objects in the system. Do not call unless you
REALLY know what you're doing.


@SuppressWarnings("deprecation")
  public static void load(String appname, JNILibrary library) {
    // 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());
      }
    }
  }

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.

Load the given library into the given application .


private boolean unpackLibrary(String path) {
    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;
  }

Looks for a URL in a classpath, and if found, unpacks it

Looks for a URL in a classpath and if found unpacks it


private static void deleteTemporaryFiles() {
    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();
    }
  }

private static void deleteTemporaryFiles ( ) { 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 ( ) ; } }

Finds all ".humble" temp files in the temp directory and nukes them.

Finds all . humble temp files in the temp directory and nukes them .


public static AudioChannel.Layout getDefaultLayout(int numChannels) {
    return AudioChannel.Layout.swigToEnum(VideoJNI.AudioChannel_getDefaultLayout(numChannels));
  }

public static AudioChannel . Layout getDefaultLayout ( int numChannels ) { return AudioChannel . Layout . swigToEnum ( VideoJNI . AudioChannel_getDefaultLayout ( numChannels ) ) ; }

Return default channel layout for a given number of channels.

Return default channel layout for a given number of channels .


public static AudioChannel.Type getChannelFromLayoutAtIndex(AudioChannel.Layout layout, int index) {
    return AudioChannel.Type.swigToEnum(VideoJNI.AudioChannel_getChannelFromLayoutAtIndex(layout.swigValue(), index));
  }

Get the channel with the given index in channel_layout.

Get the channel with the given index in channel_layout .


public static MediaPacket make() {
    long cPtr = VideoJNI.MediaPacket_make__SWIG_0();
    return (cPtr == 0) ? null : new MediaPacket(cPtr, false);
  }

public static MediaPacket make ( ) { long cPtr = VideoJNI . MediaPacket_make__SWIG_0 ( ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


public static String getVersionInfo() {
    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();
  }

public
static
String
getVersionInfo
(
)
{
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
(
)
;
}

Prints the version of this library to System.out along with
some information on what this jar is.

Prints the version of this library to System . out along with some information on what this jar is .


public static Rational getDefaultTimeBase() {
    long cPtr = VideoJNI.Global_getDefaultTimeBase();
    return (cPtr == 0) ? null : new Rational(cPtr, false);
  }

public static Rational getDefaultTimeBase ( ) { long cPtr = VideoJNI . Global_getDefaultTimeBase ( ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }

The default timebase used by media if not otherwise specified.

The default timebase used by media if not otherwise specified .


public static Demuxer make() {
    long cPtr = VideoJNI.Demuxer_make();
    return (cPtr == 0) ? null : new Demuxer(cPtr, false);
  }

public static Demuxer make ( ) { long cPtr = VideoJNI . Demuxer_make ( ) ; return ( cPtr == 0 ) ? null : new Demuxer ( cPtr , false ) ; }


private static void playVideo(String filename) throws InterruptedException, IOException {
    /*
     * Start by creating a container object, in this case a demuxer since
     * we are reading, to get video data from.
     */
    Demuxer demuxer = Demuxer.make();

    /*
     * Open the demuxer with the filename passed on.
     */
    demuxer.open(filename, null, false, true, null, null);

    /*
     * Query how many streams the call to open found
     */
    int numStreams = demuxer.getNumStreams();

    /*
     * Iterate through the streams to find the first video stream
     */
    int videoStreamId = -1;
    long streamStartTime = Global.NO_PTS;
    Decoder videoDecoder = null;
    for(int i = 0; i < numStreams; i++)
    {
      final DemuxerStream stream = demuxer.getStream(i);
      streamStartTime = stream.getStartTime();
      final Decoder decoder = stream.getDecoder();
      if (decoder != null && decoder.getCodecType() == MediaDescriptor.Type.MEDIA_VIDEO) {
        videoStreamId = i;
        videoDecoder = decoder;
        // stop at the first one.
        break;
      }
    }
    if (videoStreamId == -1)
      throw new RuntimeException("could not find video stream in container: "+filename);

    /*
     * Now we have found the audio stream in this file.  Let's open up our decoder so it can
     * do work.
     */
    videoDecoder.open(null, null);

    final MediaPicture picture = MediaPicture.make(
        videoDecoder.getWidth(),
        videoDecoder.getHeight(),
        videoDecoder.getPixelFormat());

    /** A converter object we'll use to convert the picture in the video to a BGR_24 format that Java Swing
     * can work with. You can still access the data directly in the MediaPicture if you prefer, but this
     * abstracts away from this demo most of that byte-conversion work. Go read the source code for the
     * converters if you're a glutton for punishment.
     */
    final MediaPictureConverter converter =
        MediaPictureConverterFactory.createConverter(
            MediaPictureConverterFactory.HUMBLE_BGR_24,
            picture);
    BufferedImage image = null;

    /**
     * This is the Window we will display in. See the code for this if you're curious, but to keep this demo clean
     * we're 'simplifying' Java AWT UI updating code. This method just creates a single window on the UI thread, and blocks
     * until it is displayed.
     */
    final ImageFrame window = ImageFrame.make();
    if (window == null) {
      throw new RuntimeException("Attempting this demo on a headless machine, and that will not work. Sad day for you.");
    }

    /**
     * Media playback, like comedy, is all about timing. Here we're going to introduce very very basic
     * timing. This code is deliberately kept simple (i.e. doesn't worry about A/V drift, garbage collection pause time, etc.)
     * because that will quickly make things more complicated.
     *
     * But the basic idea is there are two clocks:
     *

     *
Player Clock: The time that the player sees (relative to the system clock).

     *
Stream Clock: Each stream has its own clock, and the ticks are measured in units of time-bases

     *

     *
     * And we need to convert between the two units of time. Each MediaPicture and MediaAudio object have associated
     * time stamps, and much of the complexity in video players goes into making sure the right picture (or sound) is
     * seen (or heard) at the right time. This is actually very tricky and many folks get it wrong -- watch enough
     * Netflix and you'll see what I mean -- audio and video slightly out of sync. But for this demo, we're erring for
     * 'simplicity' of code, not correctness. It is beyond the scope of this demo to make a full fledged video player.
     */

    // Calculate the time BEFORE we start playing.
    long systemStartTime = System.nanoTime();
    // Set units for the system time, which because we used System.nanoTime will be in nanoseconds.
    final Rational systemTimeBase = Rational.make(1, 1000000000);
    // All the MediaPicture objects decoded from the videoDecoder will share this timebase.
    final Rational streamTimebase = videoDecoder.getTimeBase();

    /**
     * Now, we start walking through the container looking at each packet. This
     * is a decoding loop, and as you work with Humble you'll write a lot
     * of these.
     *
     * Notice how in this loop we reuse all of our objects to avoid
     * reallocating them. Each call to Humble resets objects to avoid
     * unnecessary reallocation.
     */
    final MediaPacket packet = MediaPacket.make();
    while(demuxer.read(packet) >= 0) {
      /**
       * Now we have a packet, let's see if it belongs to our video stream
       */
      if (packet.getStreamIndex() == videoStreamId)
      {
        /**
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in decoding speak).  So, we may need to call decode  multiple
         * times at different offsets in the packet's data.  We capture that here.
         */
        int offset = 0;
        int bytesRead = 0;
        do {
          bytesRead += videoDecoder.decode(picture, packet, offset);
          if (picture.isComplete()) {
            image = displayVideoAtCorrectTime(streamStartTime, picture,
                converter, image, window, systemStartTime, systemTimeBase,
                streamTimebase);
          }
          offset += bytesRead;
        } while (offset < packet.getSize());
      }
    }

    // Some video decoders (especially advanced ones) will cache
    // video data before they begin decoding, so when you are done you need
    // to flush them. The convention to flush Encoders or Decoders in Humble Video
    // is to keep passing in null until incomplete samples or packets are returned.
    do {
      videoDecoder.decode(picture, null, 0);
      if (picture.isComplete()) {
        image = displayVideoAtCorrectTime(streamStartTime, picture, converter,
            image, window, systemStartTime, systemTimeBase, streamTimebase);
      }
    } while (picture.isComplete());

    // It is good practice to close demuxers when you're done to free
    // up file handles. Humble will EVENTUALLY detect if nothing else
    // references this demuxer and close it then, but get in the habit
    // of cleaning up after yourself, and your future girlfriend/boyfriend
    // will appreciate it.
    demuxer.close();

    // similar with the demuxer, for the windowing system, clean up after yourself.
    window.dispose();
  }

Opens a file, and plays the video from it on a screen at the right rate.
@param filename The file or URL to play.

Opens a file and plays the video from it on a screen at the right rate .


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 {
    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;
  }

Takes the video picture and displays it at the right time.

Takes the video picture and displays it at the right time .


public static CodecDescriptor make(Codec.ID id) {
    long cPtr = VideoJNI.CodecDescriptor_make(id.swigValue());
    return (cPtr == 0) ? null : new CodecDescriptor(cPtr, false);
  }

public static CodecDescriptor make ( Codec . ID id ) { long cPtr = VideoJNI . CodecDescriptor_make ( id . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new CodecDescriptor ( cPtr , false ) ; }


public static void printOption(java.io.PrintStream stream,
      Configurable configObj, Property prop)
  {
    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());
  }

public
static
void
printOption
(
java
.
io
.
PrintStream
stream
,
Configurable
configObj
,
Property
prop
)
{
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
(
)
==
"no help available"
:
prop
.
getHelp
(
)
)
;
}

Print information about the property on the configurable object.

@param stream stream to print to
@param configObj configurable object
@param prop property on object

Print information about the property on the configurable object .


static HumbleIO registerFactory(String protocolPrefix)
  {
    URLProtocolManager manager = URLProtocolManager.getManager();
    manager.registerFactory(protocolPrefix, mFactory);
    return mFactory;
  }

static HumbleIO registerFactory ( String protocolPrefix ) { URLProtocolManager manager = URLProtocolManager . getManager ( ) ; manager . registerFactory ( protocolPrefix , mFactory ) ; return mFactory ; }

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.

NOTE: Protocol can only contain alpha characters.

@param protocolPrefix The protocol (e.g. "yourapphandler").
@return The factory registered

Register a new protocol name for this factory that Humble . IO will use for the given protocol .


static public String generateUniqueName(Object src, String extension)
  {
    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();
  }

static public String generateUniqueName ( Object src , String extension ) { 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 ( ) ; }

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).

Generates a unique name suitable for using in the map methods for the URL parameter .


public static MediaAudioResampler make(AudioChannel.Layout outLayout, int outSampleRate, AudioFormat.Type outFormat, AudioChannel.Layout inLayout, int inSampleRate, AudioFormat.Type inFormat) {
    long cPtr = VideoJNI.MediaAudioResampler_make(outLayout.swigValue(), outSampleRate, outFormat.swigValue(), inLayout.swigValue(), inSampleRate, inFormat.swigValue());
    return (cPtr == 0) ? null : new MediaAudioResampler(cPtr, false);
  }

public static MediaAudioResampler make ( AudioChannel . Layout outLayout , int outSampleRate , AudioFormat . Type outFormat , AudioChannel . Layout inLayout , int inSampleRate , AudioFormat . Type inFormat ) { long cPtr = VideoJNI . MediaAudioResampler_make ( outLayout . swigValue ( ) , outSampleRate , outFormat . swigValue ( ) , inLayout . swigValue ( ) , inSampleRate , inFormat . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new MediaAudioResampler ( cPtr , false ) ; }


public java.util.Collection<Rational>
  getSupportedVideoFrameRates()
  {
    java.util.List<Rational> retval =
      new java.util.LinkedList<Rational>();
    int count = getNumSupportedVideoFrameRates();
    for(int i=0;i<count;i++)
    {
      Rational rate = getSupportedVideoFrameRate(i);
      if (rate != null)
        retval.add(rate);
    }
    return retval;
  }

public java . util . Collection < Rational > getSupportedVideoFrameRates ( ) { java . util . List < Rational > retval = new java . util . LinkedList < Rational > ( ) ; int count = getNumSupportedVideoFrameRates ( ) ; for ( int i = 0 ; i < count ; i ++ ) { Rational rate = getSupportedVideoFrameRate ( i ) ; if ( rate != null ) retval . add ( rate ) ; } return retval ; }

Returns a list of supported frame-rates this codec can encode
video to.

<p>

Not all codecs support reporting this, in which case the returned list
will be empty.

</p>

@return a list

Returns a list of supported frame - rates this codec can encode video to .


public java.util.Collection<PixelFormat.Type>
  getSupportedVideoPixelFormats()
  {
    java.util.List<PixelFormat.Type> retval =
      new java.util.LinkedList<PixelFormat.Type>();
    int count = getNumSupportedVideoPixelFormats();
    for(int i=0;i<count;i++)
    {
      PixelFormat.Type type = getSupportedVideoPixelFormat(i);
      if (type != null && type != PixelFormat.Type.PIX_FMT_NONE)
        retval.add(type);
    }
    return retval;
  }

public java . util . Collection < PixelFormat . Type > getSupportedVideoPixelFormats ( ) { java . util . List < PixelFormat . Type > retval = new java . util . LinkedList < PixelFormat . Type > ( ) ; int count = getNumSupportedVideoPixelFormats ( ) ; for ( int i = 0 ; i < count ; i ++ ) { PixelFormat . Type type = getSupportedVideoPixelFormat ( i ) ; if ( type != null && type != PixelFormat . Type . PIX_FMT_NONE ) retval . add ( type ) ; } return retval ; }

Returns a list of supported pixel formats this codec can encode
video in.

<p>

Not all codecs support reporting this, in which case the returned list
will be empty.

</p>

@return a list

Returns a list of supported pixel formats this codec can encode video in .


public java.util.Collection<Integer>
  getSupportedAudioSampleRates()
  {
    java.util.List<Integer> retval =
      new java.util.LinkedList<Integer>();
    int count = getNumSupportedAudioSampleRates();
    for(int i=0;i<count;i++)
    {
      int rate = getSupportedAudioSampleRate(i);
      if (rate != 0)
        retval.add(rate);
    }
    return retval;
  }

public java . util . Collection < Integer > getSupportedAudioSampleRates ( ) { java . util . List < Integer > retval = new java . util . LinkedList < Integer > ( ) ; int count = getNumSupportedAudioSampleRates ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int rate = getSupportedAudioSampleRate ( i ) ; if ( rate != 0 ) retval . add ( rate ) ; } return retval ; }

Returns a list of supported audio sample rates this codec can encode
audio in.

<p>

Not all codecs support reporting this, in which case the returned list
will be empty.

</p>

@return a list

Returns a list of supported audio sample rates this codec can encode audio in .


public java.util.Collection<AudioFormat.Type>
  getSupportedAudioFormats()
  {
    java.util.List<AudioFormat.Type> retval =
      new java.util.LinkedList<AudioFormat.Type>();
    int count = getNumSupportedAudioFormats();
    for(int i=0;i<count;i++)
    {
      AudioFormat.Type fmt = getSupportedAudioFormat(i);
      if (fmt != null && fmt != AudioFormat.Type.SAMPLE_FMT_NONE)
        retval.add(fmt);
    }
    return retval;
  }

public java . util . Collection < AudioFormat . Type > getSupportedAudioFormats ( ) { java . util . List < AudioFormat . Type > retval = new java . util . LinkedList < AudioFormat . Type > ( ) ; int count = getNumSupportedAudioFormats ( ) ; for ( int i = 0 ; i < count ; i ++ ) { AudioFormat . Type fmt = getSupportedAudioFormat ( i ) ; if ( fmt != null && fmt != AudioFormat . Type . SAMPLE_FMT_NONE ) retval . add ( fmt ) ; } return retval ; }

Returns a list of supported audio sample formats this codec can encode
audio in.

<p>

Not all codecs support reporting this, in which case the returned list
will be empty.

</p>

@return a list

Returns a list of supported audio sample formats this codec can encode audio in .


public java.util.Collection<AudioChannel.Layout>
  getSupportedAudioChannelLayouts()
  {
    java.util.List<AudioChannel.Layout> retval =
      new java.util.LinkedList<AudioChannel.Layout>();
    int count = getNumSupportedAudioChannelLayouts();
    for(int i=0;i<count;i++)
    {
      AudioChannel.Layout layout = getSupportedAudioChannelLayout(i);
      if (layout != AudioChannel.Layout.CH_LAYOUT_UNKNOWN)
        retval.add(layout);
    }
    return retval;
  }

public java . util . Collection < AudioChannel . Layout > getSupportedAudioChannelLayouts ( ) { java . util . List < AudioChannel . Layout > retval = new java . util . LinkedList < AudioChannel . Layout > ( ) ; int count = getNumSupportedAudioChannelLayouts ( ) ; for ( int i = 0 ; i < count ; i ++ ) { AudioChannel . Layout layout = getSupportedAudioChannelLayout ( i ) ; if ( layout != AudioChannel . Layout . CH_LAYOUT_UNKNOWN ) retval . add ( layout ) ; } return retval ; }

Returns a list of supported audio channel layouts this codec can encode
audio in.

<p>

Not all codecs support reporting this, in which case the returned list
will be empty.

</p>

@return a list

Returns a list of supported audio channel layouts this codec can encode audio in .


public void setFlag(Coder.Flag flag, boolean value) {
    VideoJNI.Coder_setFlag(swigCPtr, this, flag.swigValue(), value);
  }

public void setFlag ( Coder . Flag flag , boolean value ) { VideoJNI . Coder_setFlag ( swigCPtr , this , flag . swigValue ( ) , value ) ; }


public void setFlag2(Coder.Flag2 flag, boolean value) {
    VideoJNI.Coder_setFlag2(swigCPtr, this, flag.swigValue(), value);
  }

public void setFlag2 ( Coder . Flag2 flag , boolean value ) { VideoJNI . Coder_setFlag2 ( swigCPtr , this , flag . swigValue ( ) , value ) ; }


public Decoder getDecoder() {
    long cPtr = VideoJNI.DemuxerStream_getDecoder(swigCPtr, this);
    return (cPtr == 0) ? null : new Decoder(cPtr, false);
  }

public Decoder getDecoder ( ) { long cPtr = VideoJNI . DemuxerStream_getDecoder ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Decoder ( cPtr , false ) ; }

Get the decoder that can decode the information in this Demuxer stream.

Get the decoder that can decode the information in this Demuxer stream .


public Demuxer getDemuxer() {
    long cPtr = VideoJNI.DemuxerStream_getDemuxer(swigCPtr, this);
    return (cPtr == 0) ? null : new Demuxer(cPtr, false);
  }

public Demuxer getDemuxer ( ) { long cPtr = VideoJNI . DemuxerStream_getDemuxer ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Demuxer ( cPtr , false ) ; }

Get the Demuxer this DemuxerStream belongs to.

Get the Demuxer this DemuxerStream belongs to .


public static java.util.Collection<MuxerFormat>
  getFormats()
  {
    java.util.Collection<MuxerFormat> retval =
      new java.util.HashSet<MuxerFormat>();
    int count = getNumFormats();
    for(int i = 0; i< count;++i)
    {
      MuxerFormat fmt = getFormat(i);
      if (fmt != null)
        retval.add(fmt);
    }
    return retval;
  }

public static java . util . Collection < MuxerFormat > getFormats ( ) { java . util . Collection < MuxerFormat > retval = new java . util . HashSet < MuxerFormat > ( ) ; int count = getNumFormats ( ) ; for ( int i = 0 ; i < count ; ++ i ) { MuxerFormat fmt = getFormat ( i ) ; if ( fmt != null ) retval . add ( fmt ) ; } return retval ; }

Return a collection of all output formats installed on this system.
@return the list.

Return a collection of all output formats installed on this system .


public static FilterGraph make() {
    long cPtr = VideoJNI.FilterGraph_make();
    return (cPtr == 0) ? null : new FilterGraph(cPtr, false);
  }

public static FilterGraph make ( ) { long cPtr = VideoJNI . FilterGraph_make ( ) ; return ( cPtr == 0 ) ? null : new FilterGraph ( cPtr , false ) ; }


public BitStreamFilterType getType() {
    long cPtr = VideoJNI.BitStreamFilter_getType(swigCPtr, this);
    return (cPtr == 0) ? null : new BitStreamFilterType(cPtr, false);
  }

public BitStreamFilterType getType ( ) { long cPtr = VideoJNI . BitStreamFilter_getType ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new BitStreamFilterType ( cPtr , false ) ; }


public java.nio.ByteBuffer getByteBuffer(int offset, int length)
  {
    return getByteBuffer(offset, length, null);
  }

public java . nio . ByteBuffer getByteBuffer ( int offset , int length ) { return getByteBuffer ( offset , length , null ) ; }

Returns up to length bytes, starting at offset in the underlying
buffer we're managing.

The buffer position, mark are initialized to zero and limit
is set to the maximum capacity of this buffer.  For some
Buffer contents, the actual usable data in this buffer will
be less that the limit.

If you want to control exactly when the underlying memory
beyind the returned {@link java.nio.ByteBuffer} is released,
use {@link #getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)}.

@see #getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)

Returns up to length bytes starting at offset in the underlying buffer we re managing .


public static AudioFrame make(final AudioFormat audioFormat) {
    try {
      return new AudioFrame(audioFormat);
    } catch (LineUnavailableException e) {
      log.error("Could not get audio data line: {}", e.getMessage());
      return null;
    }
  }

public
static
AudioFrame
make
(
final
AudioFormat
audioFormat
)
{
try
{
return
new
AudioFrame
(
audioFormat
)
;
}
catch
(
LineUnavailableException
e
)
{
log
.
error
(
"Could not get audio data line: {}"
,
e
.
getMessage
(
)
)
;
return
;
}
}

Get a connection to the speaker, if available.
@param audioFormat The java audio format that we will use.
@return A new audio format, or null if we cannot create one.

Get a connection to the speaker if available .


protected static MediaPicture resample(MediaPicture input,
    MediaPictureResampler resampler)
  {
    // create new picture object

    MediaPicture output = MediaPicture.make(
      resampler.getOutputWidth(),
      resampler.getOutputHeight(),
      resampler.getOutputFormat());
    return resample(output, input, resampler);
  }

protected
static
MediaPicture
resample
(
MediaPicture
input
,
MediaPictureResampler
resampler
)
{
// create new picture object
MediaPicture
output
=
MediaPicture
.
make
(
resampler
.
getOutputWidth
(
)
,
resampler
.
getOutputHeight
(
)
,
resampler
.
getOutputFormat
(
)
)
;
return
resample
(
output
,
input
,
resampler
)
;
}

Re-sample a picture.

@param picture1 the picture to re-sample
@param resampler the picture re-samper to use

@throws RuntimeException if could not re-sample picture


protected void validateImage(BufferedImage image)
  {
    // if the image is NULL, throw up

    if (image == null)
      throw new IllegalArgumentException("The passed image is NULL.");

    // if image is not the correct type, throw up

    if (image.getType() != getImageType())
      throw new IllegalArgumentException(
        "The passed image is of type #" + image.getType() +
        " but is required to be of BufferedImage type #" +
        getImageType() + ".");
  }

Test that the passed image is valid and conforms to the
converters specifications.

@param image the image to test

@throws IllegalArgumentException if the passed {@link
BufferedImage} is NULL;
@throws IllegalArgumentException if the passed {@link
BufferedImage} is not the correct type. See {@link
#getImageType}.

Test that the passed image is valid and conforms to the converters specifications .


protected void validatePicture(MediaPicture picture)
  {
    // if the picture is NULL, throw up

    if (picture == null)
      throw new IllegalArgumentException("The picture is NULL.");

    // if the picture is not complete, throw up

    if (!picture.isComplete())
      throw new IllegalArgumentException("The picture is not complete.");

    // if the picture is an invalid type throw up

    PixelFormat.Type type = picture.getFormat();
    if ((type != getPictureType()) && (willResample() &&
        type != mToImageResampler.getOutputFormat()))
      throw new IllegalArgumentException(
        "Picture is of type: " + type + ", but must be " +
        getPictureType() + (willResample()
          ? " or " + mToImageResampler.getOutputFormat()
          : "") +
        ".");
  }

Test that the passed picture is valid and conforms to the
converters specifications.

@param picture the picture to test

@throws IllegalArgumentException if the passed {@link
MediaPicture} is NULL;
@throws IllegalArgumentException if the passed {@link
MediaPicture} is not complete.
@throws IllegalArgumentException if the passed {@link
MediaPicture} is not the correct type.

Test that the passed picture is valid and conforms to the converters specifications .


public FilterGraph getFilterGraph() {
    long cPtr = VideoJNI.FilterLink_getFilterGraph(swigCPtr, this);
    return (cPtr == 0) ? null : new FilterGraph(cPtr, false);
  }

public FilterGraph getFilterGraph ( ) { long cPtr = VideoJNI . FilterLink_getFilterGraph ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new FilterGraph ( cPtr , false ) ; }

Get the FilterGraph this FilterLink belongs to.

Get the FilterGraph this FilterLink belongs to .


public KeyValueBag getMetaData() {
    long cPtr = VideoJNI.MediaRaw_getMetaData(swigCPtr, this);
    return (cPtr == 0) ? null : new KeyValueBag(cPtr, false);
  }

public KeyValueBag getMetaData ( ) { long cPtr = VideoJNI . MediaRaw_getMetaData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new KeyValueBag ( cPtr , false ) ; }

Get any meta-data associated with this media item

Get any meta - data associated with this media item


public static CPUArch getCPUArch(String javaCPU)
  {
    final CPUArch javaArch;
    final String javaCPUArch = javaCPU != null ? javaCPU.toLowerCase() : "";

    // first parse the java arch
    if (javaCPUArch.startsWith("x86_64") ||
        javaCPUArch.startsWith("amd64") ||
        javaCPUArch.startsWith("ia64")) {
      javaArch = CPUArch.X86_64;
    } else if (
        javaCPUArch.startsWith("ppc64") ||
        javaCPUArch.startsWith("powerpc64")
        ) {
      javaArch = CPUArch.PPC64;
    } else if (
        javaCPUArch.startsWith("ppc") ||
        javaCPUArch.startsWith("powerpc")
        ) {
      javaArch = CPUArch.PPC;
    } else if (
        javaCPUArch.contains("86")
        )
    {
      javaArch = CPUArch.X86;
    } else {
      javaArch = CPUArch.UNKNOWN;
    }
    return javaArch;
  }

public
static
CPUArch
getCPUArch
(
String
javaCPU
)
{
final
CPUArch
javaArch
;
final
String
javaCPUArch
=
javaCPU
!=
javaCPU
.
toLowerCase
(
)
:
""
;
// first parse the java arch
if
(
javaCPUArch
.
startsWith
(
"x86_64"
)
||
javaCPUArch
.
startsWith
(
"amd64"
)
||
javaCPUArch
.
startsWith
(
"ia64"
)
)
{
javaArch
=
CPUArch
.
X86_64
;
}
else
if
(
javaCPUArch
.
startsWith
(
"ppc64"
)
||
javaCPUArch
.
startsWith
(
"powerpc64"
)
)
{
javaArch
=
CPUArch
.
PPC64
;
}
else
if
(
javaCPUArch
.
startsWith
(
"ppc"
)
||
javaCPUArch
.
startsWith
(
"powerpc"
)
)
{
javaArch
=
CPUArch
.
PPC
;
}
else
if
(
javaCPUArch
.
contains
(
"86"
)
)
{
javaArch
=
CPUArch
.
X86
;
}
else
{
javaArch
=
CPUArch
.
UNKNOWN
;
}
return
javaArch
;
}

Get the CPU architecture based on the passed in javaCPUArch specifier.

The string should be of a format returned from {@link System#getProperty(String)}
for the property "os.arch".

@param javaCPU the string to parse
@return the CPU architecture
@see System#getProperty(String)

Get the CPU architecture based on the passed in javaCPUArch specifier .


public static CPUArch getCPUArchFromGNUString(String gnuString)
  {
    final String nativeCpu = gnuString.toLowerCase();
    final CPUArch nativeArch;
    // then the native arch
    if (nativeCpu.startsWith("x86_64") ||
        nativeCpu.startsWith("amd64") ||
        nativeCpu.startsWith("ia64"))
      nativeArch = CPUArch.X86_64;
    else if (
        nativeCpu.startsWith("ppc64") ||
        nativeCpu.startsWith("powerpc64")
        )
      nativeArch = CPUArch.PPC64;
    else if (
        nativeCpu.startsWith("ppc") ||
        nativeCpu.startsWith("powerpc")
        )
      nativeArch = CPUArch.PPC;
    else if (
        nativeCpu.contains("86")
        )
      nativeArch = CPUArch.X86;
    else
      nativeArch = CPUArch.UNKNOWN;

    return nativeArch;
  }

public
static
CPUArch
getCPUArchFromGNUString
(
String
gnuString
)
{
final
String
nativeCpu
=
gnuString
.
toLowerCase
(
)
;
final
CPUArch
nativeArch
;
// then the native arch
if
(
nativeCpu
.
startsWith
(
"x86_64"
)
||
nativeCpu
.
startsWith
(
"amd64"
)
||
nativeCpu
.
startsWith
(
"ia64"
)
)
nativeArch
=
CPUArch
.
X86_64
;
else
if
(
nativeCpu
.
startsWith
(
"ppc64"
)
||
nativeCpu
.
startsWith
(
"powerpc64"
)
)
nativeArch
=
CPUArch
.
PPC64
;
else
if
(
nativeCpu
.
startsWith
(
"ppc"
)
||
nativeCpu
.
startsWith
(
"powerpc"
)
)
nativeArch
=
CPUArch
.
PPC
;
else
if
(
nativeCpu
.
contains
(
"86"
)
)
nativeArch
=
CPUArch
.
X86
;
else
nativeArch
=
CPUArch
.
UNKNOWN
;
return
nativeArch
;
}

Return a CPUArch from parsing a GNU autoconf triple.

For example "x86_64-w64-mingw32" will return {@link JNIEnv.CPUArch#X86_64}
and "ppc-apple-darwin" will return {@link JNIEnv.CPUArch#PPC}.

@param gnuString the GNU string
@return the architecture

Return a CPUArch from parsing a GNU autoconf triple .


public static OSFamily getOSFamily(String osName)
  {
    final OSFamily retval;

    if (osName != null && osName.length() > 0)
    {
      if (osName.startsWith("Windows"))
        retval = OSFamily.WINDOWS;
      else if (osName.startsWith("Mac"))
        retval = OSFamily.MAC;
      else if (osName.startsWith("Linux"))
        retval = OSFamily.LINUX;
      else
        retval = OSFamily.UNKNOWN;
    } else
      retval = OSFamily.UNKNOWN;
    return retval;
  }

public static OSFamily getOSFamily ( String osName ) { final OSFamily retval ; if ( osName != null && osName . length ( ) > 0 ) { if ( osName . startsWith ( "Windows" ) ) retval = OSFamily . WINDOWS ; else if ( osName . startsWith ( "Mac" ) ) retval = OSFamily . MAC ; else if ( osName . startsWith ( "Linux" ) ) retval = OSFamily . LINUX ; else retval = OSFamily . UNKNOWN ; } else retval = OSFamily . UNKNOWN ; return retval ; }

Get the OSFamily based on the passed in osName specifier.

The string should be of a format returned from {@link System#getProperty(String)}
for the property "os.name".

@param osName the string to parse
@return the OSFamily
@see System#getProperty(String)

Get the OSFamily based on the passed in osName specifier .


public static OSFamily getOSFamilyFromGNUString(String gnuString)
  {
    final String nativeOs = (gnuString != null ? gnuString.toLowerCase() : "");
    final OSFamily retval;
    if (nativeOs.startsWith("mingw") || nativeOs.startsWith("cygwin"))
      retval = OSFamily.WINDOWS;
    else if (nativeOs.startsWith("darwin"))
      retval = OSFamily.MAC;
    else if (nativeOs.startsWith("linux"))
      retval = OSFamily.LINUX;
    else
      retval = OSFamily.UNKNOWN;
    return retval;
  }

public static OSFamily getOSFamilyFromGNUString ( String gnuString ) { final String nativeOs = ( gnuString != null ? gnuString . toLowerCase ( ) : "" ) ; final OSFamily retval ; if ( nativeOs . startsWith ( "mingw" ) || nativeOs . startsWith ( "cygwin" ) ) retval = OSFamily . WINDOWS ; else if ( nativeOs . startsWith ( "darwin" ) ) retval = OSFamily . MAC ; else if ( nativeOs . startsWith ( "linux" ) ) retval = OSFamily . LINUX ; else retval = OSFamily . UNKNOWN ; return retval ; }

Return an OS Family from parsing a GNU autoconf triple.

For example "x86_64-w64-mingw32" will return {@link JNIEnv.OSFamily#WINDOWS}
and "ppc-apple-darwin" will return {@link JNIEnv.OSFamily#MAC}.

@param gnuString the GNU string
@return the OSFamily

Return an OS Family from parsing a GNU autoconf triple .


private static void playSound(String filename) throws InterruptedException, IOException, LineUnavailableException {
    /*
     * Start by creating a container object, in this case a demuxer since
     * we are reading, to get audio data from.
     */
    Demuxer demuxer = Demuxer.make();

    /*
     * Open the demuxer with the filename passed on.
     */
    demuxer.open(filename, null, false, true, null, null);

    /*
     * Query how many streams the call to open found
     */
    int numStreams = demuxer.getNumStreams();

    /*
     * Iterate through the streams to find the first audio stream
     */
    int audioStreamId = -1;
    Decoder audioDecoder = null;
    for(int i = 0; i < numStreams; i++)
    {
      final DemuxerStream stream = demuxer.getStream(i);
      final Decoder decoder = stream.getDecoder();
      if (decoder != null && decoder.getCodecType() == MediaDescriptor.Type.MEDIA_AUDIO) {
        audioStreamId = i;
        audioDecoder = decoder;
        // stop at the first one.
        break;
      }
    }
    if (audioStreamId == -1)
      throw new RuntimeException("could not find audio stream in container: "+filename);

    /*
     * Now we have found the audio stream in this file.  Let's open up our decoder so it can
     * do work.
     */
    audioDecoder.open(null, null);

    /*
     * We allocate a set of samples with the same number of channels as the
     * coder tells us is in this buffer.
     */
    final MediaAudio samples = MediaAudio.make(
        audioDecoder.getFrameSize(),
        audioDecoder.getSampleRate(),
        audioDecoder.getChannels(),
        audioDecoder.getChannelLayout(),
        audioDecoder.getSampleFormat());

    /*
     * A converter object we'll use to convert Humble Audio to a format that
     * Java Audio can actually play. The details are complicated, but essentially
     * this converts any audio format (represented in the samples object) into
     * a default audio format suitable for Java's speaker system (which will
     * be signed 16-bit audio, stereo (2-channels), resampled to 22,050 samples
     * per second).
     */

    final MediaAudioConverter converter =
        MediaAudioConverterFactory.createConverter(
            MediaAudioConverterFactory.DEFAULT_JAVA_AUDIO,
            samples);

    /*
     * An AudioFrame is a wrapper for the Java Sound system that abstracts away
     * some stuff. Go read the source code if you want -- it's not very complicated.
     */
    final AudioFrame audioFrame = AudioFrame.make(converter.getJavaFormat());
    if (audioFrame == null)
      throw new LineUnavailableException();

    /* We will use this to cache the raw-audio we pass to and from
     * the java sound system.
     */
    ByteBuffer rawAudio = null;

    /*
     * Now, we start walking through the container looking at each packet. This
     * is a decoding loop, and as you work with Humble you'll write a lot
     * of these.
     *
     * Notice how in this loop we reuse all of our objects to avoid
     * reallocating them. Each call to Humble resets objects to avoid
     * unnecessary reallocation.
     */
    final MediaPacket packet = MediaPacket.make();
    while(demuxer.read(packet) >= 0) {
      /*
       * Now we have a packet, let's see if it belongs to our audio stream
       */
      if (packet.getStreamIndex() == audioStreamId)
      {
        /*
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in audio-decoding speak).  So, we may need to call decode audio multiple
         * times at different offsets in the packet's data.  We capture that here.
         */
        int offset = 0;
        int bytesRead = 0;
        do {
          bytesRead += audioDecoder.decode(samples, packet, offset);
          if (samples.isComplete()) {
            rawAudio = converter.toJavaAudio(rawAudio, samples);
            audioFrame.play(rawAudio);
          }
          offset += bytesRead;
        } while (offset < packet.getSize());
      }
    }

    // Some audio decoders (especially advanced ones) will cache
    // audio data before they begin decoding, so when you are done you need
    // to flush them. The convention to flush Encoders or Decoders in Humble Video
    // is to keep passing in null until incomplete samples or packets are returned.
    do {
      audioDecoder.decode(samples, null, 0);
      if (samples.isComplete()) {
        rawAudio = converter.toJavaAudio(rawAudio, samples);
        audioFrame.play(rawAudio);
      }
    } while (samples.isComplete());

    // It is good practice to close demuxers when you're done to free
    // up file handles. Humble will EVENTUALLY detect if nothing else
    // references this demuxer and close it then, but get in the habit
    // of cleaning up after yourself, and your future girlfriend/boyfriend
    // will appreciate it.
    demuxer.close();

    // similar with the demuxer, for the audio playback stuff, clean up after yourself.
    audioFrame.dispose();
  }

Opens a file, and plays the audio from it on the speakers.
@param filename The file or URL to play.
@throws LineUnavailableException

Opens a file and plays the audio from it on the speakers .


synchronized void loadLibrary0(String aLibraryName, Long aMajorVersion)
  {
    if (alreadyLoadedLibrary(aLibraryName, aMajorVersion))
      // our work is done.
      return;

    List<String> libCandidates = getLibraryCandidates(aLibraryName,
        aMajorVersion);
    if (libCandidates != null && libCandidates.size() > 0
        && !loadCandidateLibrary(aLibraryName, aMajorVersion, libCandidates))
    {
      // finally, try the System.loadLibrary call
      try
      {
        System.loadLibrary(aLibraryName);
      }
      catch (UnsatisfiedLinkError e)
      {
        log
            .error(
                "Could not load library: {}; version: {}.",
                aLibraryName, aMajorVersion == null ? "" : aMajorVersion);
        throw e;

      }
      // and if we get here it means we successfully loaded since no
      // exception was thrown. Add our library to the cache.
      setLoadedLibrary(aLibraryName, aMajorVersion);
    }
    log.trace("Successfully Loaded library: {}; Version: {}", aLibraryName, aMajorVersion);
  }

This is the method that actually loads the library. It maintains an object
level lock, and since this class only allows a singleton object, that is a
class-level lock. That means if you're loading a library on one thread,
other threads will block until it finishes.

This should be OK in general.

@param aLibraryName
The library name.
@param aMajorVersion
The version, or null if you don't care.

This is the method that actually loads the library . It maintains an object level lock and since this class only allows a singleton object that is a class - level lock . That means if you re loading a library on one thread other threads will block until it finishes .


void setLoadedLibrary(String aLibraryName, Long aMajorVersion)
  {
    Set<Long> foundVersions = mLoadedLibraries.get(aLibraryName);
    if (foundVersions == null)
    {
      foundVersions = new HashSet<Long>();
      mLoadedLibraries.put(aLibraryName, foundVersions);
    }
    foundVersions.add(aMajorVersion);
  }

void setLoadedLibrary ( String aLibraryName , Long aMajorVersion ) { Set < Long > foundVersions = mLoadedLibraries . get ( aLibraryName ) ; if ( foundVersions == null ) { foundVersions = new HashSet < Long > ( ) ; mLoadedLibraries . put ( aLibraryName , foundVersions ) ; } foundVersions . add ( aMajorVersion ) ; }

Tell the cache that we've loaded this version.

@param aLibraryName
@param aMajorVersion

Tell the cache that we ve loaded this version .


boolean loadCandidateLibrary(String aLibraryName, Long aMajorVersion,
      List<String> aLibCandidates)
  {
    boolean retval = false;
    for (String candidate : aLibCandidates)
    {
      log
          .trace(
              "Attempt: library load of library: {}; version: {}: relative path: {}",
              new Object[]
              {
                  aLibraryName,
                  aMajorVersion == null ? "<unspecified>" : aMajorVersion
                      .longValue(), candidate
              });
      File candidateFile = new File(candidate);
      if (candidateFile.exists())
      {
        String absPath = candidateFile.getAbsolutePath();
        try
        {
          log
              .trace(
                  "Attempt: library load of library: {}; version: {}: absolute path: {}",
                  new Object[]
                  {
                      aLibraryName,
                      aMajorVersion == null ? "<unspecified>" : aMajorVersion
                          .longValue(), absPath
                  });
          // Here's where we attempt the actual load.
          System.load(absPath);
          log
              .trace(
                  "Success: library load of library: {}; version: {}: absolute path: {}",
                  new Object[]
                  {
                      aLibraryName,
                      aMajorVersion == null ? "<unspecified>" : aMajorVersion
                          .longValue(), absPath
                  });
          // if we got here, we loaded successfully
          setLoadedLibrary(aLibraryName, aMajorVersion);
          retval = true;
          break;
        }
        catch (UnsatisfiedLinkError e)
        {
          log
              .warn(
                  "Failure: library load of library: {}; version: {}: absolute path: {}; error: {}",
                  new Object[]
                  {
                      aLibraryName,
                      aMajorVersion == null ? "<unspecified>" : aMajorVersion
                          .longValue(), absPath, e
                  });
        }
        catch (SecurityException e)
        {
          log
              .warn(
                  "Failure: library load of library: {}; version: {}: absolute path: {}; error: {}",
                  new Object[]
                  {
                      aLibraryName,
                      aMajorVersion == null ? "<unspecified>" : aMajorVersion
                          .longValue(), absPath, e
                  });
        }
      }
    }
    return retval;
  }

Iterates through the set of aLibCandidates until it succeeds in loading a
library. If it succeeds, it lets the cache know.

@param aLibraryName
The library name.
@param aMajorVersion
The version we want, or null if we don't care.
@param aLibCandidates
The set of candidates generated by
{@link #getLibraryCandidates(String, Long)}
@return true if we succeeded in loading a library; false otherwise

Iterates through the set of aLibCandidates until it succeeds in loading a library . If it succeeds it lets the cache know .


private void initializeSearchPaths()
  {
    String pathVar = null;
    if (mJavaPropPaths == null)
    {
      pathVar = System.getProperty("java.library.path", "");
      log.trace("property java.library.path: {}", pathVar);
      mJavaPropPaths = getEntitiesFromPath(pathVar);
    }
    if (mJavaEnvPaths == null)
    {
      String envVar = getSystemRuntimeLibraryPathVar();
      pathVar = System.getenv(envVar);
      log.trace("OS environment runtime shared library path ({}): {}", envVar,
          pathVar);
      mJavaEnvPaths = getEntitiesFromPath(pathVar);
    }

  }

Initialize the paths we'll search for libraries in.

Initialize the paths we ll search for libraries in .


boolean alreadyLoadedLibrary(String aLibraryName, Long aMajorVersion)
  {
    boolean retval = false;
    Set<Long> foundVersions = mLoadedLibraries.get(aLibraryName);
    if (foundVersions != null)
    {
      // we found at least some versions
      if (aMajorVersion == null || foundVersions.contains(aMajorVersion))
      {
        retval = true;
      }
      else
      {
        log
            .warn(
                "Attempting load of {}, version {}, but already loaded verions: {}."
                    + "  We will attempt to load the specified version but behavior is undefined",
                new Object[]
                {
                    aLibraryName, aMajorVersion, foundVersions.toArray()
                });
      }
    }
    return retval;
  }

Checks our cache to see if we've already loaded this library.

We will also detect if we've already loaded another version of this
library, and log a warning, but otherwise will return false in that case.

@param aLibraryName
The library name.
@param aMajorVersion
The version, or null if we don't care.
@return true if in cache; false otherwise

Checks our cache to see if we ve already loaded this library .


private static void recordScreen(String filename, String formatname,
      String codecname, int duration, int snapsPerSecond) throws AWTException, InterruptedException, IOException {
    /**
     * Set up the AWT infrastructure to take screenshots of the desktop.
     */
    final Robot robot = new Robot();
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final Rectangle screenbounds = new Rectangle(toolkit.getScreenSize());

    final Rational framerate = Rational.make(1, snapsPerSecond);

    /** First we create a muxer using the passed in filename and formatname if given. */
    final Muxer muxer = Muxer.make(filename, null, formatname);

    /** Now, we need to decide what type of codec to use to encode video. Muxers
     * have limited sets of codecs they can use. We're going to pick the first one that
     * works, or if the user supplied a codec name, we're going to force-fit that
     * in instead.
     */
    final MuxerFormat format = muxer.getFormat();
    final Codec codec;
    if (codecname != null) {
      codec = Codec.findEncodingCodecByName(codecname);
    } else {
      codec = Codec.findEncodingCodec(format.getDefaultVideoCodecId());
    }

    /**
     * Now that we know what codec, we need to create an encoder
     */
    Encoder encoder = Encoder.make(codec);

    /**
     * Video encoders need to know at a minimum:
     *   width
     *   height
     *   pixel format
     * Some also need to know frame-rate (older codecs that had a fixed rate at which video files could
     * be written needed this). There are many other options you can set on an encoder, but we're
     * going to keep it simpler here.
     */
    encoder.setWidth(screenbounds.width);
    encoder.setHeight(screenbounds.height);
    // We are going to use 420P as the format because that's what most video formats these days use
    final PixelFormat.Type pixelformat = PixelFormat.Type.PIX_FMT_YUV420P;
    encoder.setPixelFormat(pixelformat);
    encoder.setTimeBase(framerate);

    /** An annoynace of some formats is that they need global (rather than per-stream) headers,
     * and in that case you have to tell the encoder. And since Encoders are decoupled from
     * Muxers, there is no easy way to know this beyond
     */
    if (format.getFlag(MuxerFormat.Flag.GLOBAL_HEADER))
      encoder.setFlag(Encoder.Flag.FLAG_GLOBAL_HEADER, true);

    /** Open the encoder. */
    encoder.open(null, null);

    /** Add this stream to the muxer. */
    muxer.addNewStream(encoder);

    /** And open the muxer for business. */
    muxer.open(null, null);

    /** Next, we need to make sure we have the right MediaPicture format objects
     * to encode data with. Java (and most on-screen graphics programs) use some
     * variant of Red-Green-Blue image encoding (a.k.a. RGB or BGR). Most video
     * codecs use some variant of YCrCb formatting. So we're going to have to
     * convert. To do that, we'll introduce a MediaPictureConverter object later. object.
     */
    MediaPictureConverter converter = null;
    final MediaPicture picture = MediaPicture.make(
        encoder.getWidth(),
        encoder.getHeight(),
        pixelformat);
    picture.setTimeBase(framerate);

    /** Now begin our main loop of taking screen snaps.
     * We're going to encode and then write out any resulting packets. */
    final MediaPacket packet = MediaPacket.make();
    for (int i = 0; i < duration / framerate.getDouble(); i++) {
      /** Make the screen capture && convert image to TYPE_3BYTE_BGR */
      final BufferedImage screen = convertToType(robot.createScreenCapture(screenbounds), BufferedImage.TYPE_3BYTE_BGR);

      /** This is LIKELY not in YUV420P format, so we're going to convert it using some handy utilities. */
      if (converter == null)
        converter = MediaPictureConverterFactory.createConverter(screen, picture);
      converter.toPicture(picture, screen, i);

      do {
        encoder.encode(packet, picture);
        if (packet.isComplete())
          muxer.write(packet, false);
      } while (packet.isComplete());

      /** now we'll sleep until it's time to take the next snapshot. */
      Thread.sleep((long) (1000 * framerate.getDouble()));
    }

    /** Encoders, like decoders, sometimes cache pictures so it can do the right key-frame optimizations.
     * So, they need to be flushed as well. As with the decoders, the convention is to pass in a null
     * input until the output is not complete.
     */
    do {
      encoder.encode(packet, null);
      if (packet.isComplete())
        muxer.write(packet,  false);
    } while (packet.isComplete());

    /** Finally, let's clean up after ourselves. */
    muxer.close();
  }


public void delete()
  {
    // acquire lock for minimum time
    final long swigPtr = mSwigCPtr.getAndSet(0);
    if (swigPtr != 0)
    {
      if (mJavaRefCount.decrementAndGet() == 0)
      {
        // log.debug("deleting: {}; {}", this, mSwigCPtr);
        FerryJNI.RefCounted_release(swigPtr, null);
      }
      // Free the memory manager we use
      mMemAllocator = null;
    }

  }

Explicitly deletes the underlying native storage used by
the object this object references.  The underlying native
object is now no long valid, and attempts to use it could
cause unspecified behavior.

Explicitly deletes the underlying native storage used by the object this object references . The underlying native object is now no long valid and attempts to use it could cause unspecified behavior .


public MuxerStream getStream(int position) throws java.lang.InterruptedException, java.io.IOException {
    long cPtr = VideoJNI.Muxer_getStream(swigCPtr, this, position);
    return (cPtr == 0) ? null : new MuxerStream(cPtr, false);
  }

public MuxerStream getStream ( int position ) throws java . lang . InterruptedException , java . io . IOException { long cPtr = VideoJNI . Muxer_getStream ( swigCPtr , this , position ) ; return ( cPtr == 0 ) ? null : new MuxerStream ( cPtr , false ) ; }

Get the MuxerStream at the given position.

Get the MuxerStream at the given position .


public Muxer getMuxer() {
    long cPtr = VideoJNI.MuxerStream_getMuxer(swigCPtr, this);
    return (cPtr == 0) ? null : new Muxer(cPtr, false);
  }

public Muxer getMuxer ( ) { long cPtr = VideoJNI . MuxerStream_getMuxer ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Muxer ( cPtr , false ) ; }

Get the Muxer that this stream belongs to.

Get the Muxer that this stream belongs to .


public static SetScriptTransaction makeScriptTx(PrivateKeyAccount sender, String script, byte chainId, long fee, long timestamp) {
        return new SetScriptTransaction(sender, script, chainId, fee, timestamp);
    }

public static SetScriptTransaction makeScriptTx ( PrivateKeyAccount sender , String script , byte chainId , long fee , long timestamp ) { return new SetScriptTransaction ( sender , script , chainId , fee , timestamp ) ; }

Creates a signed SetScript object.

@param sender    the account to set the script for
@param script    compiled script, base64 encoded
@param chainId   chain ID
@param fee       object fee
@param timestamp operation timestamp
@return object object
@see Account#MAINNET
@see Account#TESTNET


public static byte[] decode(String input) throws IllegalArgumentException {
        if (input.startsWith("base58:")) input = input.substring(7);
        if (input.length() == 0) return new byte[0];

        // Convert the base58-encoded ASCII chars to a base58 byte sequence (base58 digits).
        byte[] input58 = new byte[input.length()];
        for (int i = 0; i < input.length(); ++i) {
            char c = input.charAt(i);
            int digit = c < 128 ? INDEXES[c] : -1;
            if (digit < 0) {
                throw new IllegalArgumentException("Illegal character " + c + " at position " + i);
            }
            input58[i] = (byte) digit;
        }
        // Count leading zeros.
        int zeros = 0;
        while (zeros < input58.length && input58[zeros] == 0) {
            ++zeros;
        }
        // Convert base-58 digits to base-256 digits.
        byte[] decoded = new byte[input.length()];
        int outputStart = decoded.length;
        for (int inputStart = zeros; inputStart < input58.length; ) {
            decoded[--outputStart] = divmod(input58, inputStart, 58, 256);
            if (input58[inputStart] == 0) {
                ++inputStart; // optimization - skip leading zeros
            }
        }
        // Ignore extra leading zeroes that were added during the calculation.
        while (outputStart < decoded.length && decoded[outputStart] == 0) {
            ++outputStart;
        }
        // Return decoded data (including original number of leading zeros).
        return Arrays.copyOfRange(decoded, outputStart - zeros, decoded.length);
    }

Decodes the given base58 string into the original data bytes.

@param input the base58-encoded string to decode
@return the decoded data bytes
@throws IllegalArgumentException if the given string is not a valid base58 string

Decodes the given base58 string into the original data bytes .


public static String generateSeed() {
        byte[] bytes = new byte[21];
        new SecureRandom().nextBytes(bytes);
        byte[] rhash = hash(bytes, 0, 20, SHA256);
        bytes[20] = rhash[0];
        BigInteger rand = new BigInteger(bytes);
        BigInteger mask = new BigInteger(new byte[]{0, 0, 7, -1}); // 11 lower bits
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 15; i++) {
            sb.append(i > 0 ? ' ' : "")
                    .append(SEED_WORDS[rand.and(mask).intValue()]);
            rand = rand.shiftRight(11);
        }
        return sb.toString();
    }

public
static
String
generateSeed
(
)
{
byte
[
]
bytes
=
new
byte
[
21
]
;
new
SecureRandom
(
)
.
nextBytes
(
bytes
)
;
byte
[
]
rhash
=
hash
(
bytes
,
0
,
20
,
SHA256
)
;
bytes
[
20
]
=
rhash
[
0
]
;
BigInteger
rand
=
new
BigInteger
(
bytes
)
;
BigInteger
mask
=
new
BigInteger
(
new
byte
[
]
{
0
,
0
,
7
,
1
}
)
;
// 11 lower bits
StringBuilder
sb
=
new
StringBuilder
(
)
;
for
(
int
i
=
0
;
i
<
15
;
i
++
)
{
sb
.
append
(
i
>
0
'
'
:
""
)
.
append
(
SEED_WORDS
[
rand
.
and
(
mask
)
.
intValue
(
)
]
)
;
rand
=
rand
.
shiftRight
(
11
)
;
}
return
sb
.
toString
(
)
;
}

Generates a 15-word random seed. This method implements the BIP-39 algorithm with 160 bits of entropy.

@return the seed as a String

Generates a 15 - word random seed . This method implements the BIP - 39 algorithm with 160 bits of entropy .


public Transaction getTransaction(String txId) throws IOException {
        return wavesJsonMapper.convertValue(send("/transactions/info/" + txId), Transaction.class);
    }

public Transaction getTransaction ( String txId ) throws IOException { return wavesJsonMapper . convertValue ( send ( "/transactions/info/" + txId ) , Transaction . class ) ; }

Returns object by its ID.

@param txId object ID
@return object object
@throws IOException if no object with the given ID exists


public List<Transaction> getAddressTransactions(String address, int limit) throws IOException {
        return getAddressTransactions(address, limit, null);
    }

public List < Transaction > getAddressTransactions ( String address , int limit ) throws IOException { return getAddressTransactions ( address , limit , null ) ; }

Returns transactions by address with limit.
@param address address
@param limit transactions limit
@return list of transactions
@throws IOException if something going wrong

Returns transactions by address with limit .


public List<Transaction> getAddressTransactions(String address, int limit, String after) throws IOException {
        String requestUrl = String.format("/transactions/address/%s/limit/%d", address, limit);
        if (after != null) {
            requestUrl += String.format("?after=%s", after);
        }
        return wavesJsonMapper.<List<List<Transaction>>>convertValue(send(requestUrl),new TypeReference<List<List<Transaction>>>(){}).get(0);
    }

public List < Transaction > getAddressTransactions ( String address , int limit , String after ) throws IOException { String requestUrl = String . format ( "/transactions/address/%s/limit/%d" , address , limit ) ; if ( after != null ) { requestUrl += String . format ( "?after=%s" , after ) ; } return wavesJsonMapper . < List < List < Transaction > > > convertValue ( send ( requestUrl ) , new TypeReference < List < List < Transaction > > > ( ) { } ) . get ( 0 ) ; }

Returns transactions by address with limit after passed transaction id.
@param address address
@param limit transactions limit
@param after separate transaction id
@return list of transactions
@throws IOException if something going wrong

Returns transactions by address with limit after passed transaction id .


public List<BlockHeader> getBlockHeaderSeq(int from, int to) throws IOException {
        String path = String.format("/blocks/headers/seq/%s/%s", from, to);
        HttpResponse r = exec(request(path));
        return parse(r, BLOCK_HEADER_LIST);
    }

public List < BlockHeader > getBlockHeaderSeq ( int from , int to ) throws IOException { String path = String . format ( "/blocks/headers/seq/%s/%s" , from , to ) ; HttpResponse r = exec ( request ( path ) ) ; return parse ( r , BLOCK_HEADER_LIST ) ; }

Returns seq of block headers

@param from start block
@param to   end block
@return sequences of block objects without transactions
@throws IOException if no block exists at the given height


public Block getBlock(String signature) throws IOException {
        return wavesJsonMapper.convertValue(send("/blocks/signature/" + signature), Block.class);
    }

public Block getBlock ( String signature ) throws IOException { return wavesJsonMapper . convertValue ( send ( "/blocks/signature/" + signature ) , Block . class ) ; }

Returns block by its signature.

@param signature block signature
@return block object
@throws IOException if no block with the given signature exists


public String send(Transaction tx) throws IOException {
        return parse(exec(request(tx)), "id").asText();
    }

public String send ( Transaction tx ) throws IOException { return parse ( exec ( request ( tx ) ) , "id" ) . asText ( ) ; }

Sends a signed object and returns its ID.

@param tx signed object (as created by static methods in Transaction class)
@return Transaction ID
@throws IOException

Sends a signed object and returns its ID .


public String setScript(PrivateKeyAccount from, String script, byte chainId, long fee) throws IOException {
        return send(Transactions.makeScriptTx(from, compileScript(script), chainId, fee));
    }

public String setScript ( PrivateKeyAccount from , String script , byte chainId , long fee ) throws IOException { return send ( Transactions . makeScriptTx ( from , compileScript ( script ) , chainId , fee ) ) ; }

Sets a validating script for an account.

@param from    the account
@param script  script text
@param chainId chain ID
@param fee     object fee
@return object ID
@throws IOException if an error occurs
@see Account#MAINNET
@see Account#TESTNET

Sets a validating script for an account .


public String compileScript(String script) throws IOException {
        if (script == null || script.isEmpty()) {
            return null;
        }
        HttpPost request = new HttpPost(uri.resolve("/utils/script/compile"));
        request.setEntity(new StringEntity(script));
        return parse(exec(request), "script").asText();
    }

public String compileScript ( String script ) throws IOException { if ( script == null || script . isEmpty ( ) ) { return null ; } HttpPost request = new HttpPost ( uri . resolve ( "/utils/script/compile" ) ) ; request . setEntity ( new StringEntity ( script ) ) ; return parse ( exec ( request ) , "script" ) . asText ( ) ; }

Compiles a script.

@param script the script to compile
@return compiled script, base64 encoded
@throws IOException if the script is not well formed or some other error occurs


public void writePrimitiveArray(Object array, int off, int len) throws IOException {
        Class<?> componentType = array.getClass().getComponentType();
        if ( componentType == byte.class ) {
            writeRawBytes((byte[]) array, off, len);
        } else
        if ( componentType == char.class ) {
            writeFCharArr((char[]) array, off, len);
        } else
        if ( componentType == short.class ) {
            writeFShortArr((short[]) array, off, len);
        } else
        if ( componentType == int.class ) {
            writeFIntArr((int[]) array, off, len);
        } else
        if ( componentType == double.class ) {
            writeFDoubleArr((double[]) array, off, len);
        } else
        if ( componentType == float.class ) {
            writeFFloatArr((float[]) array, off, len);
        } else
        if ( componentType == long.class ) {
            writeFLongArr((long[]) array, off, len);
        } else
        if ( componentType == boolean.class ) {
            writeFBooleanArr((boolean[]) array, off, len);
        } else {
            throw new RuntimeException("expected primitive array");
        }
    }

public
void
writePrimitiveArray
(
Object
array
,
int
off
,
int
len
)
throws
IOException
{
Class
<
>
componentType
=
array
.
getClass
(
)
.
getComponentType
(
)
;
if
(
componentType
==
byte
.
class
)
{
writeRawBytes
(
(
byte
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
char
.
class
)
{
writeFCharArr
(
(
char
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
short
.
class
)
{
writeFShortArr
(
(
short
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
int
.
class
)
{
writeFIntArr
(
(
int
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
double
.
class
)
{
writeFDoubleArr
(
(
double
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
float
.
class
)
{
writeFFloatArr
(
(
float
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
long
.
class
)
{
writeFLongArr
(
(
long
[
]
)
array
,
off
,
len
)
;
}
else
if
(
componentType
==
boolean
.
class
)
{
writeFBooleanArr
(
(
boolean
[
]
)
array
,
off
,
len
)
;
}
else
{
throw
new
RuntimeException
(
"expected primitive array"
)
;
}
}

write prim array no len no tag

@param array
@throws IOException


@Override
    public void flush() throws IOException {
        if ( outStream != null )
            outStream.write(getBuffer(), 0, (int) pos);
        pos = 0;
    }

@ Override public void flush ( ) throws IOException { if ( outStream != null ) outStream . write ( getBuffer ( ) , 0 , ( int ) pos ) ; pos = 0 ; }

writes current buffer to underlying output and resets buffer.
@throws IOException

writes current buffer to underlying output and resets buffer .


public int toMemory(Object o, long address, int availableSize) throws IOException {
        out.resetForReUse();
        writeTarget.setBase(address, availableSize);
        out.writeObject(o);
        int written = out.getWritten();
        return written;
    }

public int toMemory ( Object o , long address , int availableSize ) throws IOException { out . resetForReUse ( ) ; writeTarget . setBase ( address , availableSize ) ; out . writeObject ( o ) ; int written = out . getWritten ( ) ; return written ; }

throws FSTBufferTooSmallException in case object does not fit into given range

@param o
@param address
@param availableSize
@throws IOException
@return number of bytes written to the memory region


@Override
    public FSTClazzInfo readClass() throws IOException, ClassNotFoundException {
        if (lastDirectClass != null ) {
            FSTClazzInfo clInfo = conf.getCLInfoRegistry().getCLInfo(lastDirectClass, conf);
            lastDirectClass = null;
            return clInfo;
        }
        return null;
    }

@ Override public FSTClazzInfo readClass ( ) throws IOException , ClassNotFoundException { if ( lastDirectClass != null ) { FSTClazzInfo clInfo = conf . getCLInfoRegistry ( ) . getCLInfo ( lastDirectClass , conf ) ; lastDirectClass = null ; return clInfo ; } return null ; }

in case readClass already reads full minbin value


public int toByteArray( Object obj, byte result[], int resultOffset, int avaiableSize ) {
        output.resetForReUse();
        try {
            output.writeObject(obj);
        } catch (IOException e) {
            FSTUtil.<RuntimeException>rethrow(e);
        }
        int written = output.getWritten();
        if ( written > avaiableSize ) {
            throw FSTBufferTooSmallException.Instance;
        }
        System.arraycopy(output.getBuffer(),0,result,resultOffset, written);
        return written;
    }

public int toByteArray ( Object obj , byte result [ ] , int resultOffset , int avaiableSize ) { output . resetForReUse ( ) ; try { output . writeObject ( obj ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } int written = output . getWritten ( ) ; if ( written > avaiableSize ) { throw FSTBufferTooSmallException . Instance ; } System . arraycopy ( output . getBuffer ( ) , 0 , result , resultOffset , written ) ; return written ; }

will throw an FSTBufferTooSmallException if buffer is too small.

will throw an FSTBufferTooSmallException if buffer is too small .


public void _setMMFData(File file, FileChannel fileChannel,Cleaner cleaner) {
        this.file = file; this.fileChannel = fileChannel; this.cleaner = cleaner;
    }

public void _setMMFData ( File file , FileChannel fileChannel , Cleaner cleaner ) { this . file = file ; this . fileChannel = fileChannel ; this . cleaner = cleaner ; }

hack to update underlying file in slices handed out to app


public static int getSpecificity(final Class<?> clazz) {
    if (clazz == null) return 0;
    final LineageInfo lineageInfo = FSTClazzLineageInfo.getLineageInfo(clazz);
    return lineageInfo == null ? 0 : lineageInfo.specificity;
  }

public static int getSpecificity ( final Class < ? > clazz ) { if ( clazz == null ) return 0 ; final LineageInfo lineageInfo = FSTClazzLineageInfo . getLineageInfo ( clazz ) ; return lineageInfo == null ? 0 : lineageInfo . specificity ; }

Returns the specificity of the specified class as defined above.

Returns the specificity of the specified class as defined above .


public void resizeStore(long required, long maxgrowbytes) {
        if ( mappedFile == null )
            throw new RuntimeException("store is full. Required: "+required);
        if ( required <= memory.length() )
            return;
        mutationCount++;
        System.out.println("resizing underlying "+mappedFile+" to "+required+" numElem:"+numElem);
        long tim = System.currentTimeMillis();
        ((MMFBytez) memory).freeAndClose();
        memory = null;
        try {
            File mf = new File(mappedFile);
            FileOutputStream f = new FileOutputStream(mf,true);
            long len = mf.length();
            required = required + Math.min(required,maxgrowbytes);
            byte[] toWrite = new byte[1000];
            long max = (required - len)/1000;
            for ( long i = 0; i < max+2; i++ ) {
                f.write(toWrite);
            }
            f.flush();
            f.close();
            resetMem(mappedFile, mf.length());
            System.out.println("resizing done in "+(System.currentTimeMillis()-tim)+" numElemAfter:"+numElem);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

public
void
resizeStore
(
long
required
,
long
maxgrowbytes
)
{
if
(
mappedFile
==
)
throw
new
RuntimeException
(
"store is full. Required: "
+
required
)
;
if
(
required
<=
memory
.
length
(
)
)
return
;
mutationCount
++
;
System
.
out
.
println
(
"resizing underlying "
+
mappedFile
+
" to "
+
required
+
" numElem:"
+
numElem
)
;
long
tim
=
System
.
currentTimeMillis
(
)
;
(
(
MMFBytez
)
memory
)
.
freeAndClose
(
)
;
memory
=
;
try
{
File
mf
=
new
File
(
mappedFile
)
;
FileOutputStream
f
=
new
FileOutputStream
(
mf
,
true
)
;
long
len
=
mf
.
length
(
)
;
required
=
required
+
Math
.
min
(
required
,
maxgrowbytes
)
;
byte
[
]
toWrite
=
new
byte
[
1000
]
;
long
max
=
(
required
len
)
/
1000
;
for
(
long
i
=
0
;
i
<
max
+
2
;
i
++
)
{
f
.
write
(
toWrite
)
;
}
f
.
flush
(
)
;
f
.
close
(
)
;
resetMem
(
mappedFile
,
mf
.
length
(
)
)
;
System
.
out
.
println
(
"resizing done in "
+
(
System
.
currentTimeMillis
(
)
tim
)
+
" numElemAfter:"
+
numElem
)
;
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
(
)
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
)
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
)
;
}
}

PRIVILEGED method. You gotta know what your doing here ..

currently a very expensive operation .. frees everything, resize file and remap.
Remapping involves rebuild of index.
@param required

PRIVILEGED method . You gotta know what your doing here ..


public void removeBinary( ByteSource key ) {
        checkThread();
        if ( key.length() != keyLen )
            throw new RuntimeException("key must have length "+keyLen);
        mutationCount++;
        long rem = index.get(key);
        if ( rem != 0 ) {
            index.remove(key);
            decElems();
            removeEntry(rem);
        }
    }

public
void
removeBinary
(
ByteSource
key
)
{
checkThread
(
)
;
if
(
key
.
length
(
)
!=
keyLen
)
throw
new
RuntimeException
(
"key must have length "
+
keyLen
)
;
mutationCount
++
;
long
rem
=
index
.
get
(
key
)
;
if
(
rem
!=
0
)
{
index
.
remove
(
key
)
;
decElems
(
)
;
removeEntry
(
rem
)
;
}
}

remove the key from the binary map
@param key


void writeStringAsc(String name) throws IOException {
        int len = name.length();
        if ( len >= 127 ) {
            throw new RuntimeException("Ascii String too long");
        }
        writeFByte((byte) len);
        buffout.ensureFree(len);
        if (ascStringCache == null || ascStringCache.length < len)
            ascStringCache = new byte[len];
        name.getBytes(0, len, ascStringCache, 0);
        writeRawBytes(ascStringCache, 0, len);
    }

void
writeStringAsc
(
String
name
)
throws
IOException
{
int
len
=
name
.
length
(
)
;
if
(
len
>=
127
)
{
throw
new
RuntimeException
(
"Ascii String too long"
)
;
}
writeFByte
(
(
byte
)
len
)
;
buffout
.
ensureFree
(
len
)
;
if
(
ascStringCache
==
||
ascStringCache
.
length
<
len
)
ascStringCache
=
new
byte
[
len
]
;
name
.
getBytes
(
0
,
len
,
ascStringCache
,
0
)
;
writeRawBytes
(
ascStringCache
,
0
,
len
)
;
}

length < 127 !!!!!

@param name
@throws java.io.IOException