1 package com.googlecode.mp4parser.boxes.piff; 2 3 import com.coremedia.iso.IsoTypeReader; 4 import com.coremedia.iso.IsoTypeWriter; 5 import com.googlecode.mp4parser.AbstractFullBox; 6 7 import java.nio.ByteBuffer; 8 9 /** 10 * The syntax of the fields defined in this section, specified in ABNF [RFC5234], is as follows: 11 * TfxdBox = TfxdBoxLength TfxdBoxType [TfxdBoxLongLength] TfxdBoxUUID TfxdBoxFields 12 * TfxdBoxChildren 13 * TfxdBoxType = "u" "u" "i" "d" 14 * TfxdBoxLength = BoxLength 15 * TfxdBoxLongLength = LongBoxLength 16 * TfxdBoxUUID = %x6D %x1D %x9B %x05 %x42 %xD5 %x44 %xE6 17 * %x80 %xE2 %x14 %x1D %xAF %xF7 %x57 %xB2 18 * TfxdBoxFields = TfxdBoxVersion 19 * TfxdBoxFlags 20 * TfxdBoxDataFields32 / TfxdBoxDataFields64 21 * TfxdBoxVersion = %x00 / %x01 22 * TfxdBoxFlags = 24*24 RESERVED_BIT 23 * TfxdBoxDataFields32 = FragmentAbsoluteTime32 24 * FragmentDuration32 25 * TfxdBoxDataFields64 = FragmentAbsoluteTime64 26 * FragmentDuration64 27 * FragmentAbsoluteTime64 = UNSIGNED_INT32 28 * FragmentDuration64 = UNSIGNED_INT32 29 * FragmentAbsoluteTime64 = UNSIGNED_INT64 30 * FragmentDuration64 = UNSIGNED_INT64 31 * TfxdBoxChildren = *( VendorExtensionUUIDBox ) 32 */ 33 //@ExtendedUserType(uuid = "6d1d9b05-42d5-44e6-80e2-141daff757b2") 34 public class TfxdBox extends AbstractFullBox { 35 public long fragmentAbsoluteTime; 36 public long fragmentAbsoluteDuration; 37 TfxdBox()38 public TfxdBox() { 39 super("uuid"); 40 } 41 42 @Override getUserType()43 public byte[] getUserType() { 44 return new byte[]{(byte) 0x6d, (byte) 0x1d, (byte) 0x9b, (byte) 0x05, (byte) 0x42, (byte) 0xd5, (byte) 0x44, 45 (byte) 0xe6, (byte) 0x80, (byte) 0xe2, 0x14, (byte) 0x1d, (byte) 0xaf, (byte) 0xf7, (byte) 0x57, (byte) 0xb2}; 46 } 47 48 @Override getContentSize()49 protected long getContentSize() { 50 return getVersion() == 0x01 ? 20 : 12; 51 } 52 53 @Override _parseDetails(ByteBuffer content)54 public void _parseDetails(ByteBuffer content) { 55 parseVersionAndFlags(content); 56 57 if (getVersion() == 0x01) { 58 fragmentAbsoluteTime = IsoTypeReader.readUInt64(content); 59 fragmentAbsoluteDuration = IsoTypeReader.readUInt64(content); 60 } else { 61 fragmentAbsoluteTime = IsoTypeReader.readUInt32(content); 62 fragmentAbsoluteDuration = IsoTypeReader.readUInt32(content); 63 } 64 } 65 66 @Override getContent(ByteBuffer byteBuffer)67 protected void getContent(ByteBuffer byteBuffer) { 68 writeVersionAndFlags(byteBuffer); 69 if (getVersion() == 0x01) { 70 IsoTypeWriter.writeUInt64(byteBuffer, fragmentAbsoluteTime); 71 IsoTypeWriter.writeUInt64(byteBuffer, fragmentAbsoluteDuration); 72 } else { 73 IsoTypeWriter.writeUInt32(byteBuffer, fragmentAbsoluteTime); 74 IsoTypeWriter.writeUInt32(byteBuffer, fragmentAbsoluteDuration); 75 } 76 } 77 getFragmentAbsoluteTime()78 public long getFragmentAbsoluteTime() { 79 return fragmentAbsoluteTime; 80 } 81 getFragmentAbsoluteDuration()82 public long getFragmentAbsoluteDuration() { 83 return fragmentAbsoluteDuration; 84 } 85 } 86