示例#1
0
  private void replaceRefs(IntIntMap replaceSpec, int guid, ByteBuffer buf, Set<Integer> pmtPids) {
    if (guid == 0) {
      PATSection pat = PATSection.parse(buf);
      for (int pids : pat.getPrograms().values()) {
        pmtPids.add(pids);
      }
    } else if (pmtPids.contains(guid)) {
      System.out.println(MainUtils.bold("PMT"));
      PSISection.parse(buf);

      buf.getShort();

      NIOUtils.skip(buf, buf.getShort() & 0xfff);

      while (buf.remaining() > 4) {
        byte streamType = buf.get();
        StreamType fromTag = MTSUtils.StreamType.fromTag(streamType);
        System.out.print(
            (fromTag == null ? "UNKNOWN" : fromTag)
                + "("
                + String.format("0x%02x", streamType)
                + "):\t");
        int wn = buf.getShort() & 0xffff;
        int wasPid = wn & 0x1fff;
        int elementaryPid = replacePid(replaceSpec, wasPid);
        buf.putShort(buf.position() - 2, (short) ((elementaryPid & 0x1fff) | (wn & ~0x1fff)));

        NIOUtils.skip(buf, buf.getShort() & 0xfff);
      }
    }
  }
示例#2
0
  public static void main1(String[] args) throws IOException {

    Cmd cmd = MainUtils.parseArguments(args);
    if (cmd.args.length < 1) {
      MainUtils.printHelpNoFlags("file name");
      return;
    }

    ReadableByteChannel ch = null;
    try {
      ch = NIOUtils.readableChannel(new File(cmd.args[0]));
      dumpTSPackets(ch);
    } finally {
      NIOUtils.closeQuietly(ch);
    }
  }
示例#3
0
  public static void main(String[] args) throws IOException {
    Cmd cmd = MainUtils.parseArguments(args);
    if (cmd.args.length < 2) {
      MainUtils.printHelp(
          new HashMap<String, String>() {
            {
            }
          },
          "pid_from:pid_to,[pid_from:pid_to...]",
          "file");
      return;
    }

    IntIntMap replaceSpec = parseReplaceSpec(cmd.getArg(0));

    SeekableByteChannel ch = null;
    try {
      ch = NIOUtils.rwFileChannel(new File(cmd.getArg(1)));

      new MTSReplacePid(replaceSpec).readTsFile(ch);
    } finally {
      NIOUtils.closeQuietly(ch);
    }
  }