1 package com.googlecode.mp4parser.boxes; 2 3 import com.coremedia.iso.IsoTypeReader; 4 import com.coremedia.iso.IsoTypeWriter; 5 import com.googlecode.mp4parser.AbstractBox; 6 import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; 7 import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; 8 9 import java.nio.ByteBuffer; 10 11 /** 12 * Created by IntelliJ IDEA. 13 * User: magnus 14 * Date: 2012-03-09 15 * Time: 16:11 16 * To change this template use File | Settings | File Templates. 17 */ 18 public class DTSSpecificBox extends AbstractBox { 19 20 long DTSSamplingFrequency; 21 long maxBitRate; 22 long avgBitRate; 23 int pcmSampleDepth; 24 int frameDuration; 25 int streamConstruction; 26 int coreLFEPresent; 27 int coreLayout; 28 int coreSize; 29 int stereoDownmix; 30 int representationType; 31 int channelLayout; 32 int multiAssetFlag; 33 int LBRDurationMod; 34 int reservedBoxPresent; 35 int reserved; 36 DTSSpecificBox()37 public DTSSpecificBox() { 38 super("ddts"); 39 } 40 41 @Override getContentSize()42 protected long getContentSize() { 43 return 20; 44 } 45 46 @Override _parseDetails(ByteBuffer content)47 public void _parseDetails(ByteBuffer content) { 48 DTSSamplingFrequency = IsoTypeReader.readUInt32(content); 49 maxBitRate = IsoTypeReader.readUInt32(content); 50 avgBitRate = IsoTypeReader.readUInt32(content); 51 pcmSampleDepth = IsoTypeReader.readUInt8(content); 52 BitReaderBuffer brb = new BitReaderBuffer(content); 53 frameDuration = brb.readBits(2); 54 streamConstruction = brb.readBits(5); 55 coreLFEPresent = brb.readBits(1); 56 coreLayout = brb.readBits(6); 57 coreSize = brb.readBits(14); 58 stereoDownmix = brb.readBits(1); 59 representationType = brb.readBits(3); 60 channelLayout = brb.readBits(16); 61 multiAssetFlag = brb.readBits(1); 62 LBRDurationMod = brb.readBits(1); 63 reservedBoxPresent = brb.readBits(1); 64 reserved = brb.readBits(5); 65 66 } 67 68 @Override getContent(ByteBuffer byteBuffer)69 protected void getContent(ByteBuffer byteBuffer) { 70 IsoTypeWriter.writeUInt32(byteBuffer, DTSSamplingFrequency); 71 IsoTypeWriter.writeUInt32(byteBuffer, maxBitRate); 72 IsoTypeWriter.writeUInt32(byteBuffer, avgBitRate); 73 IsoTypeWriter.writeUInt8(byteBuffer, pcmSampleDepth); 74 BitWriterBuffer bwb = new BitWriterBuffer(byteBuffer); 75 bwb.writeBits(frameDuration, 2); 76 bwb.writeBits(streamConstruction, 5); 77 bwb.writeBits(coreLFEPresent, 1); 78 bwb.writeBits(coreLayout, 6); 79 bwb.writeBits(coreSize, 14); 80 bwb.writeBits(stereoDownmix, 1); 81 bwb.writeBits(representationType, 3); 82 bwb.writeBits(channelLayout, 16); 83 bwb.writeBits(multiAssetFlag, 1); 84 bwb.writeBits(LBRDurationMod, 1); 85 bwb.writeBits(reservedBoxPresent, 1); 86 bwb.writeBits(reserved, 5); 87 88 } 89 getAvgBitRate()90 public long getAvgBitRate() { 91 return avgBitRate; 92 } 93 setAvgBitRate(long avgBitRate)94 public void setAvgBitRate(long avgBitRate) { 95 this.avgBitRate = avgBitRate; 96 } 97 getDTSSamplingFrequency()98 public long getDTSSamplingFrequency() { 99 return DTSSamplingFrequency; 100 } 101 setDTSSamplingFrequency(long DTSSamplingFrequency)102 public void setDTSSamplingFrequency(long DTSSamplingFrequency) { 103 this.DTSSamplingFrequency = DTSSamplingFrequency; 104 } 105 getMaxBitRate()106 public long getMaxBitRate() { 107 return maxBitRate; 108 } 109 setMaxBitRate(long maxBitRate)110 public void setMaxBitRate(long maxBitRate) { 111 this.maxBitRate = maxBitRate; 112 } 113 getPcmSampleDepth()114 public int getPcmSampleDepth() { 115 return pcmSampleDepth; 116 } 117 setPcmSampleDepth(int pcmSampleDepth)118 public void setPcmSampleDepth(int pcmSampleDepth) { 119 this.pcmSampleDepth = pcmSampleDepth; 120 } 121 getFrameDuration()122 public int getFrameDuration() { 123 return frameDuration; 124 } 125 setFrameDuration(int frameDuration)126 public void setFrameDuration(int frameDuration) { 127 this.frameDuration = frameDuration; 128 } 129 getStreamConstruction()130 public int getStreamConstruction() { 131 return streamConstruction; 132 } 133 setStreamConstruction(int streamConstruction)134 public void setStreamConstruction(int streamConstruction) { 135 this.streamConstruction = streamConstruction; 136 } 137 getCoreLFEPresent()138 public int getCoreLFEPresent() { 139 return coreLFEPresent; 140 } 141 setCoreLFEPresent(int coreLFEPresent)142 public void setCoreLFEPresent(int coreLFEPresent) { 143 this.coreLFEPresent = coreLFEPresent; 144 } 145 getCoreLayout()146 public int getCoreLayout() { 147 return coreLayout; 148 } 149 setCoreLayout(int coreLayout)150 public void setCoreLayout(int coreLayout) { 151 this.coreLayout = coreLayout; 152 } 153 getCoreSize()154 public int getCoreSize() { 155 return coreSize; 156 } 157 setCoreSize(int coreSize)158 public void setCoreSize(int coreSize) { 159 this.coreSize = coreSize; 160 } 161 getStereoDownmix()162 public int getStereoDownmix() { 163 return stereoDownmix; 164 } 165 setStereoDownmix(int stereoDownmix)166 public void setStereoDownmix(int stereoDownmix) { 167 this.stereoDownmix = stereoDownmix; 168 } 169 getRepresentationType()170 public int getRepresentationType() { 171 return representationType; 172 } 173 setRepresentationType(int representationType)174 public void setRepresentationType(int representationType) { 175 this.representationType = representationType; 176 } 177 getChannelLayout()178 public int getChannelLayout() { 179 return channelLayout; 180 } 181 setChannelLayout(int channelLayout)182 public void setChannelLayout(int channelLayout) { 183 this.channelLayout = channelLayout; 184 } 185 getMultiAssetFlag()186 public int getMultiAssetFlag() { 187 return multiAssetFlag; 188 } 189 setMultiAssetFlag(int multiAssetFlag)190 public void setMultiAssetFlag(int multiAssetFlag) { 191 this.multiAssetFlag = multiAssetFlag; 192 } 193 getLBRDurationMod()194 public int getLBRDurationMod() { 195 return LBRDurationMod; 196 } 197 setLBRDurationMod(int LBRDurationMod)198 public void setLBRDurationMod(int LBRDurationMod) { 199 this.LBRDurationMod = LBRDurationMod; 200 } 201 getReserved()202 public int getReserved() { 203 return reserved; 204 } 205 setReserved(int reserved)206 public void setReserved(int reserved) { 207 this.reserved = reserved; 208 } 209 getReservedBoxPresent()210 public int getReservedBoxPresent() { 211 return reservedBoxPresent; 212 } 213 setReservedBoxPresent(int reservedBoxPresent)214 public void setReservedBoxPresent(int reservedBoxPresent) { 215 this.reservedBoxPresent = reservedBoxPresent; 216 } 217 } 218