Esempio n. 1
0
  public static PMT parsePMT(ByteBuffer data) {
    parseSection(data);

    // PMT itself
    int w1 = data.getShort() & 0xffff;
    int pcrPid = w1 & 0x1fff;

    int w2 = data.getShort() & 0xffff;
    int programInfoLength = w2 & 0xfff;

    List<Tag> tags = parseTags(NIOUtils.read(data, programInfoLength));
    List<PMTStream> streams = new ArrayList<PMTStream>();
    while (data.remaining() > 4) {
      int streamType = data.get() & 0xff;
      int wn = data.getShort() & 0xffff;
      int elementaryPid = wn & 0x1fff;

      Logger.info(String.format("Elementary stream: [%d,%d]", streamType, elementaryPid));

      int wn1 = data.getShort() & 0xffff;
      int esInfoLength = wn1 & 0xfff;
      ByteBuffer read = NIOUtils.read(data, esInfoLength);
      streams.add(new PMTStream(streamType, elementaryPid, MPSUtils.parseDescriptors(read)));
    }

    return new PMT(pcrPid, tags, streams);
  }
Esempio n. 2
0
 private static List<Tag> parseTags(ByteBuffer bb) {
   List<Tag> tags = new ArrayList<Tag>();
   while (bb.hasRemaining()) {
     int tag = bb.get();
     int tagLen = bb.get();
     Logger.info(String.format("TAG: [0x%x, 0x%x]", tag, tagLen));
     tags.add(new Tag(tag, NIOUtils.read(bb, tagLen)));
   }
   return tags;
 }