• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.coremedia.iso.boxes.apple;
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  *
11  */
12 public final class AppleLosslessSpecificBox extends AbstractFullBox {
13 
14     public static final String TYPE = "alac";
15     /*
16    Extradata: 32bit size 32bit tag (=alac) 32bit zero?
17    32bit max sample per frame 8bit ?? (zero?) 8bit sample
18    size 8bit history mult 8bit initial history 8bit kmodifier
19    8bit channels? 16bit ?? 32bit max coded frame size 32bit
20    bitrate? 32bit samplerate
21     */
22     private long maxSamplePerFrame; // 32bi
23     private int unknown1; // 8bit
24     private int sampleSize; // 8bit
25     private int historyMult; // 8bit
26     private int initialHistory; // 8bit
27     private int kModifier; // 8bit
28     private int channels; // 8bit
29     private int unknown2; // 16bit
30     private long maxCodedFrameSize; // 32bit
31     private long bitRate; // 32bit
32     private long sampleRate; // 32bit
33 
getMaxSamplePerFrame()34     public long getMaxSamplePerFrame() {
35         return maxSamplePerFrame;
36     }
37 
setMaxSamplePerFrame(int maxSamplePerFrame)38     public void setMaxSamplePerFrame(int maxSamplePerFrame) {
39         this.maxSamplePerFrame = maxSamplePerFrame;
40     }
41 
getUnknown1()42     public int getUnknown1() {
43         return unknown1;
44     }
45 
setUnknown1(int unknown1)46     public void setUnknown1(int unknown1) {
47         this.unknown1 = unknown1;
48     }
49 
getSampleSize()50     public int getSampleSize() {
51         return sampleSize;
52     }
53 
setSampleSize(int sampleSize)54     public void setSampleSize(int sampleSize) {
55         this.sampleSize = sampleSize;
56     }
57 
getHistoryMult()58     public int getHistoryMult() {
59         return historyMult;
60     }
61 
setHistoryMult(int historyMult)62     public void setHistoryMult(int historyMult) {
63         this.historyMult = historyMult;
64     }
65 
getInitialHistory()66     public int getInitialHistory() {
67         return initialHistory;
68     }
69 
setInitialHistory(int initialHistory)70     public void setInitialHistory(int initialHistory) {
71         this.initialHistory = initialHistory;
72     }
73 
getKModifier()74     public int getKModifier() {
75         return kModifier;
76     }
77 
setKModifier(int kModifier)78     public void setKModifier(int kModifier) {
79         this.kModifier = kModifier;
80     }
81 
getChannels()82     public int getChannels() {
83         return channels;
84     }
85 
setChannels(int channels)86     public void setChannels(int channels) {
87         this.channels = channels;
88     }
89 
getUnknown2()90     public int getUnknown2() {
91         return unknown2;
92     }
93 
setUnknown2(int unknown2)94     public void setUnknown2(int unknown2) {
95         this.unknown2 = unknown2;
96     }
97 
getMaxCodedFrameSize()98     public long getMaxCodedFrameSize() {
99         return maxCodedFrameSize;
100     }
101 
setMaxCodedFrameSize(int maxCodedFrameSize)102     public void setMaxCodedFrameSize(int maxCodedFrameSize) {
103         this.maxCodedFrameSize = maxCodedFrameSize;
104     }
105 
getBitRate()106     public long getBitRate() {
107         return bitRate;
108     }
109 
setBitRate(int bitRate)110     public void setBitRate(int bitRate) {
111         this.bitRate = bitRate;
112     }
113 
getSampleRate()114     public long getSampleRate() {
115         return sampleRate;
116     }
117 
setSampleRate(int sampleRate)118     public void setSampleRate(int sampleRate) {
119         this.sampleRate = sampleRate;
120     }
121 
122 
123     @Override
_parseDetails(ByteBuffer content)124     public void _parseDetails(ByteBuffer content) {
125         parseVersionAndFlags(content);
126         maxSamplePerFrame = IsoTypeReader.readUInt32(content);
127         unknown1 = IsoTypeReader.readUInt8(content);
128         sampleSize = IsoTypeReader.readUInt8(content);
129         historyMult = IsoTypeReader.readUInt8(content);
130         initialHistory = IsoTypeReader.readUInt8(content);
131         kModifier = IsoTypeReader.readUInt8(content);
132         channels = IsoTypeReader.readUInt8(content);
133         unknown2 = IsoTypeReader.readUInt16(content);
134         maxCodedFrameSize = IsoTypeReader.readUInt32(content);
135         bitRate = IsoTypeReader.readUInt32(content);
136         sampleRate = IsoTypeReader.readUInt32(content);
137     }
138 
139     @Override
getContent(ByteBuffer byteBuffer)140     protected void getContent(ByteBuffer byteBuffer) {
141         writeVersionAndFlags(byteBuffer);
142         IsoTypeWriter.writeUInt32(byteBuffer, maxSamplePerFrame);
143         IsoTypeWriter.writeUInt8(byteBuffer, unknown1);
144         IsoTypeWriter.writeUInt8(byteBuffer, sampleSize);
145         IsoTypeWriter.writeUInt8(byteBuffer, historyMult);
146         IsoTypeWriter.writeUInt8(byteBuffer, initialHistory);
147         IsoTypeWriter.writeUInt8(byteBuffer, kModifier);
148         IsoTypeWriter.writeUInt8(byteBuffer, channels);
149         IsoTypeWriter.writeUInt16(byteBuffer, unknown2);
150         IsoTypeWriter.writeUInt32(byteBuffer, maxCodedFrameSize);
151         IsoTypeWriter.writeUInt32(byteBuffer, bitRate);
152         IsoTypeWriter.writeUInt32(byteBuffer, sampleRate);
153     }
154 
AppleLosslessSpecificBox()155     public AppleLosslessSpecificBox() {
156         super("alac");
157     }
158 
getContentSize()159     protected long getContentSize() {
160         return 28;
161     }
162 
163 }
164