Class AbstractCodec2

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BUFFER_FLAG_FEC
      The Buffer flag which indicates that the respective Buffer contains audio data which has been decoded as a result of the operation of FEC.
      static int BUFFER_FLAG_PLC
      The Buffer flag which indicates that the respective Buffer contains audio data which has been decoded as a result of the operation of PLC.
      static javax.media.Format[] EMPTY_FORMATS
      An empty array of Format element type.
      protected int features
      The bitmap/flag mask of optional features supported by this AbstractCodec2 such as BUFFER_FLAG_FEC and BUFFER_FLAG_PLC.
      static int MAX_AUDIO_SEQUENCE_NUMBERS_TO_PLC
      The maximum number of lost sequence numbers to conceal with packet loss mitigation techniques such as Forward Error Correction (FEC) and Packet Loss Concealment (PLC) when dealing with audio.
      static int SEQUENCE_MAX
      The maximum (RTP) sequence number value.
      static int SEQUENCE_MIN
      The minimum (RTP) sequence number value.
      • Fields inherited from class net.sf.fmj.media.AbstractCodec

        inputFormat, inputFormats, opened, outputFormat
      • Fields inherited from interface javax.media.PlugIn

        BUFFER_PROCESSED_FAILED, BUFFER_PROCESSED_OK, INPUT_BUFFER_NOT_CONSUMED, OUTPUT_BUFFER_NOT_FILLED, PLUGIN_TERMINATED
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractCodec2​(String name, Class<? extends javax.media.Format> formatClass, javax.media.Format[] supportedOutputFormats)
      Initializes a new AbstractCodec2 instance with a specific PlugIn name, a specific Class of input and output Formats and a specific list of Formats supported as output.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static int calculateLostSeqNoCount​(long lastSeqNo, long seqNo)
      Calculates the number of sequences which have been lost i.e.
      void close()  
      protected void discardOutputBuffer​(javax.media.Buffer outputBuffer)  
      protected abstract void doClose()  
      protected abstract void doOpen()
      Opens this Codec and acquires the resources that it needs to operate.
      protected abstract int doProcess​(javax.media.Buffer inBuf, javax.media.Buffer outBuf)  
      protected javax.media.Format[] getMatchingOutputFormats​(javax.media.Format inputFormat)
      Gets the Formats which are supported by this Codec as output when the input is in a specific Format.
      String getName()  
      javax.media.Format[] getSupportedOutputFormats​(javax.media.Format inputFormat)
      Implements AbstractCodec.getSupportedOutputFormats(Format).
      static long incrementSeqNo​(long seqNo)
      Increments a specific sequence number and makes sure that the result stays within the range of valid RTP sequence number values.
      static javax.media.Format matches​(javax.media.Format in, javax.media.Format[] outs)
      Utility to perform format matching.
      void open()
      Opens this PlugIn software or hardware component and acquires the resources that it needs to operate.
      int process​(javax.media.Buffer inBuf, javax.media.Buffer outBuf)
      Implements AbstractCodec#process(Buffer, Buffer).
      javax.media.Format setInputFormat​(javax.media.Format format)  
      javax.media.Format setOutputFormat​(javax.media.Format format)  
      static javax.media.format.YUVFormat specialize​(javax.media.format.YUVFormat yuvFormat, Class<?> dataType)  
      protected void updateOutput​(javax.media.Buffer outputBuffer, javax.media.Format format, int length, int offset)
      Updates the format, length and offset of a specific output Buffer to specific values.
      static byte[] validateByteArraySize​(javax.media.Buffer buffer, int newSize, boolean arraycopy)
      Ensures that the value of the data property of a specific Buffer is an array of bytes whose length is at least a specific number of bytes.
      protected short[] validateShortArraySize​(javax.media.Buffer buffer, int newSize)  
      • Methods inherited from class net.sf.fmj.media.AbstractCodec

        checkInputBuffer, dump, getInputFormat, getOutputFormat, getSupportedInputFormats, isEOM, propagateEOM
      • Methods inherited from class net.sf.fmj.media.AbstractPlugIn

        reset
      • Methods inherited from class net.sf.fmj.media.AbstractControls

        addControl, getControl, getControls, removeControl
      • Methods inherited from interface javax.media.Controls

        getControl, getControls
      • Methods inherited from interface javax.media.PlugIn

        reset
    • Field Detail

      • BUFFER_FLAG_FEC

        public static final int BUFFER_FLAG_FEC
        The Buffer flag which indicates that the respective Buffer contains audio data which has been decoded as a result of the operation of FEC.
        See Also:
        Constant Field Values
      • BUFFER_FLAG_PLC

        public static final int BUFFER_FLAG_PLC
        The Buffer flag which indicates that the respective Buffer contains audio data which has been decoded as a result of the operation of PLC.
        See Also:
        Constant Field Values
      • EMPTY_FORMATS

        public static final javax.media.Format[] EMPTY_FORMATS
        An empty array of Format element type. Explicitly defined to reduce unnecessary allocations.
      • MAX_AUDIO_SEQUENCE_NUMBERS_TO_PLC

        public static final int MAX_AUDIO_SEQUENCE_NUMBERS_TO_PLC
        The maximum number of lost sequence numbers to conceal with packet loss mitigation techniques such as Forward Error Correction (FEC) and Packet Loss Concealment (PLC) when dealing with audio.
        See Also:
        Constant Field Values
      • SEQUENCE_MAX

        public static final int SEQUENCE_MAX
        The maximum (RTP) sequence number value.
        See Also:
        Constant Field Values
      • SEQUENCE_MIN

        public static final int SEQUENCE_MIN
        The minimum (RTP) sequence number value.
        See Also:
        Constant Field Values
      • features

        protected int features
        The bitmap/flag mask of optional features supported by this AbstractCodec2 such as BUFFER_FLAG_FEC and BUFFER_FLAG_PLC.
    • Constructor Detail

      • AbstractCodec2

        protected AbstractCodec2​(String name,
                                 Class<? extends javax.media.Format> formatClass,
                                 javax.media.Format[] supportedOutputFormats)
        Initializes a new AbstractCodec2 instance with a specific PlugIn name, a specific Class of input and output Formats and a specific list of Formats supported as output.
        Parameters:
        name - the PlugIn name of the new instance
        formatClass - the Class of input and output Formats supported by the new instance
        supportedOutputFormats - the list of Formats supported by the new instance as output
    • Method Detail

      • calculateLostSeqNoCount

        public static int calculateLostSeqNoCount​(long lastSeqNo,
                                                  long seqNo)
        Calculates the number of sequences which have been lost i.e. which have not been received.
        Parameters:
        lastSeqNo - the last received sequence number (prior to the current sequence number represented by seqNo.) May be Buffer.SEQUENCE_UNKNOWN. May be equal to seqNo for the purposes of Codec implementations which repeatedly process one and the same input Buffer multiple times.
        seqNo - the current sequence number. May be equal to lastSeqNo for the purposes of Codec implementations which repeatedly process one and the same input Buffer multiple times.
        Returns:
        the number of sequences (between lastSeqNo and seqNo) which have been lost i.e. which have not been received
      • incrementSeqNo

        public static long incrementSeqNo​(long seqNo)
        Increments a specific sequence number and makes sure that the result stays within the range of valid RTP sequence number values.
        Parameters:
        seqNo - the sequence number to increment
        Returns:
        a sequence number which represents an increment over the specified seqNo within the range of valid RTP sequence number values
      • matches

        public static javax.media.Format matches​(javax.media.Format in,
                                                 javax.media.Format[] outs)
        Utility to perform format matching.
        Parameters:
        in - input format
        outs - array of output formats
        Returns:
        the first output format that is supported
      • specialize

        public static javax.media.format.YUVFormat specialize​(javax.media.format.YUVFormat yuvFormat,
                                                              Class<?> dataType)
      • validateByteArraySize

        public static byte[] validateByteArraySize​(javax.media.Buffer buffer,
                                                   int newSize,
                                                   boolean arraycopy)
        Ensures that the value of the data property of a specific Buffer is an array of bytes whose length is at least a specific number of bytes.
        Parameters:
        buffer - the Buffer whose data property value is to be validated
        newSize - the minimum length of the array of byte which is to be the value of the data property of buffer
        arraycopy - true to copy the bytes which are in the value of the data property of buffer at the time of the invocation of the method if the value of the data property of buffer is an array of byte whose length is less than newSize; otherwise, false
        Returns:
        an array of bytes which is the value of the data property of buffer and whose length is at least newSize number of bytes
      • close

        public void close()
        Specified by:
        close in interface javax.media.PlugIn
        Overrides:
        close in class net.sf.fmj.media.AbstractPlugIn
      • discardOutputBuffer

        protected void discardOutputBuffer​(javax.media.Buffer outputBuffer)
      • doClose

        protected abstract void doClose()
      • doOpen

        protected abstract void doOpen()
                                throws javax.media.ResourceUnavailableException
        Opens this Codec and acquires the resources that it needs to operate. A call to PlugIn.open() on this instance will result in a call to doOpen only if AbstractCodec.opened is false. All required input and/or output formats are assumed to have been set on this Codec before doOpen is called.
        Throws:
        javax.media.ResourceUnavailableException - if any of the resources that this Codec needs to operate cannot be acquired
      • doProcess

        protected abstract int doProcess​(javax.media.Buffer inBuf,
                                         javax.media.Buffer outBuf)
      • getMatchingOutputFormats

        protected javax.media.Format[] getMatchingOutputFormats​(javax.media.Format inputFormat)
        Gets the Formats which are supported by this Codec as output when the input is in a specific Format.
        Parameters:
        inputFormat - the Format of the input for which the supported output Formats are to be returned
        Returns:
        an array of Formats supported by this Codec as output when the input is in the specified inputFormat
      • getName

        public String getName()
        Specified by:
        getName in interface javax.media.PlugIn
        Overrides:
        getName in class net.sf.fmj.media.AbstractPlugIn
      • getSupportedOutputFormats

        public javax.media.Format[] getSupportedOutputFormats​(javax.media.Format inputFormat)
        Implements AbstractCodec.getSupportedOutputFormats(Format).
        Specified by:
        getSupportedOutputFormats in interface javax.media.Codec
        Specified by:
        getSupportedOutputFormats in class net.sf.fmj.media.AbstractCodec
        Parameters:
        inputFormat - input format
        Returns:
        array of supported output format
        See Also:
        AbstractCodec.getSupportedOutputFormats(Format)
      • open

        public void open()
                  throws javax.media.ResourceUnavailableException
        Opens this PlugIn software or hardware component and acquires the resources that it needs to operate. All required input and/or output formats have to be set on this PlugIn before open is called. Buffers should not be passed into this PlugIn without first calling open.
        Specified by:
        open in interface javax.media.PlugIn
        Overrides:
        open in class net.sf.fmj.media.AbstractPlugIn
        Throws:
        javax.media.ResourceUnavailableException - if any of the resources that this PlugIn needs to operate cannot be acquired
        See Also:
        AbstractPlugIn.open()
      • process

        public int process​(javax.media.Buffer inBuf,
                           javax.media.Buffer outBuf)
        Implements AbstractCodec#process(Buffer, Buffer).
        Specified by:
        process in interface javax.media.Codec
        Specified by:
        process in class net.sf.fmj.media.AbstractCodec
        Parameters:
        inBuf -
        outBuf -
        Returns:
        BUFFER_PROCESSED_OK if the specified inBuff was successfully processed or BUFFER_PROCESSED_FAILED if the specified was not successfully processed
        See Also:
        AbstractCodec.process(Buffer, Buffer)
      • setInputFormat

        public javax.media.Format setInputFormat​(javax.media.Format format)
        Specified by:
        setInputFormat in interface javax.media.Codec
        Overrides:
        setInputFormat in class net.sf.fmj.media.AbstractCodec
      • setOutputFormat

        public javax.media.Format setOutputFormat​(javax.media.Format format)
        Specified by:
        setOutputFormat in interface javax.media.Codec
        Overrides:
        setOutputFormat in class net.sf.fmj.media.AbstractCodec
      • updateOutput

        protected void updateOutput​(javax.media.Buffer outputBuffer,
                                    javax.media.Format format,
                                    int length,
                                    int offset)
        Updates the format, length and offset of a specific output Buffer to specific values.
        Parameters:
        outputBuffer - the output Buffer to update the properties of
        format - the Format to set on outputBuffer
        length - the length to set on outputBuffer
        offset - the offset to set on outputBuffer
      • validateShortArraySize

        protected short[] validateShortArraySize​(javax.media.Buffer buffer,
                                                 int newSize)