FileDocCategorySizeDatePackage
AudioSampleEntry.javaAPI Docmp4parser 1.0-RC-178586Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso.boxes.sampleentry

AudioSampleEntry

public class AudioSampleEntry extends SampleEntry implements com.coremedia.iso.boxes.ContainerBox
Contains basic information about the audio samples in this track. Format-specific information is appened as boxes after the data described in ISO/IEC 14496-12 chapter 8.16.2.

Fields Summary
public static final String
TYPE1
public static final String
TYPE2
public static final String
TYPE3
public static final String
TYPE4
public static final String
TYPE5
public static final String
TYPE7
public static final String
TYPE8
public static final String
TYPE9
public static final String
TYPE10
public static final String
TYPE11
public static final String
TYPE12
public static final String
TYPE13
public static final String
TYPE_ENCRYPTED
Identifier for an encrypted audio track.
private int
channelCount
private int
sampleSize
private long
sampleRate
private int
soundVersion
private int
compressionId
private int
packetSize
private long
samplesPerPacket
private long
bytesPerPacket
private long
bytesPerFrame
private long
bytesPerSample
private int
reserved1
private long
reserved2
private byte[]
soundVersion2Data
private com.coremedia.iso.BoxParser
boxParser
Constructors Summary
public AudioSampleEntry(String type)


       
        super(type);
    
Methods Summary
public void_parseDetails(java.nio.ByteBuffer content)

        _parseReservedAndDataReferenceIndex(content);    //parses the six reserved bytes and dataReferenceIndex
        // 8 bytes already parsed
        //reserved bits - used by qt
        soundVersion = IsoTypeReader.readUInt16(content);

        //reserved
        reserved1 = IsoTypeReader.readUInt16(content);
        reserved2 = IsoTypeReader.readUInt32(content);

        channelCount = IsoTypeReader.readUInt16(content);
        sampleSize = IsoTypeReader.readUInt16(content);
        //reserved bits - used by qt
        compressionId = IsoTypeReader.readUInt16(content);
        //reserved bits - used by qt
        packetSize = IsoTypeReader.readUInt16(content);
        //sampleRate = in.readFixedPoint1616();
        sampleRate = IsoTypeReader.readUInt32(content);
        if (!type.equals("mlpa")) {
            sampleRate = sampleRate >>> 16;
        }

        //more qt stuff - see http://mp4v2.googlecode.com/svn-history/r388/trunk/src/atom_sound.cpp
        if (soundVersion > 0) {
            samplesPerPacket = IsoTypeReader.readUInt32(content);
            bytesPerPacket = IsoTypeReader.readUInt32(content);
            bytesPerFrame = IsoTypeReader.readUInt32(content);
            bytesPerSample = IsoTypeReader.readUInt32(content);
        }
        if (soundVersion == 2) {

            soundVersion2Data = new byte[20];
            content.get(20);
        }
        _parseChildBoxes(content);

    
public longgetBytesPerFrame()

        return bytesPerFrame;
    
public longgetBytesPerPacket()

        return bytesPerPacket;
    
public longgetBytesPerSample()

        return bytesPerSample;
    
public intgetChannelCount()

        return channelCount;
    
public intgetCompressionId()

        return compressionId;
    
protected voidgetContent(java.nio.ByteBuffer byteBuffer)

        _writeReservedAndDataReferenceIndex(byteBuffer);
        IsoTypeWriter.writeUInt16(byteBuffer, soundVersion);
        IsoTypeWriter.writeUInt16(byteBuffer, reserved1);
        IsoTypeWriter.writeUInt32(byteBuffer, reserved2);
        IsoTypeWriter.writeUInt16(byteBuffer, channelCount);
        IsoTypeWriter.writeUInt16(byteBuffer, sampleSize);
        IsoTypeWriter.writeUInt16(byteBuffer, compressionId);
        IsoTypeWriter.writeUInt16(byteBuffer, packetSize);
        //isos.writeFixedPoint1616(getSampleRate());
        if (type.equals("mlpa")) {
            IsoTypeWriter.writeUInt32(byteBuffer, getSampleRate());
        } else {
            IsoTypeWriter.writeUInt32(byteBuffer, getSampleRate() << 16);
        }

        if (soundVersion > 0) {
            IsoTypeWriter.writeUInt32(byteBuffer, samplesPerPacket);
            IsoTypeWriter.writeUInt32(byteBuffer, bytesPerPacket);
            IsoTypeWriter.writeUInt32(byteBuffer, bytesPerFrame);
            IsoTypeWriter.writeUInt32(byteBuffer, bytesPerSample);
        }

        if (soundVersion == 2) {
            byteBuffer.put(soundVersion2Data);
        }
        _writeChildBoxes(byteBuffer);
    
protected longgetContentSize()

        long contentSize = 28;
        contentSize += soundVersion > 0 ? 16 : 0;
        contentSize += soundVersion == 2 ? 20 : 0;
        for (Box boxe : boxes) {
            contentSize += boxe.getSize();
        }
        return contentSize;
    
public intgetPacketSize()

        return packetSize;
    
public intgetReserved1()

        return reserved1;
    
public longgetReserved2()

        return reserved2;
    
public longgetSampleRate()

        return sampleRate;
    
public intgetSampleSize()

        return sampleSize;
    
public longgetSamplesPerPacket()

        return samplesPerPacket;
    
public intgetSoundVersion()

        return soundVersion;
    
public byte[]getSoundVersion2Data()

        return soundVersion2Data;
    
public voidsetBoxParser(com.coremedia.iso.BoxParser boxParser)

        this.boxParser = boxParser;
    
public voidsetBytesPerFrame(long bytesPerFrame)

        this.bytesPerFrame = bytesPerFrame;
    
public voidsetBytesPerPacket(long bytesPerPacket)

        this.bytesPerPacket = bytesPerPacket;
    
public voidsetBytesPerSample(long bytesPerSample)

        this.bytesPerSample = bytesPerSample;
    
public voidsetChannelCount(int channelCount)

        this.channelCount = channelCount;
    
public voidsetCompressionId(int compressionId)

        this.compressionId = compressionId;
    
public voidsetPacketSize(int packetSize)

        this.packetSize = packetSize;
    
public voidsetReserved1(int reserved1)

        this.reserved1 = reserved1;
    
public voidsetReserved2(long reserved2)

        this.reserved2 = reserved2;
    
public voidsetSampleRate(long sampleRate)

        this.sampleRate = sampleRate;
    
public voidsetSampleSize(int sampleSize)

        this.sampleSize = sampleSize;
    
public voidsetSamplesPerPacket(long samplesPerPacket)

        this.samplesPerPacket = samplesPerPacket;
    
public voidsetSoundVersion(int soundVersion)

        this.soundVersion = soundVersion;
    
public voidsetSoundVersion2Data(byte[] soundVersion2Data)

        this.soundVersion2Data = soundVersion2Data;
    
public java.lang.StringtoString()

        return "AudioSampleEntry{" +
                "bytesPerSample=" + bytesPerSample +
                ", bytesPerFrame=" + bytesPerFrame +
                ", bytesPerPacket=" + bytesPerPacket +
                ", samplesPerPacket=" + samplesPerPacket +
                ", packetSize=" + packetSize +
                ", compressionId=" + compressionId +
                ", soundVersion=" + soundVersion +
                ", sampleRate=" + sampleRate +
                ", sampleSize=" + sampleSize +
                ", channelCount=" + channelCount +
                ", boxes=" + getBoxes() +
                '}";