FileDocCategorySizeDatePackage
SampleGroupDescriptionBox.javaAPI Docmp4parser 1.0-RC-177107Wed Dec 19 20:10:37 GMT 2012com.googlecode.mp4parser.boxes.mp4.samplegrouping

SampleGroupDescriptionBox

public class SampleGroupDescriptionBox extends com.googlecode.mp4parser.AbstractFullBox
This description table gives information about the characteristics of sample groups. The descriptive information is any other information needed to define or characterize the sample group.

There may be multiple instances of this box if there is more than one sample grouping for the samples in a track. Each instance of the SampleGroupDescription box has a type code that distinguishes different sample groupings. Within a track, there shall be at most one instance of this box with a particular grouping type. The associated SampleToGroup shall indicate the same value for the grouping type.

The information is stored in the sample group description box after the entry-count. An abstract entry type is defined and sample groupings shall define derived types to represent the description of each sample group. For video tracks, an abstract VisualSampleGroupEntry is used with similar types for audio and hint tracks.

Fields Summary
public static final String
TYPE
private String
groupingType
private int
defaultLength
private List
groupEntries
private int
descriptionLength
Constructors Summary
public SampleGroupDescriptionBox()


      
        super(TYPE);
    
Methods Summary
protected void_parseDetails(java.nio.ByteBuffer content)

        parseVersionAndFlags(content);
        if (this.getVersion() != 1) {
            throw new RuntimeException("SampleGroupDescriptionBox are only supported in version 1");
        }
        groupingType = IsoTypeReader.read4cc(content);
        if (this.getVersion() == 1) {
            defaultLength = l2i(IsoTypeReader.readUInt32(content));
        }
        long entryCount = IsoTypeReader.readUInt32(content);
        while (entryCount-- > 0) {
            int length = defaultLength;
            if (this.getVersion() == 1) {
                if (defaultLength == 0) {
                    descriptionLength = l2i(IsoTypeReader.readUInt32(content));
                    length = descriptionLength;
                }
            } else {
                throw new RuntimeException("This should be implemented");
            }
            int finalPos = content.position() + length;
            ByteBuffer parseMe = content.slice();
            parseMe.limit(length);
            groupEntries.add(parseGroupEntry(parseMe, groupingType));
            content.position(finalPos);
        }

    
public booleanequals(java.lang.Object o)

        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        SampleGroupDescriptionBox that = (SampleGroupDescriptionBox) o;

        if (defaultLength != that.defaultLength) {
            return false;
        }
        if (groupEntries != null ? !groupEntries.equals(that.groupEntries) : that.groupEntries != null) {
            return false;
        }
        if (groupingType != null ? !groupingType.equals(that.groupingType) : that.groupingType != null) {
            return false;
        }

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

        writeVersionAndFlags(byteBuffer);
        byteBuffer.put(groupingType.getBytes());
        if (this.getVersion() == 1) {
            IsoTypeWriter.writeUInt32(byteBuffer, defaultLength);
        }
        IsoTypeWriter.writeUInt32(byteBuffer, this.groupEntries.size());
        for (GroupEntry entry : groupEntries) {
            if (this.getVersion() == 1 && defaultLength == 0) {
                IsoTypeWriter.writeUInt32(byteBuffer, entry.get().limit());
            }
            byteBuffer.put(entry.get());
        }
    
protected longgetContentSize()

        long size = 8;
        if (getVersion() == 1) {
            size += 4;
        }
        size += 4; // entryCount
        for (GroupEntry groupEntry : groupEntries) {
            if (getVersion() == 1 && defaultLength == 0) {
                size += 4;
            }
            size += groupEntry.size();
        }
        return size;
    
public intgetDefaultLength()

        return defaultLength;
    
public java.util.ListgetGroupEntries()

        return groupEntries;
    
public java.lang.StringgetGroupingType()

        return groupingType;
    
public inthashCode()

        int result = groupingType != null ? groupingType.hashCode() : 0;
        result = 31 * result + defaultLength;
        result = 31 * result + (groupEntries != null ? groupEntries.hashCode() : 0);
        return result;
    
private GroupEntryparseGroupEntry(java.nio.ByteBuffer content, java.lang.String groupingType)

        GroupEntry groupEntry;
        if (RollRecoveryEntry.TYPE.equals(groupingType)) {
            groupEntry = new RollRecoveryEntry();
        } else if (RateShareEntry.TYPE.equals(groupingType)) {
            groupEntry = new RateShareEntry();
        } else if (CencSampleEncryptionInformationGroupEntry.TYPE.equals(groupingType)) {
            groupEntry = new CencSampleEncryptionInformationGroupEntry();
        } else if (VisualRandomAccessEntry.TYPE.equals(groupingType)) {
            groupEntry = new VisualRandomAccessEntry();
        } else if (TemporalLevelEntry.TYPE.equals(groupingType)) {
            groupEntry = new TemporalLevelEntry();
        } else {
            groupEntry = new UnknownEntry();
        }
        groupEntry.parse(content);
        return groupEntry;
    
public voidsetDefaultLength(int defaultLength)

        this.defaultLength = defaultLength;
    
public voidsetGroupEntries(java.util.List groupEntries)

        this.groupEntries = groupEntries;
    
public voidsetGroupingType(java.lang.String groupingType)

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

        return "SampleGroupDescriptionBox{" +
                "groupingType='" + groupingType + '\'" +
                ", defaultLength=" + defaultLength +
                ", groupEntries=" + groupEntries +
                '}";