Beispiel #1
0
 private int replacePid(IntIntMap replaceSpec, int pid) {
   int newPid = pid;
   if (replaceSpec.contains(pid)) {
     newPid = replaceSpec.get(pid);
   }
   System.out.println("[" + pid + "->" + newPid + "]");
   return newPid;
 }
Beispiel #2
0
 private static void printPat(PATSection pat) {
   IntIntMap programs = pat.getPrograms();
   System.out.print("PAT: ");
   int[] keys = programs.keys();
   for (int i : keys) {
     System.out.print(i + ":" + programs.get(i) + ", ");
   }
 }
Beispiel #3
0
 private static IntIntMap parseReplaceSpec(String spec) {
   IntIntMap map = new IntIntMap();
   for (String pidPair : spec.split(",")) {
     String[] pidPairParsed = pidPair.split(":");
     map.put(Integer.parseInt(pidPairParsed[0]), Integer.parseInt(pidPairParsed[1]));
   }
   return map;
 }
Beispiel #4
0
  private static void dumpTSPackets(ReadableByteChannel _in) throws IOException {
    ByteBuffer buf = ByteBuffer.allocate(188 * 1024);

    while (_in.read(buf) != -1) {
      buf.flip();
      buf.limit((buf.limit() / 188) * 188);
      int pmtPid = -1;
      for (int pkt = 0; buf.hasRemaining(); ++pkt) {
        ByteBuffer tsBuf = NIOUtils.read(buf, 188);
        Assert.assertEquals(0x47, tsBuf.get() & 0xff);
        int guidFlags = ((tsBuf.get() & 0xff) << 8) | (tsBuf.get() & 0xff);
        int guid = (int) guidFlags & 0x1fff;
        int payloadStart = (guidFlags >> 14) & 0x1;
        int b0 = tsBuf.get() & 0xff;
        int counter = b0 & 0xf;
        if ((b0 & 0x20) != 0) {
          NIOUtils.skip(tsBuf, (tsBuf.get() & 0xff));
        }
        System.out.print(
            "#"
                + pkt
                + "[guid: "
                + guid
                + ", cnt: "
                + counter
                + ", start: "
                + (payloadStart == 1 ? "y" : "-"));

        if (guid == 0 || guid == pmtPid) {

          System.out.print(", PSI]: ");
          if (payloadStart == 1) {
            NIOUtils.skip(tsBuf, (tsBuf.get() & 0xff));
          }

          if (guid == 0) {
            PATSection pat = PATSection.parsePAT(tsBuf);
            IntIntMap programs = pat.getPrograms();
            pmtPid = programs.values()[0];
            printPat(pat);
          } else if (guid == pmtPid) {
            PMTSection pmt = PMTSection.parsePMT(tsBuf);
            printPmt(pmt);
          }
        } else {
          System.out.print("]: " + tsBuf.remaining());
        }
        System.out.println();
      }
      buf.clear();
    }
  }