/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * Picture formats and various static member functions for getting

 * meta data about them.
 */
public class PixelFormat extends RefCounted {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected PixelFormat(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.PixelFormat_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected PixelFormat(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.PixelFormat_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(PixelFormat obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new PixelFormat object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public PixelFormat copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new PixelFormat(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof PixelFormat)
      equal = (((PixelFormat)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

/**
 * Return the pixel format corresponding to name.

 *

 * If there is no pixel format with name name, then looks for a

 * pixel format with the name corresponding to the native endian

 * format of name.

 * For example in a little-endian system, first looks for "gray16",

 * then for "gray16le".

 *

 * Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.
 */
  public static PixelFormat.Type getFormat(String name) {
    return PixelFormat.Type.swigToEnum(VideoJNI.PixelFormat_getFormat(name));
  }

/**
 * Return the short name for a pixel format, NULL in case pix_fmt is

 * unknown.
 */
  public static String getFormatName(PixelFormat.Type pix_fmt) {
    return VideoJNI.PixelFormat_getFormatName(pix_fmt.swigValue());
  }

/**
 * @return a pixel format descriptor for provided pixel format or NULL if

 * this pixel format is unknown.
 */
  public static PixelFormatDescriptor getDescriptor(PixelFormat.Type pix_fmt) {
    long cPtr = VideoJNI.PixelFormat_getDescriptor(pix_fmt.swigValue());
    return (cPtr == 0) ? null : new PixelFormatDescriptor(cPtr, false);
  }

/**
 * Returns the total number of pixel format descriptors known to humble video.
 */
  public static int getNumInstalledFormats() {
    return VideoJNI.PixelFormat_getNumInstalledFormats();
  }

/**
 * Returns the 'i'th pixel format descriptor that is known to humble video

 *

 * @param i The i'th pixel format descriptor in the list of installed descriptors.
 */
  public static PixelFormatDescriptor getInstalledFormatDescriptor(int i) {
    long cPtr = VideoJNI.PixelFormat_getInstalledFormatDescriptor(i);
    return (cPtr == 0) ? null : new PixelFormatDescriptor(cPtr, false);
  }

/**
 * @return number of planes in pix_fmt, a negative ERROR if pix_fmt is not a

 * valid pixel format.
 */
  public static int getNumPlanes(PixelFormat.Type pix_fmt) {
    return VideoJNI.PixelFormat_getNumPlanes(pix_fmt.swigValue());
  }

/**
 * Utility function to swap the endianness of a pixel format.

 *

 * pix_fmt the pixel format

 *

 * @return pixel format with swapped endianness if it exists,

 * otherwise AV_PIX_FMT_NONE
 */
  public static PixelFormat.Type swapEndianness(PixelFormat.Type pix_fmt) {
    return PixelFormat.Type.swigToEnum(VideoJNI.PixelFormat_swapEndianness(pix_fmt.swigValue()));
  }

/**
 * Find the buffer size that would be necessary to store an image

 * with the given qualities.
 */
  public static int getBufferSizeNeeded(int width, int height, PixelFormat.Type pix_fmt) {
    return VideoJNI.PixelFormat_getBufferSizeNeeded(width, height, pix_fmt.swigValue());
  }

  /**
   * Pixel format.

   *

   * Note:

   * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA

   * color is put together as:

   *  (A << 24) | (R << 16) | (G << 8) | B

   * This is stored as BGRA on little-endian CPU architectures and ARGB on

   * big-endian CPUs.

   *

   *
When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized

   * image data is stored in AVFrame.data[0]. The palette is transported in

   * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is

   * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is

   * also endian-specific). Note also that the individual RGB palette

   * components stored in AVFrame.data[1] should be in the range 0..255.

   * This is important as many custom PAL8 video codecs that were designed

   * to run on the IBM VGA graphics adapter use 6-bit palette components.

   *

   *
For all the 8bit per pixel formats, an RGB32 palette is in data[1] like

   * for pal8. This palette is filled in automatically by the function

   * allocating the picture.

   *

   * Note:

   * Make sure that all newly added big-endian formats have pix_fmt & 1 == 1

   * and that all newly added little-endian formats have pix_fmt & 1 == 0.

   * This allows simpler detection of big vs little-endian.
   */
  public enum Type {
    PIX_FMT_NONE(VideoJNI.PixelFormat_PIX_FMT_NONE_get()),
  /**
   * planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
   */
    PIX_FMT_YUV420P(VideoJNI.PixelFormat_PIX_FMT_YUV420P_get()),
  /**
   * packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
   */
    PIX_FMT_YUYV422(VideoJNI.PixelFormat_PIX_FMT_YUYV422_get()),
  /**
   * packed RGB 8:8:8, 24bpp, RGBRGB...
   */
    PIX_FMT_RGB24(VideoJNI.PixelFormat_PIX_FMT_RGB24_get()),
  /**
   * packed RGB 8:8:8, 24bpp, BGRBGR...
   */
    PIX_FMT_BGR24(VideoJNI.PixelFormat_PIX_FMT_BGR24_get()),
  /**
   * planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
   */
    PIX_FMT_YUV422P(VideoJNI.PixelFormat_PIX_FMT_YUV422P_get()),
  /**
   * planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
   */
    PIX_FMT_YUV444P(VideoJNI.PixelFormat_PIX_FMT_YUV444P_get()),
  /**
   * planar YUV 4:1:0,  9bpp, (1 Cr & Cb sample per 4x4 Y samples)
   */
    PIX_FMT_YUV410P(VideoJNI.PixelFormat_PIX_FMT_YUV410P_get()),
  /**
   * planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
   */
    PIX_FMT_YUV411P(VideoJNI.PixelFormat_PIX_FMT_YUV411P_get()),
  /**
   * Y        ,  8bpp
   */
    PIX_FMT_GRAY8(VideoJNI.PixelFormat_PIX_FMT_GRAY8_get()),
  /**
   * Y        ,  1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
   */
    PIX_FMT_MONOWHITE(VideoJNI.PixelFormat_PIX_FMT_MONOWHITE_get()),
  /**
   * Y        ,  1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
   */
    PIX_FMT_MONOBLACK(VideoJNI.PixelFormat_PIX_FMT_MONOBLACK_get()),
  /**
   * 8 bit with PIX_FMT_RGB32 palette
   */
    PIX_FMT_PAL8(VideoJNI.PixelFormat_PIX_FMT_PAL8_get()),
  /**
   * planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
   */
    PIX_FMT_YUVJ420P(VideoJNI.PixelFormat_PIX_FMT_YUVJ420P_get()),
  /**
   * planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
   */
    PIX_FMT_YUVJ422P(VideoJNI.PixelFormat_PIX_FMT_YUVJ422P_get()),
  /**
   * planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
   */
    PIX_FMT_YUVJ444P(VideoJNI.PixelFormat_PIX_FMT_YUVJ444P_get()),
  /**
   * XVideo Motion Acceleration via common packet passing
   */
    PIX_FMT_XVMC_MPEG2_MC(VideoJNI.PixelFormat_PIX_FMT_XVMC_MPEG2_MC_get()),
    PIX_FMT_XVMC_MPEG2_IDCT(VideoJNI.PixelFormat_PIX_FMT_XVMC_MPEG2_IDCT_get()),
  /**
   * packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
   */
    PIX_FMT_UYVY422(VideoJNI.PixelFormat_PIX_FMT_UYVY422_get()),
  /**
   * packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
   */
    PIX_FMT_UYYVYY411(VideoJNI.PixelFormat_PIX_FMT_UYYVYY411_get()),
  /**
   * packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb)
   */
    PIX_FMT_BGR8(VideoJNI.PixelFormat_PIX_FMT_BGR8_get()),
  /**
   * packed RGB 1:2:1 bitstream,  4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
   */
    PIX_FMT_BGR4(VideoJNI.PixelFormat_PIX_FMT_BGR4_get()),
  /**
   * packed RGB 1:2:1,  8bpp, (msb)1B 2G 1R(lsb)
   */
    PIX_FMT_BGR4_BYTE(VideoJNI.PixelFormat_PIX_FMT_BGR4_BYTE_get()),
  /**
   * packed RGB 3:3:2,  8bpp, (msb)2R 3G 3B(lsb)
   */
    PIX_FMT_RGB8(VideoJNI.PixelFormat_PIX_FMT_RGB8_get()),
  /**
   * packed RGB 1:2:1 bitstream,  4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
   */
    PIX_FMT_RGB4(VideoJNI.PixelFormat_PIX_FMT_RGB4_get()),
  /**
   * packed RGB 1:2:1,  8bpp, (msb)1R 2G 1B(lsb)
   */
    PIX_FMT_RGB4_BYTE(VideoJNI.PixelFormat_PIX_FMT_RGB4_BYTE_get()),
  /**
   * planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
   */
    PIX_FMT_NV12(VideoJNI.PixelFormat_PIX_FMT_NV12_get()),
  /**
   * as above, but U and V bytes are swapped
   */
    PIX_FMT_NV21(VideoJNI.PixelFormat_PIX_FMT_NV21_get()),
  /**
   * packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
   */
    PIX_FMT_ARGB(VideoJNI.PixelFormat_PIX_FMT_ARGB_get()),
  /**
   * packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
   */
    PIX_FMT_RGBA(VideoJNI.PixelFormat_PIX_FMT_RGBA_get()),
  /**
   * packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
   */
    PIX_FMT_ABGR(VideoJNI.PixelFormat_PIX_FMT_ABGR_get()),
  /**
   * packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
   */
    PIX_FMT_BGRA(VideoJNI.PixelFormat_PIX_FMT_BGRA_get()),
  /**
   * Y        , 16bpp, big-endian
   */
    PIX_FMT_GRAY16BE(VideoJNI.PixelFormat_PIX_FMT_GRAY16BE_get()),
  /**
   * Y        , 16bpp, little-endian
   */
    PIX_FMT_GRAY16LE(VideoJNI.PixelFormat_PIX_FMT_GRAY16LE_get()),
  /**
   * planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
   */
    PIX_FMT_YUV440P(VideoJNI.PixelFormat_PIX_FMT_YUV440P_get()),
  /**
   * planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
   */
    PIX_FMT_YUVJ440P(VideoJNI.PixelFormat_PIX_FMT_YUVJ440P_get()),
  /**
   * planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
   */
    PIX_FMT_YUVA420P(VideoJNI.PixelFormat_PIX_FMT_YUVA420P_get()),
  /**
   * H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_H264(VideoJNI.PixelFormat_PIX_FMT_VDPAU_H264_get()),
  /**
   * MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_MPEG1(VideoJNI.PixelFormat_PIX_FMT_VDPAU_MPEG1_get()),
  /**
   * MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_MPEG2(VideoJNI.PixelFormat_PIX_FMT_VDPAU_MPEG2_get()),
  /**
   * WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_WMV3(VideoJNI.PixelFormat_PIX_FMT_VDPAU_WMV3_get()),
  /**
   * VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_VC1(VideoJNI.PixelFormat_PIX_FMT_VDPAU_VC1_get()),
  /**
   * packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
   */
    PIX_FMT_RGB48BE(VideoJNI.PixelFormat_PIX_FMT_RGB48BE_get()),
  /**
   * packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
   */
    PIX_FMT_RGB48LE(VideoJNI.PixelFormat_PIX_FMT_RGB48LE_get()),
  /**
   * packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), big-endian
   */
    PIX_FMT_RGB565BE(VideoJNI.PixelFormat_PIX_FMT_RGB565BE_get()),
  /**
   * packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), little-endian
   */
    PIX_FMT_RGB565LE(VideoJNI.PixelFormat_PIX_FMT_RGB565LE_get()),
  /**
   * packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
   */
    PIX_FMT_RGB555BE(VideoJNI.PixelFormat_PIX_FMT_RGB555BE_get()),
  /**
   * packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
   */
    PIX_FMT_RGB555LE(VideoJNI.PixelFormat_PIX_FMT_RGB555LE_get()),
  /**
   * packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), big-endian
   */
    PIX_FMT_BGR565BE(VideoJNI.PixelFormat_PIX_FMT_BGR565BE_get()),
  /**
   * packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), little-endian
   */
    PIX_FMT_BGR565LE(VideoJNI.PixelFormat_PIX_FMT_BGR565LE_get()),
  /**
   * packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
   */
    PIX_FMT_BGR555BE(VideoJNI.PixelFormat_PIX_FMT_BGR555BE_get()),
  /**
   * packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
   */
    PIX_FMT_BGR555LE(VideoJNI.PixelFormat_PIX_FMT_BGR555LE_get()),
  /**
   * HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
   */
    PIX_FMT_VAAPI_MOCO(VideoJNI.PixelFormat_PIX_FMT_VAAPI_MOCO_get()),
  /**
   * HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
   */
    PIX_FMT_VAAPI_IDCT(VideoJNI.PixelFormat_PIX_FMT_VAAPI_IDCT_get()),
  /**
   * HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VAAPI_VLD(VideoJNI.PixelFormat_PIX_FMT_VAAPI_VLD_get()),
  /**
   * planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
   */
    PIX_FMT_YUV420P16LE(VideoJNI.PixelFormat_PIX_FMT_YUV420P16LE_get()),
  /**
   * planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
   */
    PIX_FMT_YUV420P16BE(VideoJNI.PixelFormat_PIX_FMT_YUV420P16BE_get()),
  /**
   * planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
   */
    PIX_FMT_YUV422P16LE(VideoJNI.PixelFormat_PIX_FMT_YUV422P16LE_get()),
  /**
   * planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
   */
    PIX_FMT_YUV422P16BE(VideoJNI.PixelFormat_PIX_FMT_YUV422P16BE_get()),
  /**
   * planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
   */
    PIX_FMT_YUV444P16LE(VideoJNI.PixelFormat_PIX_FMT_YUV444P16LE_get()),
  /**
   * planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
   */
    PIX_FMT_YUV444P16BE(VideoJNI.PixelFormat_PIX_FMT_YUV444P16BE_get()),
  /**
   * MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
   */
    PIX_FMT_VDPAU_MPEG4(VideoJNI.PixelFormat_PIX_FMT_VDPAU_MPEG4_get()),
  /**
   * HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
   */
    PIX_FMT_DXVA2_VLD(VideoJNI.PixelFormat_PIX_FMT_DXVA2_VLD_get()),
  /**
   * packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
   */
    PIX_FMT_RGB444LE(VideoJNI.PixelFormat_PIX_FMT_RGB444LE_get()),
  /**
   * packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
   */
    PIX_FMT_RGB444BE(VideoJNI.PixelFormat_PIX_FMT_RGB444BE_get()),
  /**
   * packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
   */
    PIX_FMT_BGR444LE(VideoJNI.PixelFormat_PIX_FMT_BGR444LE_get()),
  /**
   * packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
   */
    PIX_FMT_BGR444BE(VideoJNI.PixelFormat_PIX_FMT_BGR444BE_get()),
  /**
   * 8bit gray, 8bit alpha
   */
    PIX_FMT_GRAY8A(VideoJNI.PixelFormat_PIX_FMT_GRAY8A_get()),
  /**
   * packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
   */
    PIX_FMT_BGR48BE(VideoJNI.PixelFormat_PIX_FMT_BGR48BE_get()),
  /**
   * packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
   */
    PIX_FMT_BGR48LE(VideoJNI.PixelFormat_PIX_FMT_BGR48LE_get()),
  /**
   * planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
   */
    PIX_FMT_YUV420P9BE(VideoJNI.PixelFormat_PIX_FMT_YUV420P9BE_get()),
  /**
   * planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
   */
    PIX_FMT_YUV420P9LE(VideoJNI.PixelFormat_PIX_FMT_YUV420P9LE_get()),
  /**
   * planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
   */
    PIX_FMT_YUV420P10BE(VideoJNI.PixelFormat_PIX_FMT_YUV420P10BE_get()),
  /**
   * planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
   */
    PIX_FMT_YUV420P10LE(VideoJNI.PixelFormat_PIX_FMT_YUV420P10LE_get()),
  /**
   * planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
   */
    PIX_FMT_YUV422P10BE(VideoJNI.PixelFormat_PIX_FMT_YUV422P10BE_get()),
  /**
   * planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
   */
    PIX_FMT_YUV422P10LE(VideoJNI.PixelFormat_PIX_FMT_YUV422P10LE_get()),
  /**
   * planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
   */
    PIX_FMT_YUV444P9BE(VideoJNI.PixelFormat_PIX_FMT_YUV444P9BE_get()),
  /**
   * planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
   */
    PIX_FMT_YUV444P9LE(VideoJNI.PixelFormat_PIX_FMT_YUV444P9LE_get()),
  /**
   * planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
   */
    PIX_FMT_YUV444P10BE(VideoJNI.PixelFormat_PIX_FMT_YUV444P10BE_get()),
  /**
   * planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
   */
    PIX_FMT_YUV444P10LE(VideoJNI.PixelFormat_PIX_FMT_YUV444P10LE_get()),
  /**
   * planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
   */
    PIX_FMT_YUV422P9BE(VideoJNI.PixelFormat_PIX_FMT_YUV422P9BE_get()),
  /**
   * planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
   */
    PIX_FMT_YUV422P9LE(VideoJNI.PixelFormat_PIX_FMT_YUV422P9LE_get()),
  /**
   * hardware decoding through VDA
   */
    PIX_FMT_VDA_VLD(VideoJNI.PixelFormat_PIX_FMT_VDA_VLD_get()),
  /**
   * planar GBR 4:4:4 24bpp
   */
    PIX_FMT_GBRP(VideoJNI.PixelFormat_PIX_FMT_GBRP_get()),
  /**
   * planar GBR 4:4:4 27bpp, big-endian
   */
    PIX_FMT_GBRP9BE(VideoJNI.PixelFormat_PIX_FMT_GBRP9BE_get()),
  /**
   * planar GBR 4:4:4 27bpp, little-endian
   */
    PIX_FMT_GBRP9LE(VideoJNI.PixelFormat_PIX_FMT_GBRP9LE_get()),
  /**
   * planar GBR 4:4:4 30bpp, big-endian
   */
    PIX_FMT_GBRP10BE(VideoJNI.PixelFormat_PIX_FMT_GBRP10BE_get()),
  /**
   * planar GBR 4:4:4 30bpp, little-endian
   */
    PIX_FMT_GBRP10LE(VideoJNI.PixelFormat_PIX_FMT_GBRP10LE_get()),
  /**
   * planar GBR 4:4:4 48bpp, big-endian
   */
    PIX_FMT_GBRP16BE(VideoJNI.PixelFormat_PIX_FMT_GBRP16BE_get()),
  /**
   * planar GBR 4:4:4 48bpp, little-endian
   */
    PIX_FMT_GBRP16LE(VideoJNI.PixelFormat_PIX_FMT_GBRP16LE_get()),
  /**
   * planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
   */
    PIX_FMT_YUVA422P_LIBAV(VideoJNI.PixelFormat_PIX_FMT_YUVA422P_LIBAV_get()),
  /**
   * planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
   */
    PIX_FMT_YUVA444P_LIBAV(VideoJNI.PixelFormat_PIX_FMT_YUVA444P_LIBAV_get()),
  /**
   * planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
   */
    PIX_FMT_YUVA420P9BE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P9BE_get()),
  /**
   * planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
   */
    PIX_FMT_YUVA420P9LE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P9LE_get()),
  /**
   * planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
   */
    PIX_FMT_YUVA422P9BE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P9BE_get()),
  /**
   * planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
   */
    PIX_FMT_YUVA422P9LE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P9LE_get()),
  /**
   * planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
   */
    PIX_FMT_YUVA444P9BE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P9BE_get()),
  /**
   * planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
   */
    PIX_FMT_YUVA444P9LE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P9LE_get()),
  /**
   * planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA420P10BE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P10BE_get()),
  /**
   * planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA420P10LE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P10LE_get()),
  /**
   * planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA422P10BE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P10BE_get()),
  /**
   * planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA422P10LE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P10LE_get()),
  /**
   * planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA444P10BE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P10BE_get()),
  /**
   * planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA444P10LE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P10LE_get()),
  /**
   * planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA420P16BE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P16BE_get()),
  /**
   * planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA420P16LE(VideoJNI.PixelFormat_PIX_FMT_YUVA420P16LE_get()),
  /**
   * planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA422P16BE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P16BE_get()),
  /**
   * planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA422P16LE(VideoJNI.PixelFormat_PIX_FMT_YUVA422P16LE_get()),
  /**
   * planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
   */
    PIX_FMT_YUVA444P16BE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P16BE_get()),
  /**
   * planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
   */
    PIX_FMT_YUVA444P16LE(VideoJNI.PixelFormat_PIX_FMT_YUVA444P16LE_get()),
  /**
   * HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
   */
    PIX_FMT_VDPAU(VideoJNI.PixelFormat_PIX_FMT_VDPAU_get()),
  /**
   * packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0
   */
    PIX_FMT_XYZ12LE(VideoJNI.PixelFormat_PIX_FMT_XYZ12LE_get()),
  /**
   * packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0
   */
    PIX_FMT_XYZ12BE(VideoJNI.PixelFormat_PIX_FMT_XYZ12BE_get()),
  /**
   * packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
   */
    PIX_FMT_RGBA64BE(VideoJNI.PixelFormat_PIX_FMT_RGBA64BE_get()),
  /**
   * packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
   */
    PIX_FMT_RGBA64LE(VideoJNI.PixelFormat_PIX_FMT_RGBA64LE_get()),
  /**
   * packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
   */
    PIX_FMT_BGRA64BE(VideoJNI.PixelFormat_PIX_FMT_BGRA64BE_get()),
  /**
   * packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
   */
    PIX_FMT_BGRA64LE(VideoJNI.PixelFormat_PIX_FMT_BGRA64LE_get()),
  /**
   * packed RGB 8:8:8, 32bpp, 0RGB0RGB...
   */
    PIX_FMT_0RGB(VideoJNI.PixelFormat_PIX_FMT_0RGB_get()),
  /**
   * packed RGB 8:8:8, 32bpp, RGB0RGB0...
   */
    PIX_FMT_RGB0(VideoJNI.PixelFormat_PIX_FMT_RGB0_get()),
  /**
   * packed BGR 8:8:8, 32bpp, 0BGR0BGR...
   */
    PIX_FMT_0BGR(VideoJNI.PixelFormat_PIX_FMT_0BGR_get()),
  /**
   * packed BGR 8:8:8, 32bpp, BGR0BGR0...
   */
    PIX_FMT_BGR0(VideoJNI.PixelFormat_PIX_FMT_BGR0_get()),
  /**
   * planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
   */
    PIX_FMT_YUVA444P(VideoJNI.PixelFormat_PIX_FMT_YUVA444P_get()),
  /**
   * planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
   */
    PIX_FMT_YUVA422P(VideoJNI.PixelFormat_PIX_FMT_YUVA422P_get()),
  /**
   * planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
   */
    PIX_FMT_YUV420P12BE(VideoJNI.PixelFormat_PIX_FMT_YUV420P12BE_get()),
  /**
   * planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
   */
    PIX_FMT_YUV420P12LE(VideoJNI.PixelFormat_PIX_FMT_YUV420P12LE_get()),
  /**
   * planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
   */
    PIX_FMT_YUV420P14BE(VideoJNI.PixelFormat_PIX_FMT_YUV420P14BE_get()),
  /**
   * planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
   */
    PIX_FMT_YUV420P14LE(VideoJNI.PixelFormat_PIX_FMT_YUV420P14LE_get()),
  /**
   * planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
   */
    PIX_FMT_YUV422P12BE(VideoJNI.PixelFormat_PIX_FMT_YUV422P12BE_get()),
  /**
   * planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
   */
    PIX_FMT_YUV422P12LE(VideoJNI.PixelFormat_PIX_FMT_YUV422P12LE_get()),
  /**
   * planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
   */
    PIX_FMT_YUV422P14BE(VideoJNI.PixelFormat_PIX_FMT_YUV422P14BE_get()),
  /**
   * planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
   */
    PIX_FMT_YUV422P14LE(VideoJNI.PixelFormat_PIX_FMT_YUV422P14LE_get()),
  /**
   * planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
   */
    PIX_FMT_YUV444P12BE(VideoJNI.PixelFormat_PIX_FMT_YUV444P12BE_get()),
  /**
   * planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
   */
    PIX_FMT_YUV444P12LE(VideoJNI.PixelFormat_PIX_FMT_YUV444P12LE_get()),
  /**
   * planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
   */
    PIX_FMT_YUV444P14BE(VideoJNI.PixelFormat_PIX_FMT_YUV444P14BE_get()),
  /**
   * planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
   */
    PIX_FMT_YUV444P14LE(VideoJNI.PixelFormat_PIX_FMT_YUV444P14LE_get()),
  /**
   * planar GBR 4:4:4 36bpp, big-endian
   */
    PIX_FMT_GBRP12BE(VideoJNI.PixelFormat_PIX_FMT_GBRP12BE_get()),
  /**
   * planar GBR 4:4:4 36bpp, little-endian
   */
    PIX_FMT_GBRP12LE(VideoJNI.PixelFormat_PIX_FMT_GBRP12LE_get()),
  /**
   * planar GBR 4:4:4 42bpp, big-endian
   */
    PIX_FMT_GBRP14BE(VideoJNI.PixelFormat_PIX_FMT_GBRP14BE_get()),
  /**
   * planar GBR 4:4:4 42bpp, little-endian
   */
    PIX_FMT_GBRP14LE(VideoJNI.PixelFormat_PIX_FMT_GBRP14LE_get()),
  /**
   * planar GBRA 4:4:4:4 32bpp
   */
    PIX_FMT_GBRAP(VideoJNI.PixelFormat_PIX_FMT_GBRAP_get()),
  /**
   * planar GBRA 4:4:4:4 64bpp, big-endian
   */
    PIX_FMT_GBRAP16BE(VideoJNI.PixelFormat_PIX_FMT_GBRAP16BE_get()),
  /**
   * planar GBRA 4:4:4:4 64bpp, little-endian
   */
    PIX_FMT_GBRAP16LE(VideoJNI.PixelFormat_PIX_FMT_GBRAP16LE_get()),
  /**
   * planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor of PIX_FMT_YUV411P and setting color_range
   */
    PIX_FMT_YUVJ411P(VideoJNI.PixelFormat_PIX_FMT_YUVJ411P_get()),
  /**
   * number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
   */
    PIX_FMT_NB(VideoJNI.PixelFormat_PIX_FMT_NB_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Type swigToEnum(int swigValue) {
      Type[] swigValues = Type.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Type swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Type() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Type(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Type(Type swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

}


/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * A packet of encoded data that was read from a Demuxer or

 * will be written to a Muxer.
 */
public class MediaPacket extends MediaEncoded {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected MediaPacket(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.MediaPacket_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected MediaPacket(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.MediaPacket_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(MediaPacket obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new MediaPacket object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public MediaPacket copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new MediaPacket(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof MediaPacket)
      equal = (((MediaPacket)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

  @Override
  public String toString() {
    final StringBuilder b = new StringBuilder(super.toString());
    b.append("[")
    .append("pts="+getPts()+";")
    .append("dts="+getDts()+";")
    .append("complete="+isComplete()+";")
    .append("size="+getSize()+";")
    .append("maxSize="+getMaxSize()+";")
    .append("streamIndex="+getStreamIndex()+";")
    .append("key="+isKey()+";")
    .append("flags="+getFlags()+";")
    .append("duration="+getDuration()+";")
    .append("position="+getPosition()+";")
    .append("convergenceDuration="+getConvergenceDuration()+";")
    .append("]");
    return b.toString();
  }

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

/**
 * Allocate a new packet that wraps an existing Buffer.

 *

 * NOTE: At least 16 bytes of the passed in buffer will be used

 * for header information, so the resulting Packet.getSize()

 * will be smaller than Buffer.getBufferSize() .

 *

 * @param buffer The Buffer to wrap.

 * @return a new packet or null on error.
 */
  public static MediaPacket make(Buffer buffer) {
    long cPtr = VideoJNI.MediaPacket_make__SWIG_1(Buffer.getCPtr(buffer), buffer);
    return (cPtr == 0) ? null : new MediaPacket(cPtr, false);
  }

/**
 * Allocate a new packet wrapping the existing contents of

 * a passed in packet.  Callers can then modify

 * #getPts(),

 * #getDts() and other get/set methods without

 * modifying the original packet.

 *

 * @param packet Packet to reuse buffer from and to

 *   copy settings from.

 * @param copyData if true copy data from packet

 *   into our own buffer.  If false, share the same

 *   data buffer that packet uses

 *

 * @return a new packet or null on error.
 */
  public static MediaPacket make(MediaPacket packet, boolean copyData) {
    long cPtr = VideoJNI.MediaPacket_make__SWIG_2(MediaPacket.getCPtr(packet), packet, copyData);
    return (cPtr == 0) ? null : new MediaPacket(cPtr, false);
  }

/**
 * Allocate a new packet.

 *

 * Note that any buffers this packet needs will be

 * lazily allocated (i.e. we won't actually grab all

 * the memory until we need it).

 *

 * @param size The maximum size, in bytes, of data you

 *   want to put in this packet.

 *

 * @return a new packet, or null on error.
 */
  public static MediaPacket make(int size) {
    long cPtr = VideoJNI.MediaPacket_make__SWIG_3(size);
    return (cPtr == 0) ? null : new MediaPacket(cPtr, false);
  }

/**
 * Get any underlying raw data available for this packet.

 *

 * @return The raw data, or null if not accessible.
 */
  public Buffer getData() {
    long cPtr = VideoJNI.MediaPacket_getData(swigCPtr, this);
    return (cPtr == 0) ? null : new Buffer(cPtr, false);
  }

/**
 * Get the number of side data elements in this packet.
 */
  public int getNumSideDataElems() {
    return VideoJNI.MediaPacket_getNumSideDataElems(swigCPtr, this);
  }

/**
 * Get the n'th item of SideData.

 *

 * WARNING: Callers must ensure that the the packet object

 * this is called form is NOT reset or destroyed while using this buffer,

 * as unfortunately we cannot ensure this buffer survives the

 * underlying packet data.

 *

 *

 * @param n The n'th item to get.

 * @return the data, or null if none found

 * @throws InvalidArgument if n < 0 || n >= #getNumSideDataElems()
 */
  public Buffer getSideData(int n) {
    long cPtr = VideoJNI.MediaPacket_getSideData(swigCPtr, this, n);
    return (cPtr == 0) ? null : new Buffer(cPtr, false);
  }

/**
 * Get the n'th item of SideData.

 *

 * @param n The n'th item to get.

 * @return the data, or SideDataType.DATA_UNKNOWN if none found

 * @throws InvalidArgument if n < 0 || n >= #getNumSideDataElems()
 */
  public MediaPacket.SideDataType getSideDataType(int n) {
    return MediaPacket.SideDataType.swigToEnum(VideoJNI.MediaPacket_getSideDataType(swigCPtr, this, n));
  }

/**
 * Get the Presentation Time Stamp (PTS) for this packet.

 *

 * This is the time at which the payload for this packet should

 * be presented to the user, in units of

 * #getTimeBase(), relative to the start of stream.

 *

 * @return Get the Presentation Timestamp for this packet.
 */
  public long getPts() {
    return VideoJNI.MediaPacket_getPts(swigCPtr, this);
  }

/**
 * Set a new Presentation Time Stamp (PTS) for this packet.

 *

 * @param aPts a new PTS for this packet.

 *

 * @see #getPts()
 */
  public void setPts(long aPts) {
    VideoJNI.MediaPacket_setPts(swigCPtr, this, aPts);
  }

/**
 * Get the Decompression Time Stamp (DTS) for this packet.

 *

 * This is the time at which the payload for this packet should

 * be decompressed, in units of

 * #getTimeBase(), relative to the start of stream.

 *

 *

 * Some media codecs can require packets from the "future" to

 * be decompressed before earliest packets as an additional way to compress

 * data.  In general you don't need to worry about this, but if you're

 * curious start reading about the difference between I-Frames, P-Frames

 * and B-Frames (or Bi-Directional Frames).  B-Frames can use information

 * from future frames when compressed.

 *

 * @return Get the Decompression Timestamp (i.e. when this was read relative

 * to the start of reading packets).
 */
  public long getDts() {
    return VideoJNI.MediaPacket_getDts(swigCPtr, this);
  }

/**
 * Set a new Decompression Time Stamp (DTS) for this packet.

 * @param aDts a new DTS for this packet.

 * @see #getDts()
 */
  public void setDts(long aDts) {
    VideoJNI.MediaPacket_setDts(swigCPtr, this, aDts);
  }

/**
 * Get the size in bytes of the payload currently in this packet.

 * @return Size (in bytes) of payload currently in packet.
 */
  public int getSize() {
    return VideoJNI.MediaPacket_getSize(swigCPtr, this);
  }

/**
 * Get the maximum size (in bytes) of payload this packet can hold.

 * @return Get maximum size (in bytes) of payload this packet can hold.
 */
  public int getMaxSize() {
    return VideoJNI.MediaPacket_getMaxSize(swigCPtr, this);
  }

/**
 * Get the container-specific index for the stream this packet is

 * part of.

 * @return Stream in container that this packet has data for, or <0 if unsure.
 */
  public int getStreamIndex() {
    return VideoJNI.MediaPacket_getStreamIndex(swigCPtr, this);
  }

/**
 * Get any flags set on this packet, as a 4-byte binary-ORed bit-mask.

 * This is access to raw FFMPEG

 * flags, but it is easier to use the is* methods below.

 * @return Any flags on the packet.
 */
  public int getFlags() {
    return VideoJNI.MediaPacket_getFlags(swigCPtr, this);
  }

/**
 * Does this packet contain Key data? i.e. data that needs no other

 * frames or samples to decode.

 * @return true if key; false otherwise.
 */
  public boolean isKeyPacket() {
    return VideoJNI.MediaPacket_isKeyPacket(swigCPtr, this);
  }

/**
 * Return the duration of this packet, in units of #getTimeBase()

 * @return Duration of this packet, in same time-base as the PTS.
 */
  public long getDuration() {
    return VideoJNI.MediaPacket_getDuration(swigCPtr, this);
  }

/**
 * Return the position (in bytes) of this packet in the stream.

 * @return The position of this packet in the stream, or -1 if

 *   unknown.
 */
  public long getPosition() {
    return VideoJNI.MediaPacket_getPosition(swigCPtr, this);
  }

/**
 * Set if this is a key packet.

 *

 * @param keyPacket true for yes, false for no.
 */
  public void setKeyPacket(boolean keyPacket) {
    VideoJNI.MediaPacket_setKeyPacket(swigCPtr, this, keyPacket);
  }

/**
 * Set any internal flags.

 *

 * @param flags Flags to set
 */
  public void setFlags(int flags) {
    VideoJNI.MediaPacket_setFlags(swigCPtr, this, flags);
  }

/**
 * Set the stream index for this packet.

 *

 * @param streamIndex The stream index, as determined from the IContainer this packet will be written to.
 */
  public void setStreamIndex(int streamIndex) {
    VideoJNI.MediaPacket_setStreamIndex(swigCPtr, this, streamIndex);
  }

/**
 * Set the duration.

 * @param duration new duration

 * @see #getDuration()
 */
  public void setDuration(long duration) {
    VideoJNI.MediaPacket_setDuration(swigCPtr, this, duration);
  }

/**
 * Set the position.

 * @param position new position

 * @see #getPosition()
 */
  public void setPosition(long position) {
    VideoJNI.MediaPacket_setPosition(swigCPtr, this, position);
  }

/**
 * Time difference in IStream#getTimeBase() units

 * from the presentation time stamp of this

 * packet to the point at which the output from the decoder has converged

 * independent from the availability of previous frames. That is, the

 * frames are virtually identical no matter if decoding started from

 * the very first frame or from this keyframe.

 * Is Global#NO_PTS if unknown.

 * This field is not the display duration of the current packet.

 *

 * The purpose of this field is to allow seeking in streams that have no

 * keyframes in the conventional sense. It corresponds to the

 * recovery point SEI in H.264 and match_time_delta in NUT. It is also

 * essential for some types of subtitle streams to ensure that all

 * subtitles are correctly displayed after seeking.

 *

 *

 * If you didn't follow that, try drinking one to two glasses

 * of Absinthe.  It won't help, but it'll be more fun.

 *

 *

 * @return the convergence duration
 */
  public long getConvergenceDuration() {
    return VideoJNI.MediaPacket_getConvergenceDuration(swigCPtr, this);
  }

/**
 * Set the convergence duration.

 * @param duration the new duration
 */
  public void setConvergenceDuration(long duration) {
    VideoJNI.MediaPacket_setConvergenceDuration(swigCPtr, this, duration);
  }

/**
 * Discard the current payload and allocate a new payload.

 *

 * Note that if any people have access to the old payload using

 * getData(), the memory will continue to be available to them

 * until they release their hold of the Buffer.

 *

 *

 * When requesting a packet size, the system

 *   may allocate a larger payloadSize.

 *

 * @param payloadSize The (minimum) payloadSize of this packet in bytes. It is ok to

 *   pass in 0 here, in which case the packet will later allocate memory if needed.
 */
  public void reset(int payloadSize) {
    VideoJNI.MediaPacket_reset(swigCPtr, this, payloadSize);
  }

  public enum SideDataType {
    DATA_UNKNOWN(VideoJNI.MediaPacket_DATA_UNKNOWN_get()),
    DATA_PALETTE(VideoJNI.MediaPacket_DATA_PALETTE_get()),
    DATA_NEW_EXTRADATA(VideoJNI.MediaPacket_DATA_NEW_EXTRADATA_get()),
  /**
   * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:

   * {@code
  u32le param_flags
  if (param_flags  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
      s32le channel_count
  if (param_flags  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
      u64le channel_layout
  if (param_flags  AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
      s32le sample_rate
  if (param_flags  AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
      s32le width
      s32le height
  }
   */
    DATA_PARAM_CHANGE(VideoJNI.MediaPacket_DATA_PARAM_CHANGE_get()),
  /**
   * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of

   * structures with info about macroblocks relevant to splitting the

   * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).

   * That is, it does not necessarily contain info about all macroblocks,

   * as long as the distance between macroblocks in the info is smaller

   * than the target payload size.

   * Each MB info structure is 12 bytes, and is laid out as follows:

   * {@code
  u32le bit offset from the start of the packet
  u8    current quantizer at the start of the macroblock
  u8    GOB number
  u16le macroblock address within the GOB
  u8    horizontal MV predictor
  u8    vertical MV predictor
  u8    horizontal MV predictor for block number 3
  u8    vertical MV predictor for block number 3
  }
   */
    DATA_H263_MB_INFO(VideoJNI.MediaPacket_DATA_H263_MB_INFO_get()),
  /**
   * Recommmends skipping the specified number of samples

   * {@code
  u32le number of samples to skip from start of this packet
  u32le number of samples to skip from end of this packet
  u8    reason for start skip
  u8    reason for end   skip (0=padding silence, 1=convergence)
  }
   */
    DATA_SKIP_SAMPLES(VideoJNI.MediaPacket_DATA_SKIP_SAMPLES_get()),
  /**
   * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that

   * the packet may contain "dual mono" audio specific to Japanese DTV

   * and if it is true, recommends only the selected channel to be used.

   * {@code
  u8    selected channels (0=mail/left, 1=sub/right, 2=both)
  }
   */
    DATA_JP_DUALMONO(VideoJNI.MediaPacket_DATA_JP_DUALMONO_get()),
  /**
   * A list of zero terminated key/value strings. There is no end marker for

   * the list, so it is required to rely on the side data size to stop.
   */
    DATA_STRINGS_METADATA(VideoJNI.MediaPacket_DATA_STRINGS_METADATA_get()),
  /**
   * Subtitle event position

   * {@code
  u32le x1
  u32le y1
  u32le x2
  u32le y2
  }
   */
    DATA_SUBTITLE_POSITION(VideoJNI.MediaPacket_DATA_SUBTITLE_POSITION_get()),
  /**
   * Data found in BlockAdditional element of matroska container. There is

   * no end marker for the data, so it is required to rely on the side data

   * size to recognize the end. 8 byte id (as found in BlockAddId) followed

   * by data.
   */
    DATA_MATROSKA_BLOCKADDITIONAL(VideoJNI.MediaPacket_DATA_MATROSKA_BLOCKADDITIONAL_get()),
  /**
   * The optional first identifier line of a WebVTT cue.
   */
    DATA_WEBVTT_IDENTIFIER(VideoJNI.MediaPacket_DATA_WEBVTT_IDENTIFIER_get()),
  /**
   * The optional settings (rendering instructions) that immediately

   * follow the timestamp specifier of a WebVTT cue.
   */
    DATA_WEBVTT_SETTINGS(VideoJNI.MediaPacket_DATA_WEBVTT_SETTINGS_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static SideDataType swigToEnum(int swigValue) {
      SideDataType[] swigValues = SideDataType.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (SideDataType swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + SideDataType.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private SideDataType() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private SideDataType(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private SideDataType(SideDataType swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

}


/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * A type of filter that can be created.
 */
public class FilterType extends RefCounted {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected FilterType(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.FilterType_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected FilterType(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.FilterType_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(FilterType obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new FilterType object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public FilterType copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new FilterType(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof FilterType)
      equal = (((FilterType)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

/**
 * @return name of this filter type.
 */
  public String getName() {
    return VideoJNI.FilterType_getName(swigCPtr, this);
  }

/**
 * @return description of this filter type.
 */
  public String getDescription() {
    return VideoJNI.FilterType_getDescription(swigCPtr, this);
  }

/**
 * @return bitmask of Flags set on this FilterType.
 */
  public int getFlags() {
    return VideoJNI.FilterType_getFlags(swigCPtr, this);
  }

/**
 * @param flag flag to check setting of.

 * @return is this flag set on the given FilterType
 */
  public boolean getFlag(FilterType.Flag flag) {
    return VideoJNI.FilterType_getFlag(swigCPtr, this, flag.swigValue());
  }

/**
 * @return number of inputs this FilterType expects.
 */
  public int getNumInputs() {
    return VideoJNI.FilterType_getNumInputs(swigCPtr, this);
  }

/**
 * @param index which input to get name of

 * @return the input name

 * @throws InvalidArgument if index < 0 || index > #getNumInputs().
 */
  public String getInputName(int index) {
    return VideoJNI.FilterType_getInputName(swigCPtr, this, index);
  }

/**
 * @param index which input to get type of

 * @return the input media type

 * @throws InvalidArgument if index < 0 || index > #getNumInputs().
 */
  public MediaDescriptor.Type getInputType(int index) {
    return MediaDescriptor.Type.swigToEnum(VideoJNI.FilterType_getInputType(swigCPtr, this, index));
  }

/**
 * @return number of outputs this FilterType expects.
 */
  public int getNumOutputs() {
    return VideoJNI.FilterType_getNumOutputs(swigCPtr, this);
  }

/**
 * @param index which output to get name of

 * @return the output name

 * @throws InvalidArgument if index < 0 || index > #getNumOutputs().
 */
  public String getOutputName(int index) {
    return VideoJNI.FilterType_getOutputName(swigCPtr, this, index);
  }

/**
 * @param index which output to get type of

 * @return the output media type

 * @throws InvalidArgument if index < 0 || index > #getNumOutputs().
 */
  public MediaDescriptor.Type getOutputType(int index) {
    return MediaDescriptor.Type.swigToEnum(VideoJNI.FilterType_getOutputType(swigCPtr, this, index));
  }

/**
 * Find a given filter by name.

 *

 * @param name name of filter.
 */
  public static FilterType findFilterType(String name) {
    long cPtr = VideoJNI.FilterType_findFilterType(name);
    return (cPtr == 0) ? null : new FilterType(cPtr, false);
  }

/**
 * @return the number of filters installed in this system.
 */
  public static int getNumFilterTypes() {
    return VideoJNI.FilterType_getNumFilterTypes();
  }

/**
 * @param index the position in the list of installed filters to get. Use

 *   with #getNumFilters() to iterate over all the filters installed

 *   in the system.

 * @return get the filter at the index position in the installed filters.

 * @throws InvalidArgument if index < 0 || index >= #getNumFilterTypes().
 */
  public static FilterType getFilterType(int index) {
    long cPtr = VideoJNI.FilterType_getFilterType(index);
    return (cPtr == 0) ? null : new FilterType(cPtr, false);
  }

  /**
   * Flags that show features different FilterType object support.
   */
  public enum Flag {
  /**
   * Do not use.
   */
    FILTER_FLAG_UNKNOWN(VideoJNI.FilterType_FILTER_FLAG_UNKNOWN_get()),
  /**
   * The number of the filter inputs is not determined just by the number of inputs explicitly added.

   * The filter might add additional inputs during initialization depending on the

   * options supplied to it.
   */
    FILTER_FLAG_DYNAMIC_INPUTS(VideoJNI.FilterType_FILTER_FLAG_DYNAMIC_INPUTS_get()),
  /**
   * The number of the filter outputs is not determined just by AVFilter.outputs.

   * The filter might add additional outputs during initialization depending on

   * the options supplied to it.
   */
    FILTER_FLAG_DYNAMIC_OUTPUTS(VideoJNI.FilterType_FILTER_FLAG_DYNAMIC_OUTPUTS_get()),
  /**
   * The filter supports multithreading by splitting frames into multiple parts

   * and processing them concurrently.
   */
    FILTER_FLAG_SLICE_THREADS(VideoJNI.FilterType_FILTER_FLAG_SLICE_THREADS_get()),
  /**
   * Some filters support a generic "enable" expression option that can be used

   * to enable or disable a filter in the timeline. Filters supporting this

   * option have this flag set. When the enable expression is false, the default

   * no-op filter_frame() function is called in place of the filter_frame()

   * callback defined on each input pad, thus the frame is passed unchanged to

   * the next filters.
   */
    FILTER_FLAG_SUPPORT_TIMELINE_GENERIC(VideoJNI.FilterType_FILTER_FLAG_SUPPORT_TIMELINE_GENERIC_get()),
  /**
   * Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will

   * have its filter_frame() callback(s) called as usual even when the enable

   * expression is false. The filter will disable filtering within the

   * filter_frame() callback(s) itself, for example executing code depending on

   * the AVFilterContext->is_disabled value.
   */
    FILTER_FLAG_SUPPORT_TIMELINE_INTERNAL(VideoJNI.FilterType_FILTER_FLAG_SUPPORT_TIMELINE_INTERNAL_get()),
  /**
   * Handy mask to test whether the filter supports or no the timeline feature

   * (internally or generically).
   */
    FILTER_FLAG_SUPPORT_TIMELINE(VideoJNI.FilterType_FILTER_FLAG_SUPPORT_TIMELINE_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Flag swigToEnum(int swigValue) {
      Flag[] swigValues = Flag.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Flag swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Flag.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Flag() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Flag(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Flag(Flag swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

}


/*******************************************************************************
 * Copyright (c) 2013, Art Clarke.  All rights reserved.
 *
 * This file is part of Humble-Video.
 *
 * Humble-Video is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Humble-Video is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Humble-Video.  If not, see <http://www.gnu.org/licenses/>.
 *******************************************************************************/
package io.humble.video.customio;

import java.io.Closeable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.EOFException;
import java.io.IOException;
import java.io.RandomAccessFile;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Implementation of URLProtocolHandler that can read from
 * {@link DataInput}
 * objects or write to {@link DataOutput} objects.
 *
 *

 *
 * The {@link IURLProtocolHandler#URL_RDWR} mode is not supported
 * unless both input and output objects are the same
 * {@link RandomAccessFile}
 *
 *

 *

 *
 * {@link IURLProtocolHandler#isStreamed(String, int)} will return
 * true, unless this class is reading from or writing to
 * a {@link RandomAccessFile};
 *
 *

 *
 * @author aclarke
 *
 */

public class DataInputOutputHandler implements IURLProtocolHandler
{
  private final Logger log = LoggerFactory.getLogger(this.getClass());

  /**
   * Whether or not this class will default calling
   * {@link Closeable#close()} on a stream when
   * {@link #close()} is called on this method.  Can be
   * overriden in constructors.
   */
  public final static boolean CLOSE_STREAM_ON_CLOSE=true;

  private final DataInput mDataInput;
  private final DataOutput mDataOutput;
  private final boolean mCloseStreamOnClose;
  private Object mOpenStream = null;

  /**
   * Create a handler that can only be opened for reading.
   * @param in an input object.
   */
  public DataInputOutputHandler(DataInput in)
  {
    this(in, null, CLOSE_STREAM_ON_CLOSE);
  }

  /**
   * Create a handler that can only be opened for writing.
   * @param out an output object
   */
  public DataInputOutputHandler(DataOutput out)
  {
    this(null, out, CLOSE_STREAM_ON_CLOSE);
  }

  /**
   * Create a handler that can only be opened for reading,
   * writing and seeking.
   * @param file a file to use.
   */
  public DataInputOutputHandler(RandomAccessFile file)
  {
    this(file, file, CLOSE_STREAM_ON_CLOSE);
  }

  /**
   * Creates a new handler.  If you pass in non null arguments
   * for both in and out, the handler may be opened in either
   * {@link IURLProtocolHandler#URL_RDONLY_MODE} or
   * {@link IURLProtocolHandler#URL_WRONLY_MODE}, but not at
   * the same time.
   *

   * {@link IURLProtocolHandler#URL_RDWR} mode is supported
   * by this handler if both in and out are instances of
   * {@link RandomAccessFile}.
   *

   * @param in The object to read from if asked to.
   * @param out The object to write from if asked to.
   * @param closeStreamOnClose Whether or not to automatically
   *   call {@link Closeable#close()} on the given channel
   *   when {@link #close()} is called.
   */
  public DataInputOutputHandler(
      DataInput in, DataOutput out,
      boolean closeStreamOnClose)
  {
    if (in == null && out == null)
      throw new IllegalArgumentException("must pass one non null stream");
    mDataInput = in;
    mDataOutput = out;
    mCloseStreamOnClose = closeStreamOnClose;
  }

  /**
   * {@inheritDoc}
   */

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

  /**
   * {@inheritDoc}
   */

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

    return 0;
  }

  /**
   * {@inheritDoc}
   */

  public int read(byte[] buf, int size)
  {
    int ret = -1;
    if (mOpenStream == null || !(mOpenStream instanceof DataInput))
      return -1;

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

  /**
   * {@inheritDoc}
   *
   * This method is not supported on this class and always return -1;
   */

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

      file.seek(seek);
      return seek;
    }
    catch (IOException e)
    {
      log.debug("got io exception \"{}\" while seeking in: {}", e
          .getMessage(), file);
      return -1;
    }
  }

  /**
   * {@inheritDoc}
   */

  public int write(byte[] buf, int size)
  {
    if (mOpenStream == null ||
        !(mOpenStream instanceof DataOutput))
      return -1;

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

  /**
   * {@inheritDoc}
   * Always true, unless we're inputting or outputting to a
   * {@link RandomAccessFile}.
   */

  public boolean isStreamed(String url, int flags)
  {
    if (mDataInput != null && mDataInput instanceof RandomAccessFile)
      return false;
    if (mDataOutput != null && mDataOutput instanceof RandomAccessFile)
      return false;
    return true;
  }
  /**
   * Returns the {@link DataInput} we'd input from if asked.
   * @return the {@link DataInput}
   */
  public DataInput getDataInput()
  {
    return mDataInput;
  }
  /**
   * Returns the {@link DataOutput} we'd output to if asked.
   * @return the {@link DataOutput}
   */
  public DataOutput getDataOutput()
  {
    return mDataOutput;
  }
  /**
   * Returns the object currently {@link #open(String, int)}.
   * @return the open object
   */
  public Object getOpen()
  {
    return mOpenStream;
  }

  /**
   * Will this handler call {@link Closeable#close()} automatically
   * when its {@link #close()} method is called by Humble Video?
   *
   * We will check if the object we're using supports {@link Closeable}.
   *
   * @return the closeStreamOnClose setting
   */
  public boolean isCloseStreamOnClose()
  {
    return mCloseStreamOnClose;
  }

}


/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * Descriptor that unambiguously describes how the bits of a pixel are

 * stored in the up to 4 data planes of an image. It also stores the

 * subsampling factors and number of components.

 *

 * Note: This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV

 *       and all the YUV variants) AVPixFmtDescriptor just stores how values

 *       are stored not what these values represent.
 */
public class PixelFormatDescriptor extends RefCounted {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected PixelFormatDescriptor(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.PixelFormatDescriptor_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected PixelFormatDescriptor(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.PixelFormatDescriptor_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(PixelFormatDescriptor obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new PixelFormatDescriptor object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public PixelFormatDescriptor copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new PixelFormatDescriptor(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof PixelFormatDescriptor)
      equal = (((PixelFormatDescriptor)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

/**
 * Get the name of this pixel descriptor
 */
  public String getName() {
    return VideoJNI.PixelFormatDescriptor_getName(swigCPtr, this);
  }

/**
 * The number of components each pixel has, (1-4)
 */
  public short getNumComponents() {
    return VideoJNI.PixelFormatDescriptor_getNumComponents(swigCPtr, this);
  }

/**
 * Amount to shift the luma width right to find the chroma width.

 * For YV12 this is 1 for example.

 * chroma_width = -((-luma_width) >> log2_chroma_w)

 * The note above is needed to ensure rounding up.

 * This value only refers to the chroma components.
 */
  public short getLog2ChromaWidth() {
    return VideoJNI.PixelFormatDescriptor_getLog2ChromaWidth(swigCPtr, this);
  }

/**
 * Amount to shift the luma height right to find the chroma height.

 * For YV12 this is 1 for example.

 * chroma_height= -((-luma_height) >> log2_chroma_h)

 * The note above is needed to ensure rounding up.

 * This value only refers to the chroma components.
 */
  public short getLog2ChromaHeight() {
    return VideoJNI.PixelFormatDescriptor_getLog2ChromaHeight(swigCPtr, this);
  }

/**
 * Get the flags for this Pixel Format. This is a bitmask of the PixelFormatDescriptor.Flag enum values.
 */
  public short getFlags() {
    return VideoJNI.PixelFormatDescriptor_getFlags(swigCPtr, this);
  }

/**
 * Is the given flag set on this format?
 */
  public boolean getFlag(PixelFormatDescriptor.Flag flag) {
    return VideoJNI.PixelFormatDescriptor_getFlag(swigCPtr, this, flag.swigValue());
  }

/**
 * Return the number of bits per pixel used by the pixel format

 * described by pixdesc. Note that this is not the same as the number

 * of bits per sample.

 *

 * The returned number of bits refers to the number of bits actually

 * used for storing the pixel information, that is padding bits are

 * not counted.
 */
  public int getBitsPerPixel() {
    return VideoJNI.PixelFormatDescriptor_getBitsPerPixel(swigCPtr, this);
  }

/**
 * Return the number of bits per pixel for the pixel format

 * described by pixdesc, including any padding or unused bits.
 */
  public int getPaddedBitsPerPixel() {
    return VideoJNI.PixelFormatDescriptor_getPaddedBitsPerPixel(swigCPtr, this);
  }

/**
 * Parameters that describe how pixels are packed.

 * If the format has 2 or 4 components, then alpha is last.

 * If the format has 1 or 2 components, then luma is 0.

 * If the format has 3 or 4 components,

 * if the RGB flag is set then 0 is red, 1 is green and 2 is blue;

 * otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
 */
  public PixelComponentDescriptor getComponentDescriptor(int component) {
    long cPtr = VideoJNI.PixelFormatDescriptor_getComponentDescriptor(swigCPtr, this, component);
    return (cPtr == 0) ? null : new PixelComponentDescriptor(cPtr, false);
  }

/**
 * @return an PixelFormat id described by desc, or PixelFormat.Type.PIX_FMT_NONE if desc

 * is not a valid pointer to a pixel format descriptor.
 */
  public PixelFormat.Type getFormat() {
    return PixelFormat.Type.swigToEnum(VideoJNI.PixelFormatDescriptor_getFormat(swigCPtr, this));
  }

  public enum Flag {
  /**
   * Pixel format is big-endian.
   */
    PIX_FMT_FLAG_BE(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_BE_get()),
  /**
   * Pixel format has a palette in data[1], values are indexes in this palette.
   */
    PIX_FMT_FLAG_PAL(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_PAL_get()),
  /**
   * All values of a component are bit-wise packed end to end.
   */
    PIX_FMT_FLAG_BITSTREAM(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_BITSTREAM_get()),
  /**
   * Pixel format is an HW accelerated format.
   */
    PIX_FMT_FLAG_HWACCEL(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_HWACCEL_get()),
  /**
   * At least one pixel component is not in the first data plane.
   */
    PIX_FMT_FLAG_PLANAR(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_PLANAR_get()),
  /**
   * The pixel format contains RGB-like data (as opposed to YUV/grayscale).
   */
    PIX_FMT_FLAG_RGB(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_RGB_get()),
  /**
   * The pixel format is "pseudo-paletted". This means that FFmpeg treats it as

   * paletted internally, but the palette is generated by the decoder and is not

   * stored in the file.
   */
    PIX_FMT_FLAG_PSEUDOPAL(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_PSEUDOPAL_get()),
  /**
   * The pixel format has an alpha channel.
   */
    PIX_FMT_FLAG_ALPHA(VideoJNI.PixelFormatDescriptor_PIX_FMT_FLAG_ALPHA_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Flag swigToEnum(int swigValue) {
      Flag[] swigValues = Flag.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Flag swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Flag.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Flag() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Flag(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Flag(Flag swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

}


/*
 * Copyright (c) 2014, Andrew "Art" Clarke.  All rights reserved.
 *
 * This file is part of Humble-Video.
 *
 * Humble-Video is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Humble-Video is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Humble-Video.  If not, see <http://www.gnu.org/licenses/>.
 */
package io.humble.video_native;

/**
 * A class for finding out version information about this jar.
 * @author aclarke
 *
 */
public class Version {
  /** Private class; cannot construct */
  private Version() {};

  /**
   * Prints the version of this library to System.out along with
   * some information on what this jar is.
   */
  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();
  }

}


/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * A collection of static functions that refer to the entire package (like version getters).
 */
public class Global extends RefCounted {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected Global(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.Global_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected Global(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.Global_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(Global obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new Global object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public Global copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new Global(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof Global)
      equal = (((Global)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

  /**
   * The default unit of time that {@link MediaRaw} time stamps are represented in.
   */
  public static final java.util.concurrent.TimeUnit DEFAULT_TIME_UNIT =
    java.util.concurrent.TimeUnit.MICROSECONDS;

/**
 * The default timebase used by media if not otherwise specified.
 */
  public static Rational getDefaultTimeBase() {
    long cPtr = VideoJNI.Global_getDefaultTimeBase();
    return (cPtr == 0) ? null : new Rational(cPtr, false);
  }

/**
 * Get the major version number of this library.

 * @return the major version number of this library or 0 if unknown.
 */
  public static int getVersionMajor() {
    return VideoJNI.Global_getVersionMajor();
  }

/**
 * Get the minor version number of this library.

 * @return the minor version number of this library or 0 if unknown.
 */
  public static int getVersionMinor() {
    return VideoJNI.Global_getVersionMinor();
  }

/**
 * Get a string representation of the version of this library.

 * @return the version of this library in string form.
 */
  public static String getVersionStr() {
    return VideoJNI.Global_getVersionStr();
  }

/**
 * Get the version of the FFMPEG libavformat library we are compiled against.

 * @return the version.
 */
  public static int getAVFormatVersion() {
    return VideoJNI.Global_getAVFormatVersion();
  }

/**
 * Get the version of the FFMPEG libavformat library we are compiled against.

 * @return the version.
 */
  public static String getAVFormatVersionStr() {
    return VideoJNI.Global_getAVFormatVersionStr();
  }

/**
 * Get the version of the FFMPEG libavcodec library we are compiled against.

 * @return the version.
 */
  public static int getAVCodecVersion() {
    return VideoJNI.Global_getAVCodecVersion();
  }

/**
 * Get the version of the FFMPEG libavcodec library we are compiled against.

 * @return the version.
 */
  public static String getAVCodecVersionStr() {
    return VideoJNI.Global_getAVCodecVersionStr();
  }

/**
 * Internal Only.  Do not call.

 * Methods using the C++ interface that will not necessarily

 * create other Global object should call this.  In general,

 * unless you're extending Humble Video directly yourself, ordinary

 * users of this library don't need to call this.

 *

 * It's main purpose is to ensure any FFmpeg required environment

 * initialization functions are called, and any Humble Video required

 * environmental contexts are set up.

 *

 */
  public static void init() {
    VideoJNI.Global_init();
  }

/**
 * Internal Only.  This method can be used to turn up or

 * down FFmpeg's logging level.

 * @param level An integer value for level.  Lower numbers

 *   mean less logging.  A negative number tells FFmpeg to

 *   shut up.
 */
  public static void setFFmpegLoggingLevel(int level) {
    VideoJNI.Global_setFFmpegLoggingLevel(level);
  }

/**
 * A value that means no time stamp is set for a given object.

 * if the Media#getTimeStamp() method of an

 * object returns this value it means the time stamp wasn't set.
 */
  public final static long NO_PTS = VideoJNI.Global_NO_PTS_get();
/**
 * The default time units per second that we use for decoded

 * MediaRaw objects.

 *

 * This means that 1 tick of a time stamp is 1 Microsecond.
 */
  public final static long DEFAULT_PTS_PER_SECOND = VideoJNI.Global_DEFAULT_PTS_PER_SECOND_get();
}


/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.6
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package io.humble.video;
import io.humble.ferry.*;
/**
 * Represents settable properties that effect how Humble Video objects

 * operate.

 *

 * For example, setting the "b" property on an

 * IStreamCoder sets the bit-rate the coder will attempt

 * to encode at.

 *

 */
public class Property extends RefCounted {
  // JNIHelper.swg: Start generated code
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>
  /**
   * This method is only here to use some references and remove
   * a Eclipse compiler warning.
   */
  @SuppressWarnings("unused")
  private void noop()
  {
    Buffer.make(null, 1);
  }

  private volatile long swigCPtr;

  /**
   * Internal Only.
   */
  protected Property(long cPtr, boolean cMemoryOwn) {
    super(VideoJNI.Property_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.
   */
  protected Property(long cPtr, boolean cMemoryOwn,
      java.util.concurrent.atomic.AtomicLong ref)
  {
    super(VideoJNI.Property_SWIGUpcast(cPtr),
     cMemoryOwn, ref);
    swigCPtr = cPtr;
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that obj is proxying for.
   *
   * @param obj The java proxy object for a native object.
   * @return The raw pointer obj is proxying for.
   */
  protected static long getCPtr(Property obj) {
    if (obj == null) return 0;
    return obj.getMyCPtr();
  }

  /**
   * Internal Only.  Not part of public API.
   *
   * Get the raw value of the native object that we're proxying for.
   *
   * @return The raw pointer we're proxying for.
   */
  protected long getMyCPtr() {
    if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted");
    return swigCPtr;
  }

  /**
   * Create a new Property object that is actually referring to the
   * exact same underlying native object.
   *
   * @return the new Java object.
   */
  @Override
  public Property copyReference() {
    if (swigCPtr == 0)
      return null;
    else
      return new Property(swigCPtr, swigCMemOwn, getJavaRefCount());
  }

  /**
   * Compares two values, returning true if the underlying objects in native code are the same object.
   *
   * That means you can have two different Java objects, but when you do a comparison, you'll find out
   * they are the EXACT same object.
   *
   * @return True if the underlying native object is the same.  False otherwise.
   */
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof Property)
      equal = (((Property)obj).swigCPtr == this.swigCPtr);
    return equal;
  }

  /**
   * Get a hashable value for this object.
   *
   * @return the hashable value.
   */
  public int hashCode() {
     return (int)swigCPtr;
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<
  // JNIHelper.swg: End generated code

/**
 * Get the name for this property.

 *

 * @return the name.
 */
  public String getName() {
    return VideoJNI.Property_getName(swigCPtr, this);
  }

/**
 * Get the (English) help string for this property.

 *

 * @return the help string
 */
  public String getHelp() {
    return VideoJNI.Property_getHelp(swigCPtr, this);
  }

/**
 * Get any sub-unit this option or constant belongs to.

 *

 * @return the unit, or null if none.
 */
  public String getUnit() {
    return VideoJNI.Property_getUnit(swigCPtr, this);
  }

/**
 * Get the underlying native type of this property.

 *

 * @return the type
 */
  public Property.Type getType() {
    return Property.Type.swigToEnum(VideoJNI.Property_getType(swigCPtr, this));
  }

/**
 * Get any set flags (a bitmask) for this option.

 *

 * @return the flags
 */
  public int getFlags() {
    return VideoJNI.Property_getFlags(swigCPtr, this);
  }

/**
 * Get the default setting this flag would have it not set.

 *

 * @return the default
 */
  public long getDefault() {
    return VideoJNI.Property_getDefault(swigCPtr, this);
  }

/**
 * Get the default setting this flag would have it not set.

 *

 * @return the default
 */
  public double getDefaultAsDouble() {
    return VideoJNI.Property_getDefaultAsDouble(swigCPtr, this);
  }

/**
 * If this IProperty is of the type Type#PROPERTY_FLAGS, this method will

 * tell you how many different flag settings it takes.

 *

 * @return Number of flag settings, or <0 if not a FLAGS value
 */
  public int getNumFlagSettings() {
    return VideoJNI.Property_getNumFlagSettings(swigCPtr, this);
  }

/**
 * If this IProperty is of the type Type#PROPERTY_FLAGS, this method will

 * give you another IProperty representing a constant setting for that flag.

 *

 * @param position The position number for the flag;  Must be in range 0 <= position <= #getNumFlagSettings().

 *

 * @return An IProperty object for the flag setting, or null if not available.
 */
  public Property getFlagConstant(int position) {
    long cPtr = VideoJNI.Property_getFlagConstant__SWIG_0(swigCPtr, this, position);
    return (cPtr == 0) ? null : new Property(cPtr, false);
  }

/**
 * If this IProperty is of the type Type#PROPERTY_FLAGS, this method will

 * give you another IProperty representing a constant setting for that flag.

 *

 * @param name The name of the constant.

 *

 * @return An IProperty object for the flag setting, or null if not available.
 */
  public Property getFlagConstant(String name) {
    long cPtr = VideoJNI.Property_getFlagConstant__SWIG_1(swigCPtr, this, name);
    return (cPtr == 0) ? null : new Property(cPtr, false);
  }

  /**
   * The different type of options that are supported by Humble Video.

   *

   * Well, actually by FFMPEG, but you get the idea.
   */
  public enum Type {
    PROPERTY_FLAGS,
    PROPERTY_INT,
    PROPERTY_INT64,
    PROPERTY_DOUBLE,
    PROPERTY_FLOAT,
    PROPERTY_STRING,
    PROPERTY_RATIONAL,
    PROPERTY_BINARY,
    PROPERTY_CONST(VideoJNI.Property_PROPERTY_CONST_get()),
    PROPERTY_IMAGE_SIZE(VideoJNI.Property_PROPERTY_IMAGE_SIZE_get()),
    PROPERTY_PIXEL_FMT(VideoJNI.Property_PROPERTY_PIXEL_FMT_get()),
    PROPERTY_SAMPLE_FMT(VideoJNI.Property_PROPERTY_SAMPLE_FMT_get()),
  /**
   * offset must point to AVRational
   */
    PROPERTY_VIDEO_RATE(VideoJNI.Property_PROPERTY_VIDEO_RATE_get()),
    PROPERTY_DURATION(VideoJNI.Property_PROPERTY_DURATION_get()),
    PROPERTY_COLOR(VideoJNI.Property_PROPERTY_COLOR_get()),
    PROPERTY_CHANNEL_LAYOUT(VideoJNI.Property_PROPERTY_CHANNEL_LAYOUT_get()),
    PROPERTY_UNKNOWN(VideoJNI.Property_PROPERTY_UNKNOWN_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Type swigToEnum(int swigValue) {
      Type[] swigValues = Type.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Type swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Type() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Type(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Type(Type swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

  public enum Flags {
    FLAG_ENCODING_PARAM(VideoJNI.Property_FLAG_ENCODING_PARAM_get()),
    FLAG_DECODING_PARAM(VideoJNI.Property_FLAG_DECODING_PARAM_get()),
    FLAG_METADATA(VideoJNI.Property_FLAG_METADATA_get()),
    FLAG_AUDIO_PARAM(VideoJNI.Property_FLAG_AUDIO_PARAM_get()),
    FLAG_VIDEO_PARAM(VideoJNI.Property_FLAG_VIDEO_PARAM_get()),
    FLAG_SUBTITLE_PARAM(VideoJNI.Property_FLAG_SUBTITLE_PARAM_get()),
    FLAG_FILTERING_PARAM(VideoJNI.Property_FLAG_FILTERING_PARAM_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Flags swigToEnum(int swigValue) {
      Flags[] swigValues = Flags.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Flags swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Flags.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Flags() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Flags(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Flags(Flags swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

  /**
   * How to search options when looking for different values.
   */
  public enum Search {
  /**
   * Do not search child options
   */
    PROPERTY_SEARCH_DEFAULT(VideoJNI.Property_PROPERTY_SEARCH_DEFAULT_get()),
  /**
   * Search children first
   */
    PROPERTY_SEARCH_CHILDREN(VideoJNI.Property_PROPERTY_SEARCH_CHILDREN_get()),
  ;

    public final int swigValue() {
      return swigValue;
    }

    public static Search swigToEnum(int swigValue) {
      Search[] swigValues = Search.class.getEnumConstants();
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (Search swigEnum : swigValues)
        if (swigEnum.swigValue == swigValue)
          return swigEnum;
      throw new IllegalArgumentException("No enum " + Search.class + " with value " + swigValue);
    }

    @SuppressWarnings("unused")
    private Search() {
      this.swigValue = SwigNext.next++;
    }

    @SuppressWarnings("unused")
    private Search(int swigValue) {
      this.swigValue = swigValue;
      SwigNext.next = swigValue+1;
    }

    @SuppressWarnings("unused")
    private Search(Search swigEnum) {
      this.swigValue = swigEnum.swigValue;
      SwigNext.next = this.swigValue+1;
    }

    private final int swigValue;

    private static class SwigNext {
      private static int next = 0;
    }
  }

}