Class VideoCodec

java.lang.Object
com.codename1.media.VideoCodec

public final class VideoCodec extends Object

Describes a single codec made available by the underlying platform, as returned by VideoIO#getAvailableEncoders() and VideoIO#getAvailableDecoders(). This lets an application discover, at runtime, which codecs the device can actually use and pick the best one for its needs.

Instances are immutable value objects. Capability fields that the platform cannot report are returned as -1 (integers) or empty arrays.

  • Constructor Summary

    Constructors
    Constructor
    Description
    VideoCodec(String id, String name, String mimeType, boolean video, boolean encoder, boolean decoder, boolean hardwareAccelerated, int maxWidth, int maxHeight, String[] supportedContainers)
    Creates a codec descriptor.
  • Method Summary

    Modifier and Type
    Method
    Description
    The stable identifier of this codec, e.g.
    int
    The maximum height in pixels supported by this codec, or -1 if the platform does not report a limit.
    int
    The maximum width in pixels supported by this codec, or -1 if the platform does not report a limit.
    The codec mime type when the platform reports one, otherwise null.
    A human readable name for this codec, suitable for display in a picker.
    The container formats (e.g. VideoIO#CONTAINER_MP4) this codec can be muxed into.
    boolean
    True if this codec can be used for decoding.
    boolean
    True if this codec can be used for encoding.
    boolean
    True if this codec is backed by dedicated hardware (and therefore typically much faster and more power efficient than a software codec).
    boolean
    True for a video codec, false for an audio codec.
    Returns a string representation of the object.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • VideoCodec

      public VideoCodec(String id, String name, String mimeType, boolean video, boolean encoder, boolean decoder, boolean hardwareAccelerated, int maxWidth, int maxHeight, String[] supportedContainers)

      Creates a codec descriptor. Normally created by platform implementations rather than application code.

      Parameters
      • id: the stable identifier of the codec, e.g. one of the VideoIO#CODEC_H264 constants

      • name: a human readable name for display

      • mimeType: the codec mime type when known (may be null)

      • video: true for a video codec, false for an audio codec

      • encoder: true if this codec can encode

      • decoder: true if this codec can decode

      • hardwareAccelerated: true if the codec is backed by dedicated hardware

      • maxWidth: the maximum supported width in pixels, or -1 if unknown

      • maxHeight: the maximum supported height in pixels, or -1 if unknown

      • supportedContainers: the container formats this codec can be muxed into (may be empty)

  • Method Details

    • getId

      public String getId()
      The stable identifier of this codec, e.g. VideoIO#CODEC_H264. Use this value when configuring a VideoWriterBuilder.
    • getName

      public String getName()
      A human readable name for this codec, suitable for display in a picker.
    • getMimeType

      public String getMimeType()
      The codec mime type when the platform reports one, otherwise null.
    • isVideo

      public boolean isVideo()
      True for a video codec, false for an audio codec.
    • isEncoder

      public boolean isEncoder()
      True if this codec can be used for encoding.
    • isDecoder

      public boolean isDecoder()
      True if this codec can be used for decoding.
    • isHardwareAccelerated

      public boolean isHardwareAccelerated()
      True if this codec is backed by dedicated hardware (and therefore typically much faster and more power efficient than a software codec).
    • getMaxWidth

      public int getMaxWidth()
      The maximum width in pixels supported by this codec, or -1 if the platform does not report a limit.
    • getMaxHeight

      public int getMaxHeight()
      The maximum height in pixels supported by this codec, or -1 if the platform does not report a limit.
    • getSupportedContainers

      public String[] getSupportedContainers()
      The container formats (e.g. VideoIO#CONTAINER_MP4) this codec can be muxed into. May be empty when unknown.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object