Home | History | Annotate | Download | only in apple
      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 
     34     public long getMaxSamplePerFrame() {
     35         return maxSamplePerFrame;
     36     }
     37 
     38     public void setMaxSamplePerFrame(int maxSamplePerFrame) {
     39         this.maxSamplePerFrame = maxSamplePerFrame;
     40     }
     41 
     42     public int getUnknown1() {
     43         return unknown1;
     44     }
     45 
     46     public void setUnknown1(int unknown1) {
     47         this.unknown1 = unknown1;
     48     }
     49 
     50     public int getSampleSize() {
     51         return sampleSize;
     52     }
     53 
     54     public void setSampleSize(int sampleSize) {
     55         this.sampleSize = sampleSize;
     56     }
     57 
     58     public int getHistoryMult() {
     59         return historyMult;
     60     }
     61 
     62     public void setHistoryMult(int historyMult) {
     63         this.historyMult = historyMult;
     64     }
     65 
     66     public int getInitialHistory() {
     67         return initialHistory;
     68     }
     69 
     70     public void setInitialHistory(int initialHistory) {
     71         this.initialHistory = initialHistory;
     72     }
     73 
     74     public int getKModifier() {
     75         return kModifier;
     76     }
     77 
     78     public void setKModifier(int kModifier) {
     79         this.kModifier = kModifier;
     80     }
     81 
     82     public int getChannels() {
     83         return channels;
     84     }
     85 
     86     public void setChannels(int channels) {
     87         this.channels = channels;
     88     }
     89 
     90     public int getUnknown2() {
     91         return unknown2;
     92     }
     93 
     94     public void setUnknown2(int unknown2) {
     95         this.unknown2 = unknown2;
     96     }
     97 
     98     public long getMaxCodedFrameSize() {
     99         return maxCodedFrameSize;
    100     }
    101 
    102     public void setMaxCodedFrameSize(int maxCodedFrameSize) {
    103         this.maxCodedFrameSize = maxCodedFrameSize;
    104     }
    105 
    106     public long getBitRate() {
    107         return bitRate;
    108     }
    109 
    110     public void setBitRate(int bitRate) {
    111         this.bitRate = bitRate;
    112     }
    113 
    114     public long getSampleRate() {
    115         return sampleRate;
    116     }
    117 
    118     public void setSampleRate(int sampleRate) {
    119         this.sampleRate = sampleRate;
    120     }
    121 
    122 
    123     @Override
    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
    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 
    155     public AppleLosslessSpecificBox() {
    156         super("alac");
    157     }
    158 
    159     protected long getContentSize() {
    160         return 28;
    161     }
    162 
    163 }
    164