コード例 #1
0
ファイル: PrintStructure.java プロジェクト: mklemm/mp4parser
  /**
   * Parses the FileChannel, in the range [start, end) and prints the elements found
   *
   * <p>Elements are printed, indented by "level" number of spaces. If an element is a container,
   * then its contents will be, recursively, printed, with a greater indentation.
   *
   * @param fc
   * @param level
   * @param start
   * @param end
   * @throws IOException
   */
  private void print(FileChannel fc, int level, long start, long end) throws IOException {
    fc.position(start);
    if (end <= 0) {
      end = start + fc.size();
      System.out.println("Setting END to " + end);
    }
    while (end - fc.position() > 8) {
      long begin = fc.position();
      ByteBuffer bb = ByteBuffer.allocate(8);
      fc.read(bb);
      bb.rewind();
      long size = IsoTypeReader.readUInt32(bb);
      String type = IsoTypeReader.read4cc(bb);
      long fin = begin + size;
      // indent by the required number of spaces
      for (int i = 0; i < level; i++) {
        System.out.print(" ");
      }

      System.out.println(type + "@" + (begin) + " size: " + size);
      if (containers.contains(type)) {
        print(fc, level + 1, begin + 8, fin);
        if (fc.position() != fin) {
          System.out.println("End of container contents at " + fc.position());
          System.out.println("  FIN = " + fin);
        }
      } else {

      }

      fc.position(fin);
    }
  }
コード例 #2
0
 @Override
 public void parse(DataSource dataSource, ByteBuffer header, long contentSize, BoxParser boxParser)
     throws IOException {
   ByteBuffer content = ByteBuffer.allocate(l2i(contentSize));
   dataSource.read(content);
   content.position(6);
   dataReferenceIndex = IsoTypeReader.readUInt16(content);
   displayFlags = content.getInt();
   textJustification = content.getInt();
   backgroundR = IsoTypeReader.readUInt16(content);
   backgroundG = IsoTypeReader.readUInt16(content);
   backgroundB = IsoTypeReader.readUInt16(content);
   defaultTextBox = IsoTypeReader.readUInt64(content);
   reserved1 = IsoTypeReader.readUInt64(content);
   fontNumber = content.getShort();
   fontFace = content.getShort();
   reserved2 = content.get();
   reserved3 = content.getShort();
   foregroundR = IsoTypeReader.readUInt16(content);
   foregroundG = IsoTypeReader.readUInt16(content);
   foregroundB = IsoTypeReader.readUInt16(content);
   if (content.remaining() > 0) {
     int length = IsoTypeReader.readUInt8(content);
     byte[] myFontName = new byte[length];
     content.get(myFontName);
     fontName = new String(myFontName);
   } else {
     fontName = null;
   }
   // initContainer(); there are no child boxes!?
 }
コード例 #3
0
 public void _parseDetails(ByteBuffer paramByteBuffer) {
   parseVersionAndFlags(paramByteBuffer);
   int i = IsoTypeReader.readUInt8(paramByteBuffer);
   this.offsetSize = (i >>> 4);
   this.lengthSize = (i & 0xF);
   int j = IsoTypeReader.readUInt8(paramByteBuffer);
   this.baseOffsetSize = (j >>> 4);
   if (getVersion() == 1) this.indexSize = (j & 0xF);
   int k = IsoTypeReader.readUInt16(paramByteBuffer);
   for (int l = 0; l < k; ++l) this.items.add(new Item(paramByteBuffer));
 }
コード例 #4
0
 public void _parseDetails(ByteBuffer paramByteBuffer) {
   parseVersionAndFlags(paramByteBuffer);
   int i = CastUtils.l2i(IsoTypeReader.readUInt32(paramByteBuffer));
   this.entries = new ArrayList(i);
   for (int j = 0; j < i; ++j) {
     Entry localEntry =
         new Entry(
             CastUtils.l2i(IsoTypeReader.readUInt32(paramByteBuffer)), paramByteBuffer.getInt());
     this.entries.add(localEntry);
   }
 }
コード例 #5
0
ファイル: SampleSizeBox.java プロジェクト: GyuminLee/Android
  @Override
  public void _parseDetails(ByteBuffer content) {
    parseVersionAndFlags(content);
    sampleSize = IsoTypeReader.readUInt32(content);
    sampleCount = l2i(IsoTypeReader.readUInt32(content));

    if (sampleSize == 0) {
      sampleSizes = new long[(int) sampleCount];

      for (int i = 0; i < sampleCount; i++) {
        sampleSizes[i] = IsoTypeReader.readUInt32(content);
      }
    }
  }
コード例 #6
0
  @Override
  public void _parseDetails(ByteBuffer content) {
    parseVersionAndFlags(content);
    int fragmentCount = IsoTypeReader.readUInt8(content);

    for (int i = 0; i < fragmentCount; i++) {
      Entry entry = new Entry();
      if (getVersion() == 0x01) {
        entry.fragmentAbsoluteTime = IsoTypeReader.readUInt64(content);
        entry.fragmentAbsoluteDuration = IsoTypeReader.readUInt64(content);
      } else {
        entry.fragmentAbsoluteTime = IsoTypeReader.readUInt32(content);
        entry.fragmentAbsoluteDuration = IsoTypeReader.readUInt32(content);
      }
      entries.add(entry);
    }
  }
コード例 #7
0
 public Item(ByteBuffer arg2) {
   ByteBuffer localByteBuffer;
   this.itemId = IsoTypeReader.readUInt16(localByteBuffer);
   if (ItemLocationBox.this.getVersion() == 1)
     this.constructionMethod = (0xF & IsoTypeReader.readUInt16(localByteBuffer));
   this.dataReferenceIndex = IsoTypeReader.readUInt16(localByteBuffer);
   if (ItemLocationBox.this.baseOffsetSize > 0) ;
   for (this.baseOffset =
           IsoTypeReaderVariable.read(localByteBuffer, ItemLocationBox.this.baseOffsetSize);
       ;
       this.baseOffset = 0L) {
     int i = IsoTypeReader.readUInt16(localByteBuffer);
     for (int j = 0; ; ++j) {
       if (j >= i) return;
       this.extents.add(new ItemLocationBox.Extent(ItemLocationBox.this, localByteBuffer));
     }
   }
 }
コード例 #8
0
  public static BaseDescriptor createFrom(int objectTypeIndication, ByteBuffer bb)
      throws IOException {
    int tag = IsoTypeReader.readUInt8(bb);

    Map<Integer, Class<? extends BaseDescriptor>> tagMap =
        descriptorRegistry.get(objectTypeIndication);
    if (tagMap == null) {
      tagMap = descriptorRegistry.get(-1);
    }
    Class<? extends BaseDescriptor> aClass = tagMap.get(tag);

    //    if (tag == 0x00) {
    //      log.warning("Found illegal tag 0x00! objectTypeIndication " +
    // Integer.toHexString(objectTypeIndication) +
    //              " and tag " + Integer.toHexString(tag) + " using: " + aClass);
    //      aClass = BaseDescriptor.class;
    //    }

    BaseDescriptor baseDescriptor;
    if (aClass == null || aClass.isInterface() || Modifier.isAbstract(aClass.getModifiers())) {
      log.warning(
          "No ObjectDescriptor found for objectTypeIndication "
              + Integer.toHexString(objectTypeIndication)
              + " and tag "
              + Integer.toHexString(tag)
              + " found: "
              + aClass);
      baseDescriptor = new UnknownDescriptor();
    } else {
      try {
        baseDescriptor = aClass.newInstance();
      } catch (Exception e) {
        log.log(
            Level.SEVERE,
            "Couldn't instantiate BaseDescriptor class "
                + aClass
                + " for objectTypeIndication "
                + objectTypeIndication
                + " and tag "
                + tag,
            e);
        throw new RuntimeException(e);
      }
    }
    baseDescriptor.parse(tag, bb);
    return baseDescriptor;
  }
コード例 #9
0
  @Override
  public void _parseDetails(ByteBuffer content) {
    parseVersionAndFlags(content);

    entryCount = IsoTypeReader.readUInt32(content);

    for (int i = 0; i < entryCount; i++) {
      SampleEntry sampleEntry = new SampleEntry();
      sampleEntry.setSampleDelta(IsoTypeReader.readUInt32(content));
      int subsampleCount = IsoTypeReader.readUInt16(content);
      for (int j = 0; j < subsampleCount; j++) {
        SampleEntry.SubsampleEntry subsampleEntry = new SampleEntry.SubsampleEntry();
        subsampleEntry.setSubsampleSize(
            getVersion() == 1
                ? IsoTypeReader.readUInt32(content)
                : IsoTypeReader.readUInt16(content));
        subsampleEntry.setSubsamplePriority(IsoTypeReader.readUInt8(content));
        subsampleEntry.setDiscardable(IsoTypeReader.readUInt8(content));
        subsampleEntry.setReserved(IsoTypeReader.readUInt32(content));
        sampleEntry.addSubsampleEntry(subsampleEntry);
      }
      entries.add(sampleEntry);
    }
  }
コード例 #10
0
 public void parseDetail(ByteBuffer paramByteBuffer)
   throws IOException
 {
   this.esId = IsoTypeReader.readUInt16(paramByteBuffer);
   int i = IsoTypeReader.readUInt8(paramByteBuffer);
   this.streamDependenceFlag = (i >>> 7);
   this.URLFlag = (0x1 & i >>> 6);
   this.oCRstreamFlag = (0x1 & i >>> 5);
   this.streamPriority = (i & 0x1F);
   if (this.streamDependenceFlag == 1)
     this.dependsOnEsId = IsoTypeReader.readUInt16(paramByteBuffer);
   if (this.URLFlag == 1)
   {
     this.URLLength = IsoTypeReader.readUInt8(paramByteBuffer);
     this.URLString = IsoTypeReader.readString(paramByteBuffer, this.URLLength);
   }
   if (this.oCRstreamFlag == 1)
     this.oCREsId = IsoTypeReader.readUInt16(paramByteBuffer);
   int j = 1 + (2 + (1 + getSizeBytes()));
   int k;
   label130: int i1;
   label152: int i5;
   long l3;
   Integer localInteger3;
   label267: label311: long l2;
   Integer localInteger2;
   label411: label455: label472: BaseDescriptor localBaseDescriptor1;
   long l1;
   Integer localInteger1;
   if (this.streamDependenceFlag == 1)
   {
     k = 2;
     int l = j + k;
     if (this.URLFlag != 1)
       break label620;
     i1 = 1 + this.URLLength;
     int i2 = i1 + l;
     int i3 = this.oCRstreamFlag;
     int i4 = 0;
     if (i3 == 1)
       i4 = 2;
     i5 = i2 + i4;
     int i6 = paramByteBuffer.position();
     if (getSize() > i5 + 2)
     {
       BaseDescriptor localBaseDescriptor3 = ObjectDescriptorFactory.createFrom(-1, paramByteBuffer);
       l3 = paramByteBuffer.position() - i6;
       Logger localLogger3 = log;
       StringBuilder localStringBuilder3 = new StringBuilder().append(localBaseDescriptor3).append(" - ESDescriptor1 read: ").append(l3).append(", size: ");
       if (localBaseDescriptor3 == null)
         break label626;
       localInteger3 = Integer.valueOf(localBaseDescriptor3.getSize());
       localLogger3.finer(localInteger3);
       if (localBaseDescriptor3 == null)
         break label632;
       int i11 = localBaseDescriptor3.getSize();
       paramByteBuffer.position(i6 + i11);
       i5 += i11;
       if (localBaseDescriptor3 instanceof DecoderConfigDescriptor)
         this.decoderConfigDescriptor = ((DecoderConfigDescriptor)localBaseDescriptor3);
     }
     int i7 = paramByteBuffer.position();
     if (getSize() <= i5 + 2)
       break label662;
     BaseDescriptor localBaseDescriptor2 = ObjectDescriptorFactory.createFrom(-1, paramByteBuffer);
     l2 = paramByteBuffer.position() - i7;
     Logger localLogger2 = log;
     StringBuilder localStringBuilder2 = new StringBuilder().append(localBaseDescriptor2).append(" - ESDescriptor2 read: ").append(l2).append(", size: ");
     if (localBaseDescriptor2 == null)
       break label644;
     localInteger2 = Integer.valueOf(localBaseDescriptor2.getSize());
     localLogger2.finer(localInteger2);
     if (localBaseDescriptor2 == null)
       break label650;
     int i10 = localBaseDescriptor2.getSize();
     paramByteBuffer.position(i7 + i10);
     i5 += i10;
     if (localBaseDescriptor2 instanceof SLConfigDescriptor)
       this.slConfigDescriptor = ((SLConfigDescriptor)localBaseDescriptor2);
     if (getSize() - i5 <= 2)
       return;
     int i8 = paramByteBuffer.position();
     localBaseDescriptor1 = ObjectDescriptorFactory.createFrom(-1, paramByteBuffer);
     l1 = paramByteBuffer.position() - i8;
     Logger localLogger1 = log;
     StringBuilder localStringBuilder1 = new StringBuilder().append(localBaseDescriptor1).append(" - ESDescriptor3 read: ").append(l1).append(", size: ");
     if (localBaseDescriptor1 == null)
       break label673;
     localInteger1 = Integer.valueOf(localBaseDescriptor1.getSize());
     label555: localLogger1.finer(localInteger1);
     if (localBaseDescriptor1 == null)
       break label679;
     int i9 = localBaseDescriptor1.getSize();
     paramByteBuffer.position(i8 + i9);
     i5 += i9;
   }
   while (true)
   {
     this.otherDescriptors.add(localBaseDescriptor1);
     break label472:
     k = 0;
     break label130:
     label620: i1 = 0;
     break label152:
     label626: localInteger3 = null;
     break label267:
     label632: i5 = (int)(l3 + i5);
     break label311:
     label644: localInteger2 = null;
     break label411:
     label650: i5 = (int)(l2 + i5);
     break label455:
     label662: log.warning("SLConfigDescriptor is missing!");
     break label472:
     label673: localInteger1 = null;
     break label555:
     label679: i5 = (int)(l1 + i5);
   }
 }
コード例 #11
0
  @Override
  public void _parseDetails(ByteBuffer content) {
    parseVersionAndFlags(content);
    if (getVersion() == 1) {
      creationTime = IsoTypeReader.readUInt64(content);
      modificationTime = IsoTypeReader.readUInt64(content);
      timescale = IsoTypeReader.readUInt32(content);
      duration = IsoTypeReader.readUInt64(content);
    } else {
      creationTime = IsoTypeReader.readUInt32(content);
      modificationTime = IsoTypeReader.readUInt32(content);
      timescale = IsoTypeReader.readUInt32(content);
      duration = IsoTypeReader.readUInt32(content);
    }
    rate = IsoTypeReader.readFixedPoint1616(content);
    volume = IsoTypeReader.readFixedPoint88(content);
    IsoTypeReader.readUInt16(content);
    IsoTypeReader.readUInt32(content);
    IsoTypeReader.readUInt32(content);
    matrix = new long[9];
    for (int i = 0; i < 9; i++) {
      matrix[i] = IsoTypeReader.readUInt32(content);
    }

    previewTime = content.getInt();
    previewDuration = content.getInt();
    posterTime = content.getInt();
    selectionTime = content.getInt();
    selectionDuration = content.getInt();
    currentTime = content.getInt();

    nextTrackId = IsoTypeReader.readUInt32(content);
  }
コード例 #12
0
 @Override
 public void _parseDetails(ByteBuffer content) {
   parseVersionAndFlags(content);
   maxSamplePerFrame = IsoTypeReader.readUInt32(content);
   unknown1 = IsoTypeReader.readUInt8(content);
   sampleSize = IsoTypeReader.readUInt8(content);
   historyMult = IsoTypeReader.readUInt8(content);
   initialHistory = IsoTypeReader.readUInt8(content);
   kModifier = IsoTypeReader.readUInt8(content);
   channels = IsoTypeReader.readUInt8(content);
   unknown2 = IsoTypeReader.readUInt16(content);
   maxCodedFrameSize = IsoTypeReader.readUInt32(content);
   bitRate = IsoTypeReader.readUInt32(content);
   sampleRate = IsoTypeReader.readUInt32(content);
 }
コード例 #13
0
ファイル: DescriptionBox.java プロジェクト: 2bfree/astrid
 @Override
 public void _parseDetails(ByteBuffer content) {
   parseVersionAndFlags(content);
   language = IsoTypeReader.readIso639(content);
   description = IsoTypeReader.readString(content);
 }