package net.northking.cctp.upperComputer.driver.agent.command.data;

public class ScreenVideoFrame {


    // The follow flag constants MUST stay in sync with their equivalents
    // in MediaCodec.h !

    /**
     * This indicates that the (encoded) buffer marked as such contains
     * the data for a key frame.
     */
    public static final int BUFFER_FLAG_KEY_FRAME = 1;

    /**
     * This indicated that the buffer marked as such contains codec
     * initialization / codec specific data instead of media data.
     */
    public static final int BUFFER_FLAG_CODEC_CONFIG = 2;

    /**
     * This signals the end of stream, i.e. no buffers will be available
     * after this, unless of course, flush follows.
     */
    public static final int BUFFER_FLAG_END_OF_STREAM = 4;

    /**
     * This indicates that the buffer only contains part of a frame,
     * and the decoder should batch the data until a buffer without
     * this flag appears before decoding the frame.
     */
    public static final int BUFFER_FLAG_PARTIAL_FRAME = 8;

    /**
     * This indicates that the buffer contains non-media data for the
     * muxer to process.
     * <br>
     * All muxer data should start with a FOURCC header that determines the type of data.
     * <br>
     * For example, when it contains Exif data sent to a MediaMuxer track of
     * MediaFormat#MIMETYPE_IMAGE_ANDROID_HEIC type, the data must start with
     * Exif header ("Exif\0\0"), followed by the TIFF header (See JEITA CP-3451C Section 4.5.2.)
     */
    public static final int BUFFER_FLAG_MUXER_DATA = 16;

    public long presentationTimeUs;
    public int flags;

    public byte[] data = new byte[0];

    public boolean hasFlag(int flag) {
        return (flags & flag) > 0;
    }

    @Override
    public String toString() {
        return "ScreenVideoFrame{" +
                "presentationTimeUs=" + presentationTimeUs +
                ", flags=" + flags +
                ", dataLength=" + data.length +
                '}';
    }
}
