001package net.bramp.ffmpeg.nut;
002
003import com.google.common.base.MoreObjects;
004import java.io.IOException;
005
006/** Represents the footer of a NUT packet containing a checksum. */
007public class PacketFooter {
008  int checksum;
009
010  /** Reads and validates the packet footer checksum. */
011  public void read(NutDataInputStream in) throws IOException {
012    long expected = in.getCRC();
013    checksum = in.readInt();
014    if (checksum != expected) {
015      // throw new IOException(String.format("invalid packet checksum %X want %X", expected,
016      // checksum));
017      Packet.LOG.debug("invalid packet checksum {} want {}", expected, checksum);
018    }
019    in.resetCRC();
020  }
021
022  @Override
023  public String toString() {
024    return MoreObjects.toStringHelper(this).add("checksum", checksum).toString();
025  }
026}