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


import net.northking.cctp.upperComputer.driver.agent.command.data.ScreenVideoFrame;
import net.northking.cctp.upperComputer.driver.agent.command.protocol.AbstractProtocolCommand;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class WatchScreenVideoFrameCommand extends AbstractProtocolCommand<ScreenVideoFrame> {

    private static WatchScreenVideoFrameCommand instance;

    public static WatchScreenVideoFrameCommand getInstance() {
        if (instance == null) {
            instance = new WatchScreenVideoFrameCommand();
        }
        return instance;
    }

    @Override
    public int getCommandId() {
        return 44;
    }

    @Override
    public void doSend(DataOutput output) throws IOException {

    }

    @Override
    public ScreenVideoFrame buildReceive(DataInput input) throws IOException {
        ScreenVideoFrame videoFrame = new ScreenVideoFrame();
        videoFrame.presentationTimeUs = input.readLong();
        videoFrame.flags = input.readInt();
        int size = input.readInt();
        byte[] contentByteArray = new byte[size];
        input.readFully(contentByteArray);
        videoFrame.data = contentByteArray;
        return videoFrame;
    }
}
