All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jitsi.impl.neomedia.quicktime.QTCaptureDecompressedVideoOutput Maven / Gradle / Ivy

Go to download

libjitsi is an advanced Java media library for secure real-time audio/video communication

The newest version!
/*
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jitsi.impl.neomedia.quicktime;

/**
 * Represents a QTKit QTCaptureDecompressedVideoOutput object.
 *
 * @author Lyubomir Marinov
 */
public class QTCaptureDecompressedVideoOutput
    extends QTCaptureOutput
{

    /**
     * Initializes a new QTCaptureDecompressedVideoOutput which
     * represents a new QTKit QTCaptureDecompressedVideoOutput object.
     */
    public QTCaptureDecompressedVideoOutput()
    {
        this(allocAndInit());
    }

    /**
     * Initializes a new QTCaptureDecompressedVideoOutput which is to
     * represent a new QTKit QTCaptureDecompressedVideoOutput object.
     *
     * @param ptr the pointer to the QTKit
     * QTCaptureDecompressedVideoOutput object to be represented by the
     * new instance
     */
    public QTCaptureDecompressedVideoOutput(long ptr)
    {
        super(ptr);
    }

    private static native long allocAndInit();

    /**
     * Called by the garbage collector to release system resources and perform
     * other cleanup.
     *
     * @see Object#finalize()
     */
    @Override
    protected void finalize()
    {
        release();
    }

    public NSDictionary pixelBufferAttributes()
    {
        long pixelBufferAttributesPtr = pixelBufferAttributes(getPtr());

        return
            (pixelBufferAttributesPtr == 0)
                ? null
                : new NSDictionary(pixelBufferAttributesPtr);
    }

    private static native long pixelBufferAttributes(long ptr);

    public boolean setAutomaticallyDropsLateVideoFrames(
            boolean automaticallyDropsLateVideoFrames)
    {
        return
            setAutomaticallyDropsLateVideoFrames(
                    getPtr(),
                    automaticallyDropsLateVideoFrames);
    }

    private static native boolean setAutomaticallyDropsLateVideoFrames(
            long ptr,
            boolean automaticallyDropsLateVideoFrames);

    public void setDelegate(Delegate delegate)
    {
        setDelegate(getPtr(), delegate);
    }

    private static native void setDelegate(long ptr, Delegate delegate);

    public void setPixelBufferAttributes(NSDictionary pixelBufferAttributes)
    {
        setPixelBufferAttributes(getPtr(), pixelBufferAttributes.getPtr());
    }

    private static native void setPixelBufferAttributes(
            long ptr,
            long pixelBufferAttributesPtr);

    /**
     * Represents the receiver of CVImageBuffer video frames and their
     * associated QTSampleBuffers captured by a
     * QTCaptureDecompressedVideoOutput.
     */
    public static abstract class Delegate
    {
        private MutableQTSampleBuffer sampleBuffer;

        private MutableCVPixelBuffer videoFrame;

        /**
         * Notifies this Delegate that the QTCaptureOutput to
         * which it is set has output a specific CVImageBuffer
         * representing a video frame with a specific QTSampleBuffer.
         *
         * @param videoFrame the CVImageBuffer which represents the
         * output video frame
         * @param sampleBuffer the QTSampleBuffer which represents
         * additional details about the output video samples
         */
        public abstract void outputVideoFrameWithSampleBuffer(
                CVImageBuffer videoFrame,
                QTSampleBuffer sampleBuffer);

        // called from JNI
        void outputVideoFrameWithSampleBuffer(
                long videoFramePtr,
                long sampleBufferPtr)
        {
            if (videoFrame == null)
                videoFrame = new MutableCVPixelBuffer(videoFramePtr);
            else
                videoFrame.setPtr(videoFramePtr);

            if (sampleBuffer == null)
                sampleBuffer = new MutableQTSampleBuffer(sampleBufferPtr);
            else
                sampleBuffer.setPtr(sampleBufferPtr);

            outputVideoFrameWithSampleBuffer(videoFrame, sampleBuffer);
        }
    }

    /**
     * Represents a CVPixelBuffer which allows public changing of the
     * CoreVideo CVPixelBufferRef it represents.
     */
    private static class MutableCVPixelBuffer
        extends CVPixelBuffer
    {
        /**
         * Initializes a new MutableCVPixelBuffer which is to represent
         * a specific CoreVideo CVPixelBufferRef.
         *
         * @param ptr the CoreVideo CVPixelBufferRef to be represented
         * by the new instance
         */
        private MutableCVPixelBuffer(long ptr)
        {
            super(ptr);
        }

        /**
         * Sets the CoreVideo CVImageBufferRef represented by this
         * instance.
         *
         * @param ptr the CoreVideo CVImageBufferRef to be represented
         * by this instance
         * @see CVPixelBuffer#setPtr(long)
         */
        @Override
        public void setPtr(long ptr)
        {
            super.setPtr(ptr);
        }
    }

    /**
     * Represents a QTSampleBuffer which allows public changing of the
     * QTKit QTSampleBuffer object it represents.
     */
    private static class MutableQTSampleBuffer
        extends QTSampleBuffer
    {
        /**
         * Initializes a new MutableQTSampleBuffer instance which is to
         * represent a specific QTKit QTSampleBuffer object.
         *
         * @param ptr the pointer to the QTKit QTSampleBuffer object to
         * be represented by the new instance
         */
        private MutableQTSampleBuffer(long ptr)
        {
            super(ptr);
        }

        /**
         * Sets the pointer to the Objective-C object represented by this
         * instance.
         *
         * @param ptr the pointer to the Objective-C object to be represented by
         * this instance
         * @see QTSampleBuffer#setPtr(long)
         */
        @Override
        public void setPtr(long ptr)
        {
            super.setPtr(ptr);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy