1 /* 2 * Copyright 2009 castLabs GmbH, Berlin 3 * 4 * Licensed under the Apache License, Version 2.0 (the License); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an AS IS BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.coremedia.iso.boxes.fragment; 18 19 import com.coremedia.iso.IsoTypeReader; 20 import com.coremedia.iso.IsoTypeWriter; 21 import com.googlecode.mp4parser.AbstractFullBox; 22 23 import java.nio.ByteBuffer; 24 25 public class TrackFragmentBaseMediaDecodeTimeBox extends AbstractFullBox { 26 public static final String TYPE = "tfdt"; 27 28 private long baseMediaDecodeTime; 29 TrackFragmentBaseMediaDecodeTimeBox()30 public TrackFragmentBaseMediaDecodeTimeBox() { 31 super(TYPE); 32 } 33 34 @Override getContentSize()35 protected long getContentSize() { 36 return getVersion() == 0 ? 8 : 12; 37 } 38 39 @Override getContent(ByteBuffer byteBuffer)40 protected void getContent(ByteBuffer byteBuffer) { 41 writeVersionAndFlags(byteBuffer); 42 if (getVersion() == 1) { 43 IsoTypeWriter.writeUInt64(byteBuffer, baseMediaDecodeTime); 44 } else { 45 IsoTypeWriter.writeUInt32(byteBuffer, baseMediaDecodeTime); 46 } 47 } 48 49 50 @Override _parseDetails(ByteBuffer content)51 public void _parseDetails(ByteBuffer content) { 52 parseVersionAndFlags(content); 53 if (getVersion() == 1) { 54 baseMediaDecodeTime = IsoTypeReader.readUInt64(content); 55 } else { 56 baseMediaDecodeTime = IsoTypeReader.readUInt32(content); 57 } 58 59 } 60 61 getBaseMediaDecodeTime()62 public long getBaseMediaDecodeTime() { 63 return baseMediaDecodeTime; 64 } 65 setBaseMediaDecodeTime(long baseMediaDecodeTime)66 public void setBaseMediaDecodeTime(long baseMediaDecodeTime) { 67 this.baseMediaDecodeTime = baseMediaDecodeTime; 68 } 69 70 @Override toString()71 public String toString() { 72 return "TrackFragmentBaseMediaDecodeTimeBox{" + 73 "baseMediaDecodeTime=" + baseMediaDecodeTime + 74 '}'; 75 } 76 } 77