Example #1
0
 private void Idle() throws IOException {
   write(Header.PT_ACK);
   readack();
 }
Example #2
0
  public void OpenDir(DvrDirectory poDir) {
    if (poDir.m_bIsOpen) return;

    Lock();
    try {
      Calendar loCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
      byte[] laGetDir = new byte[] // Command
          {Header.PT_GETDIR, 0, (byte) (poDir.m_oParent == null ? 0 : 1)};
      write(laGetDir); // Send
      readack();

      if (poDir.m_oParent != null) {
        write(poDir.m_cRemoteName);
        readbyte();
        ping();
      }

      short lnAnzElements = readshort();
      short lnIndex = 0;
      String lcFileName = "";
      long lnSize = 0;
      int lnTimeStamp = 0;
      while (lnAnzElements > 0) {
        loCalendar.set(1999, 12, 01, 00, 00, 00);
        byte lbType = readbyte();
        byte lbIsDir = 0;
        switch (lbType) {
          case 0: // Directory
            lbIsDir = readbyte();
            lcFileName = readstring();
            poDir.m_oDirectorys.add(new DvrDirectory(poDir, lcFileName, lcFileName, null));
            break;
          case 1: // Binary
            lcFileName = readstring();
            lnSize = readlong();
            lnTimeStamp = readint();
            loCalendar.add(Calendar.SECOND, lnTimeStamp);
            poDir.m_oFiles.add(
                new DvrFile(poDir, lcFileName, lnSize, (short) -1, lbType, loCalendar.getTime()));
            break;
          case 3: // TS Radio
          case 4: // TS File Record SD Quality
          case 7: // TS File Record HD Quality
            lbIsDir = readbyte();
            lnIndex = readbyte();
            lcFileName = readstring();
            lnSize = readlong();
            lnTimeStamp = readint();
            loCalendar.add(Calendar.SECOND, lnTimeStamp);
            poDir.m_oFiles.add(
                new DvrFile(poDir, lcFileName, lnSize, lnIndex, lbType, loCalendar.getTime()));
            break;
          case 9: // USB Memory Stick
            lbIsDir = readbyte();
            String lcDescription = readstring();
            String lcName = readstring();
            poDir.m_oDirectorys.add(
                new DvrDirectory(poDir, lcName, lcName.substring(1), lcDescription));
            break;
          default:
            throw new IOException("Unknown RecordType " + lbType);
        }
        lnAnzElements--;
      }
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      Unlock();
    }
    poDir.m_bIsOpen = true;
  }