/** * Write data to the stream as content of DataPhase (StartData -> [Data] -> EndData) * * @param transactionID * @param data * @throws IOException */ public void writeData(UINT32 transactionID, byte[] data) throws IOException { // Send StartData StartDataPacket startDataPacket = new StartDataPacket(transactionID, new UINT64(data.length)); write(startDataPacket); long packetLength = UINT32.SIZE_IN_BYTES + PtpIpPacket.Type.SIZE_IN_BYTES + UINT32.SIZE_IN_BYTES + data.length; // Send EndData os.write(new UINT32(packetLength)); os.write(PtpIpPacket.Type.END_DATA.value()); os.write(transactionID); os.write(data); os.flush(); }
/** * Write PTP-IP Packet to the stream. * * @param packet * @throws IOException */ public void write(PtpIpPacket packet) throws IOException { os.write(packet.bytes()); os.flush(); }