1package com.googlecode.mp4parser.boxes;
2
3import com.coremedia.iso.IsoTypeReader;
4import com.coremedia.iso.IsoTypeWriter;
5import com.googlecode.mp4parser.AbstractBox;
6import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer;
7import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer;
8
9import 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 */
18public 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
37    public DTSSpecificBox() {
38        super("ddts");
39    }
40
41    @Override
42    protected long getContentSize() {
43        return 20;
44    }
45
46    @Override
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
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
90    public long getAvgBitRate() {
91        return avgBitRate;
92    }
93
94    public void setAvgBitRate(long avgBitRate) {
95        this.avgBitRate = avgBitRate;
96    }
97
98    public long getDTSSamplingFrequency() {
99        return DTSSamplingFrequency;
100    }
101
102    public void setDTSSamplingFrequency(long DTSSamplingFrequency) {
103        this.DTSSamplingFrequency = DTSSamplingFrequency;
104    }
105
106    public long getMaxBitRate() {
107        return maxBitRate;
108    }
109
110    public void setMaxBitRate(long maxBitRate) {
111        this.maxBitRate = maxBitRate;
112    }
113
114    public int getPcmSampleDepth() {
115        return pcmSampleDepth;
116    }
117
118    public void setPcmSampleDepth(int pcmSampleDepth) {
119        this.pcmSampleDepth = pcmSampleDepth;
120    }
121
122    public int getFrameDuration() {
123        return frameDuration;
124    }
125
126    public void setFrameDuration(int frameDuration) {
127        this.frameDuration = frameDuration;
128    }
129
130    public int getStreamConstruction() {
131        return streamConstruction;
132    }
133
134    public void setStreamConstruction(int streamConstruction) {
135        this.streamConstruction = streamConstruction;
136    }
137
138    public int getCoreLFEPresent() {
139        return coreLFEPresent;
140    }
141
142    public void setCoreLFEPresent(int coreLFEPresent) {
143        this.coreLFEPresent = coreLFEPresent;
144    }
145
146    public int getCoreLayout() {
147        return coreLayout;
148    }
149
150    public void setCoreLayout(int coreLayout) {
151        this.coreLayout = coreLayout;
152    }
153
154    public int getCoreSize() {
155        return coreSize;
156    }
157
158    public void setCoreSize(int coreSize) {
159        this.coreSize = coreSize;
160    }
161
162    public int getStereoDownmix() {
163        return stereoDownmix;
164    }
165
166    public void setStereoDownmix(int stereoDownmix) {
167        this.stereoDownmix = stereoDownmix;
168    }
169
170    public int getRepresentationType() {
171        return representationType;
172    }
173
174    public void setRepresentationType(int representationType) {
175        this.representationType = representationType;
176    }
177
178    public int getChannelLayout() {
179        return channelLayout;
180    }
181
182    public void setChannelLayout(int channelLayout) {
183        this.channelLayout = channelLayout;
184    }
185
186    public int getMultiAssetFlag() {
187        return multiAssetFlag;
188    }
189
190    public void setMultiAssetFlag(int multiAssetFlag) {
191        this.multiAssetFlag = multiAssetFlag;
192    }
193
194    public int getLBRDurationMod() {
195        return LBRDurationMod;
196    }
197
198    public void setLBRDurationMod(int LBRDurationMod) {
199        this.LBRDurationMod = LBRDurationMod;
200    }
201
202    public int getReserved() {
203        return reserved;
204    }
205
206    public void setReserved(int reserved) {
207        this.reserved = reserved;
208    }
209
210    public int getReservedBoxPresent() {
211        return reservedBoxPresent;
212    }
213
214    public void setReservedBoxPresent(int reservedBoxPresent) {
215        this.reservedBoxPresent = reservedBoxPresent;
216    }
217}
218