Ejemplo n.º 1
0
  /**
   * Get the next rtp packet recorded in the rtpdump file.
   *
   * @param loopFile if true, when the end of the rtpdump file is reached, this
   *     <tt>RtpdumpFileReader</tt> will go back at the beginning of the file and get the first
   *     packet.
   * @return a <tt>RawPacket</tt> containing all the information and data of the next rtp packet
   *     recorded in the rtpdump file
   * @throws IOException if <tt>loopFile</tt> was false and the end of the file is reached.
   */
  public RawPacket getNextPacket(boolean loopFile) throws IOException {
    if (loopFile && (stream.getFilePointer() >= stream.length())) {
      resetFile();
    }

    byte[] rtpdumpPacket;
    int sizeInBytes;

    stream.readShort(); // read away an useless short (2 bytes)
    sizeInBytes = stream.readUnsignedShort();
    rtpdumpPacket = new byte[sizeInBytes];
    stream.readInt(); // read away the rtpdump timestamp

    stream.read(rtpdumpPacket);

    return new RawPacket(rtpdumpPacket, 0, rtpdumpPacket.length);
  }
Ejemplo n.º 2
0
  private void doTheDamnThing(RandomAccessFile fp) throws IOException {
    byte[] b = new byte[26];

    // Load IMPM header
    fp.read(b, 0, 4);
    if (b[0] == 'I' && b[1] == 'M' && b[2] == 'P' && b[3] == 'M') {
      loadDataIT(fp);
      return;
    }

    // Attempt to load XM
    fp.seek(0);
    if (Util.readStringNoNul(fp, b, 17).equals("Extended Module: ")) {
      fp.seek(17 + 20);
      if (fp.read() == 0x1A) {
        fp.seek(17);
        loadDataXM(fp);
        return;
      }
    }

    // Attempt to load ST3 module
    fp.seek(0x1C);
    if (fp.readUnsignedShort() == 0x1A10) {
      fp.seek(0);
      loadDataS3M(fp);
      return;
    }

    fp.seek(0);

    // Assume this is a .mod file
    if (true) {
      loadDataMOD(fp);
      return;
    }

    throw new RuntimeException("module format not supported");
  }