Class IMediaData

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected IMediaData​(long cPtr, boolean cMemoryOwn)
      Internal Only.
      protected IMediaData​(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)
      Internal Only.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IMediaData copyReference()
      Create a new IMediaData object that is actually referring to the exact same underlying native object.
      void delete()
      Releases this instance of IMediaData and frees any underlying native memory.
      boolean equals​(java.lang.Object obj)
      Compares two values, returning true if the underlying objects in native code are the same object.
      void get​(int srcPos, byte[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, char[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, double[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, float[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, int[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, long[] dest, int destPos, int length)
      Absolute bulk get method.
      void get​(int srcPos, short[] dest, int destPos, int length)
      Absolute bulk get method.
      java.nio.ByteBuffer getByteBuffer()
      Gets the underlying ByteBuffer for this IMediaData object.
      java.nio.ByteBuffer getByteBuffer​(java.util.concurrent.atomic.AtomicReference<JNIReference> ref)
      Gets the underlying ByteBuffer for this IMediaData object.
      static long getCPtr​(IMediaData obj)
      Internal Only.
      IBuffer getData()
      Get any underlying raw data available for this object.
      protected IBuffer getData_internal()
      Get any underlying raw data available for this object.

      IBuffer getDataCached()
      Get any underlying raw data available for this object, but do not create a new Java wrapping object for it.
      java.lang.String getFormattedTimeStamp()
      Get a string representation of the time stamp for this IMediaData.
      java.lang.String getFormattedTimeStamp​(java.lang.String format)
      Get a string representation of the time stamp for this IMediaData.
      long getMyCPtr()
      Internal Only.
      int getSize()
      Get the size in bytes of the raw data available for this object.

      IRational getTimeBase()
      Get the time base that time stamps of this object are represented in.

      Caller must release the returned value.

      long getTimeStamp()
      Get the time stamp of this object in getTimeBase() units.

      int hashCode()
      Get a hashable value for this object.
      boolean isKey()
      Is this object a key object? i.e.
      void put​(byte[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(char[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(double[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(float[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(int[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(long[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void put​(short[] src, int srcPos, int destPos, int length)
      Absolute bulk put method.
      void setData​(IBuffer buffer)
      Sets the underlying buffer used by this object.
      protected void setData_internal​(IBuffer buffer)
      Sets the underlying buffer used by this object.
      void setTimeBase​(IRational aBase)
      Set the time base that time stamps of this object are represented in.

      void setTimeStamp​(long aTimeStamp)
      Set the time stamp for this object in getTimeBase() units.

      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IMediaData

        protected IMediaData​(long cPtr,
                             boolean cMemoryOwn)
        Internal Only.
      • IMediaData

        protected IMediaData​(long cPtr,
                             boolean cMemoryOwn,
                             java.util.concurrent.atomic.AtomicLong ref)
        Internal Only.
    • Method Detail

      • getCPtr

        public static long getCPtr​(IMediaData obj)
        Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.
        Parameters:
        obj - The java proxy object for a native object.
        Returns:
        The raw pointer obj is proxying for.
      • getMyCPtr

        public long getMyCPtr()
        Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.
        Overrides:
        getMyCPtr in class RefCounted
        Returns:
        The raw pointer we're proxying for.
      • copyReference

        public IMediaData copyReference()
        Create a new IMediaData object that is actually referring to the exact same underlying native object.
        Overrides:
        copyReference in class RefCounted
        Returns:
        the new Java object.
      • equals

        public boolean equals​(java.lang.Object obj)
        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.
        Overrides:
        equals in class java.lang.Object
        Returns:
        True if the underlying native object is the same. False otherwise.
      • hashCode

        public int hashCode()
        Get a hashable value for this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashable value.
      • getByteBuffer

        public java.nio.ByteBuffer getByteBuffer()
        Gets the underlying ByteBuffer for this IMediaData object. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. See IBuffer for the warnings associated with the use of raw memory. The buffer position and mark are initialized to zero, and the limit is initialized to the number of elements in the buffer.

        This is a convenience method to allow you to avoid getting the IBuffer object that has the actual data.

        Returns:
        The underlying ByteBuffer
        See Also:
        IBuffer.getByteBuffer(int, int)
      • getByteBuffer

        public java.nio.ByteBuffer getByteBuffer​(java.util.concurrent.atomic.AtomicReference<JNIReference> ref)
        Gets the underlying ByteBuffer for this IMediaData object. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. See IBuffer for the warnings associated with the use of raw memory. The buffer position and mark are initialized to zero, and the limit is initialized to the number of elements in the buffer.

        This is a convenience method to allow you to avoid getting the IBuffer object that has the actual data.

        Parameters:
        ref - A reference that on return from this method will contain a JNIReference object that can be used for explicit memory management.
        Returns:
        The underlying ByteBuffer
        See Also:
        IBuffer.getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)
      • getFormattedTimeStamp

        public java.lang.String getFormattedTimeStamp​(java.lang.String format)
        Get a string representation of the time stamp for this IMediaData. The format of the resulting string is specified by the format parameter. See Formatter for details on how to specify formats, however a good place to start is with the following format: %1$tH:%1$tM:%1$tS.%1$tL
        Parameters:
        format - the format for the time stamp string
        Returns:
        the printable string form of the timestamp
        See Also:
        getFormattedTimeStamp(), DEFAULT_TIME_STAMP_FORMAT, Formatter
      • getData

        public IBuffer getData()
        Get any underlying raw data available for this object.
        Returns:
        The raw data, or null if not accessible.
      • setData

        public void setData​(IBuffer buffer)
        Sets the underlying buffer used by this object.

        This is an advanced method and is not recommended for use by those who don't fully understand how IBuffers work. Implementations of IMediaData may behave in undefined ways if the buffer you pass in is not big enough for what you ask them to do (e.g. they may discard your buffer and allocate a larger one if they need more space). It is up to the caller to ensure the buffer passed in is large enough, and is not simultaneously in use by another part of the system.

        Parameters:
        buffer - The buffer to set. If null, this method is ignored.
        Since:
        3.2
      • getDataCached

        public IBuffer getDataCached()
        Get any underlying raw data available for this object, but do not create a new Java wrapping object for it.

        Do not call RefCounted.delete() on the returned value.

        Returns:
        The raw data, or null if not accessible.
        Since:
        3.2
      • delete

        public void delete()
        Releases this instance of IMediaData and frees any underlying native memory.

        Releases any underlying native memory and marks this object as invalid.

        Normally Ferry manages when to release native memory.

        In the unlikely event you want to control EXACTLY when a native object is released, each AVPKit object has a RefCounted.delete() method that you can use. Once you call RefCounted.delete(), you must ENSURE your object is never referenced again from that Java object -- Ferry tries to help you avoid crashes if you accidentally use an object after deletion but on this but we cannot offer 100% protection (specifically if another thread is accessing that object EXACTLY when you RefCounted.delete() it).

        Overrides:
        delete in class RefCounted
      • getTimeStamp

        public long getTimeStamp()
        Get the time stamp of this object in getTimeBase() units.

        Returns:
        the time stamp
      • setTimeStamp

        public void setTimeStamp​(long aTimeStamp)
        Set the time stamp for this object in getTimeBase() units.

        Parameters:
        aTimeStamp - The time stamp
      • getTimeBase

        public IRational getTimeBase()
        Get the time base that time stamps of this object are represented in.

        Caller must release the returned value.

        Returns:
        the time base.
      • setTimeBase

        public void setTimeBase​(IRational aBase)
        Set the time base that time stamps of this object are represented in.

        Parameters:
        aBase - the new time base. If null an exception is thrown.
      • getData_internal

        protected IBuffer getData_internal()
        Get any underlying raw data available for this object.

        Returns:
        The raw data, or null if not accessible.
      • getSize

        public int getSize()
        Get the size in bytes of the raw data available for this object.

        Returns:
        the size in bytes, or -1 if it cannot be computed.
      • isKey

        public boolean isKey()
        Is this object a key object? i.e. it can be interpreted without needing any other media objects

        Returns:
        true if it's a key, false if not
      • setData_internal

        protected void setData_internal​(IBuffer buffer)
        Sets the underlying buffer used by this object.


        This is an advanced method and is not recommended for use by those
        who don't fully understand how IBuffers work. Implementations of
        {IMediaData} may behave in undefined ways if the buffer you
        pass in is not big enough for what you ask them to do (e.g. they may
        discard your buffer and allocate a larger one if they need more space).
        It is up to the caller to ensure the buffer passed in is large enough,
        and is not simultaneously in use by another part of the system.


        Parameters:
        buffer - The buffer to set. If null, this method
        is ignored.