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 /** 26 * aligned(8) class TrackExtendsBox extends FullBox('trex', 0, 0){ 27 * unsigned int(32) track_ID; 28 * unsigned int(32) default_sample_description_index; 29 * unsigned int(32) default_sample_duration; 30 * unsigned int(32) default_sample_size; 31 * unsigned int(32) default_sample_flags 32 * } 33 */ 34 public class TrackExtendsBox extends AbstractFullBox { 35 public static final String TYPE = "trex"; 36 private long trackId; 37 private long defaultSampleDescriptionIndex; 38 private long defaultSampleDuration; 39 private long defaultSampleSize; 40 private SampleFlags defaultSampleFlags; 41 TrackExtendsBox()42 public TrackExtendsBox() { 43 super(TYPE); 44 } 45 46 @Override getContentSize()47 protected long getContentSize() { 48 return 5 * 4 + 4; 49 } 50 51 @Override getContent(ByteBuffer byteBuffer)52 protected void getContent(ByteBuffer byteBuffer) { 53 writeVersionAndFlags(byteBuffer); 54 IsoTypeWriter.writeUInt32(byteBuffer, trackId); 55 IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleDescriptionIndex); 56 IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleDuration); 57 IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleSize); 58 defaultSampleFlags.getContent(byteBuffer); 59 } 60 61 @Override _parseDetails(ByteBuffer content)62 public void _parseDetails(ByteBuffer content) { 63 parseVersionAndFlags(content); 64 trackId = IsoTypeReader.readUInt32(content); 65 defaultSampleDescriptionIndex = IsoTypeReader.readUInt32(content); 66 defaultSampleDuration = IsoTypeReader.readUInt32(content); 67 defaultSampleSize = IsoTypeReader.readUInt32(content); 68 defaultSampleFlags = new SampleFlags(content); 69 } 70 getTrackId()71 public long getTrackId() { 72 return trackId; 73 } 74 getDefaultSampleDescriptionIndex()75 public long getDefaultSampleDescriptionIndex() { 76 return defaultSampleDescriptionIndex; 77 } 78 getDefaultSampleDuration()79 public long getDefaultSampleDuration() { 80 return defaultSampleDuration; 81 } 82 getDefaultSampleSize()83 public long getDefaultSampleSize() { 84 return defaultSampleSize; 85 } 86 getDefaultSampleFlags()87 public SampleFlags getDefaultSampleFlags() { 88 return defaultSampleFlags; 89 } 90 getDefaultSampleFlagsStr()91 public String getDefaultSampleFlagsStr() { 92 return defaultSampleFlags.toString(); 93 } 94 setTrackId(long trackId)95 public void setTrackId(long trackId) { 96 this.trackId = trackId; 97 } 98 setDefaultSampleDescriptionIndex(long defaultSampleDescriptionIndex)99 public void setDefaultSampleDescriptionIndex(long defaultSampleDescriptionIndex) { 100 this.defaultSampleDescriptionIndex = defaultSampleDescriptionIndex; 101 } 102 setDefaultSampleDuration(long defaultSampleDuration)103 public void setDefaultSampleDuration(long defaultSampleDuration) { 104 this.defaultSampleDuration = defaultSampleDuration; 105 } 106 setDefaultSampleSize(long defaultSampleSize)107 public void setDefaultSampleSize(long defaultSampleSize) { 108 this.defaultSampleSize = defaultSampleSize; 109 } 110 setDefaultSampleFlags(SampleFlags defaultSampleFlags)111 public void setDefaultSampleFlags(SampleFlags defaultSampleFlags) { 112 this.defaultSampleFlags = defaultSampleFlags; 113 114 } 115 } 116