Coverage Report - org.jaudiotagger.audio.mp4.atom.Mp4AlacBox
 
Classes in this File Line Coverage Branch Coverage Complexity
Mp4AlacBox
63%
19/30
N/A
1
 
 1  
 package org.jaudiotagger.audio.mp4.atom;
 2  
 
 3  
 import org.jaudiotagger.audio.generic.Utils;
 4  
 import org.jaudiotagger.audio.exceptions.CannotReadException;
 5  
 
 6  
 import java.nio.ByteBuffer;
 7  
 
 8  
 /**
 9  
  * AlacBox ( Apple Lossless Codec information description box),
 10  
  *
 11  
  * Normally occurs twice, the first ALAC contaisn the default  values, the second ALAC within contains the real
 12  
  * values for this audio.
 13  
  */
 14  
 public class Mp4AlacBox extends AbstractMp4Box
 15  
 {
 16  
     public static final int OTHER_FLAG_LENGTH = 4;
 17  
 
 18  
     private int maxSamplePerFrame; // 32bit
 19  
     private int unknown1; // 8bit
 20  
     private int sampleSize; // 8bit
 21  
     private int historyMult; // 8bit
 22  
     private int initialHistory; // 8bit
 23  
     private int kModifier; // 8bit
 24  
     private int channels; // 8bit
 25  
     private int unknown2; // 16bit
 26  
     private int maxCodedFrameSize; // 32bit
 27  
     private int bitRate; // 32bit
 28  
     private int sampleRate; // 32bit
 29  
 
 30  
 
 31  
     /**
 32  
      * DataBuffer must start from from the start of the body
 33  
      *
 34  
      * @param header     header info
 35  
      * @param dataBuffer data of box (doesnt include header data)
 36  
      */
 37  
     public Mp4AlacBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
 38  16
     {
 39  16
         this.header     = header;
 40  16
         this.dataBuffer = dataBuffer;
 41  16
     }
 42  
 
 43  
     public void processData() throws CannotReadException
 44  
     {
 45  
         //Skip version/other flags
 46  16
         dataBuffer.position(dataBuffer.position() + OTHER_FLAG_LENGTH);
 47  
 
 48  16
         maxSamplePerFrame   = Utils.readUBEInt32(dataBuffer);
 49  16
         unknown1            = Utils.readUInt8(dataBuffer);
 50  16
         sampleSize          = Utils.readUInt8(dataBuffer);
 51  16
         historyMult         = Utils.readUInt8(dataBuffer);
 52  16
         initialHistory      = Utils.readUInt8(dataBuffer);
 53  16
         kModifier           = Utils.readUInt8(dataBuffer);
 54  16
         channels            = Utils.readUInt8(dataBuffer);
 55  16
         unknown2            = Utils.readUBEInt16(dataBuffer);
 56  16
         maxCodedFrameSize   = Utils.readUBEInt32(dataBuffer);
 57  16
         bitRate             = Utils.readUBEInt32(dataBuffer);
 58  16
         sampleRate          = Utils.readUBEInt32(dataBuffer);                 
 59  16
     }
 60  
 
 61  
     public int getMaxSamplePerFrame()
 62  
     {
 63  0
         return maxSamplePerFrame;
 64  
     }
 65  
 
 66  
     public int getUnknown1()
 67  
     {
 68  0
         return unknown1;
 69  
     }
 70  
 
 71  
     public int getSampleSize()
 72  
     {
 73  0
         return sampleSize;
 74  
     }
 75  
 
 76  
     public int getHistoryMult()
 77  
     {
 78  0
         return historyMult;
 79  
     }
 80  
 
 81  
     public int getInitialHistory()
 82  
     {
 83  0
         return initialHistory;
 84  
     }
 85  
 
 86  
     public int getKModifier()
 87  
     {
 88  0
         return kModifier;
 89  
     }
 90  
 
 91  
     public int getChannels()
 92  
     {
 93  8
         return channels;
 94  
     }
 95  
 
 96  
     public int getUnknown2()
 97  
     {
 98  0
         return unknown2;
 99  
     }
 100  
 
 101  
     public int getMaxCodedFrameSize()
 102  
     {
 103  0
         return maxCodedFrameSize;
 104  
     }
 105  
 
 106  
     public int getBitRate()
 107  
     {
 108  8
         return bitRate;
 109  
     }
 110  
 
 111  
     public int getSampleRate()
 112  
     {
 113  0
         return sampleRate;
 114  
     }
 115  
 
 116  
     public String toString()
 117  
     {
 118  0
         String s = "maxSamplePerFrame:" + maxSamplePerFrame
 119  
                     + "unknown1:"+ unknown1
 120  
                     + "sampleSize:"+sampleSize
 121  
                     + "historyMult:"+historyMult
 122  
                     + "initialHistory:"+initialHistory
 123  
                     + "kModifier:"+kModifier
 124  
                     + "channels:"+channels
 125  
                     + "unknown2 :"+unknown2
 126  
                     + "maxCodedFrameSize:"+maxCodedFrameSize
 127  
                     + "bitRate:"+bitRate
 128  
                     + "sampleRate:"+sampleRate;
 129  0
         return s;
 130  
     }
 131  
 }