FileDocCategorySizeDatePackage
ESDescriptor.javaAPI Docmp4parser 1.0-RC-1712845Wed Dec 19 20:10:37 GMT 2012com.googlecode.mp4parser.boxes.mp4.objectdescriptors

ESDescriptor

public class ESDescriptor extends BaseDescriptor

Fields Summary
private static Logger
log
int
esId
int
streamDependenceFlag
int
URLFlag
int
oCRstreamFlag
int
streamPriority
int
URLLength
String
URLString
int
remoteODFlag
int
dependsOnEsId
int
oCREsId
DecoderConfigDescriptor
decoderConfigDescriptor
SLConfigDescriptor
slConfigDescriptor
List
otherDescriptors
Constructors Summary
Methods Summary
public booleanequals(java.lang.Object o)

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

        ESDescriptor that = (ESDescriptor) o;

        if (URLFlag != that.URLFlag) return false;
        if (URLLength != that.URLLength) return false;
        if (dependsOnEsId != that.dependsOnEsId) return false;
        if (esId != that.esId) return false;
        if (oCREsId != that.oCREsId) return false;
        if (oCRstreamFlag != that.oCRstreamFlag) return false;
        if (remoteODFlag != that.remoteODFlag) return false;
        if (streamDependenceFlag != that.streamDependenceFlag) return false;
        if (streamPriority != that.streamPriority) return false;
        if (URLString != null ? !URLString.equals(that.URLString) : that.URLString != null) return false;
        if (decoderConfigDescriptor != null ? !decoderConfigDescriptor.equals(that.decoderConfigDescriptor) : that.decoderConfigDescriptor != null)
            return false;
        if (otherDescriptors != null ? !otherDescriptors.equals(that.otherDescriptors) : that.otherDescriptors != null)
            return false;
        if (slConfigDescriptor != null ? !slConfigDescriptor.equals(that.slConfigDescriptor) : that.slConfigDescriptor != null)
            return false;

        return true;
    
public DecoderConfigDescriptorgetDecoderConfigDescriptor()

        return decoderConfigDescriptor;
    
public intgetDependsOnEsId()

        return dependsOnEsId;
    
public intgetEsId()

        return esId;
    
public java.util.ListgetOtherDescriptors()

        return otherDescriptors;
    
public intgetRemoteODFlag()

        return remoteODFlag;
    
public SLConfigDescriptorgetSlConfigDescriptor()

        return slConfigDescriptor;
    
public intgetStreamDependenceFlag()

        return streamDependenceFlag;
    
public intgetStreamPriority()

        return streamPriority;
    
public intgetURLFlag()

        return URLFlag;
    
public intgetURLLength()

        return URLLength;
    
public java.lang.StringgetURLString()

        return URLString;
    
public intgetoCREsId()

        return oCREsId;
    
public intgetoCRstreamFlag()

        return oCRstreamFlag;
    
public inthashCode()

        int result = esId;
        result = 31 * result + streamDependenceFlag;
        result = 31 * result + URLFlag;
        result = 31 * result + oCRstreamFlag;
        result = 31 * result + streamPriority;
        result = 31 * result + URLLength;
        result = 31 * result + (URLString != null ? URLString.hashCode() : 0);
        result = 31 * result + remoteODFlag;
        result = 31 * result + dependsOnEsId;
        result = 31 * result + oCREsId;
        result = 31 * result + (decoderConfigDescriptor != null ? decoderConfigDescriptor.hashCode() : 0);
        result = 31 * result + (slConfigDescriptor != null ? slConfigDescriptor.hashCode() : 0);
        result = 31 * result + (otherDescriptors != null ? otherDescriptors.hashCode() : 0);
        return result;
    
public voidparseDetail(java.nio.ByteBuffer bb)


    
          
        esId = IsoTypeReader.readUInt16(bb);

        int data = IsoTypeReader.readUInt8(bb);
        streamDependenceFlag = data >>> 7;
        URLFlag = (data >>> 6) & 0x1;
        oCRstreamFlag = (data >>> 5) & 0x1;
        streamPriority = data & 0x1f;

        if (streamDependenceFlag == 1) {
            dependsOnEsId = IsoTypeReader.readUInt16(bb);
        }
        if (URLFlag == 1) {
            URLLength = IsoTypeReader.readUInt8(bb);
            URLString = IsoTypeReader.readString(bb, URLLength);
        }
        if (oCRstreamFlag == 1) {
            oCREsId = IsoTypeReader.readUInt16(bb);
        }

        int baseSize = 1 /*tag*/ + getSizeBytes() + 2 + 1 + (streamDependenceFlag == 1 ? 2 : 0) + (URLFlag == 1 ? 1 + URLLength : 0) + (oCRstreamFlag == 1 ? 2 : 0);

        int begin = bb.position();
        if (getSize() > baseSize + 2) {
            BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb);
            final long read = bb.position() - begin;
            log.finer(descriptor + " - ESDescriptor1 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null));
            if (descriptor != null) {
                final int size = descriptor.getSize();
                bb.position(begin + size);
                baseSize += size;
            } else {
                baseSize += read;
            }
            if (descriptor instanceof DecoderConfigDescriptor) {
                decoderConfigDescriptor = (DecoderConfigDescriptor) descriptor;
            }
        }

        begin = bb.position();
        if (getSize() > baseSize + 2) {
            BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb);
            final long read = bb.position() - begin;
            log.finer(descriptor + " - ESDescriptor2 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null));
            if (descriptor != null) {
                final int size = descriptor.getSize();
                bb.position(begin + size);
                baseSize += size;
            } else {
                baseSize += read;
            }
            if (descriptor instanceof SLConfigDescriptor) {
                slConfigDescriptor = (SLConfigDescriptor) descriptor;
            }
        } else {
            log.warning("SLConfigDescriptor is missing!");
        }

        while (getSize() - baseSize > 2) {
            begin = bb.position();
            BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb);
            final long read = bb.position() - begin;
            log.finer(descriptor + " - ESDescriptor3 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null));
            if (descriptor != null) {
                final int size = descriptor.getSize();
                bb.position(begin + size);
                baseSize += size;
            } else {
                baseSize += read;
            }
            otherDescriptors.add(descriptor);
        }
    
public java.nio.ByteBufferserialize()

        ByteBuffer out = ByteBuffer.allocate(serializedSize()); // Usually is around 30 bytes, so 200 should be enough...
        IsoTypeWriter.writeUInt8(out, 3);
        IsoTypeWriter.writeUInt8(out, serializedSize() - 2); // Not OK for longer sizes!
        IsoTypeWriter.writeUInt16(out, esId);
        int flags = (streamDependenceFlag << 7) | (URLFlag << 6) | (oCRstreamFlag << 5) | (streamPriority & 0x1f);
        IsoTypeWriter.writeUInt8(out, flags);
        if (streamDependenceFlag > 0) {
            IsoTypeWriter.writeUInt16(out, dependsOnEsId);
        }
        if (URLFlag > 0) {
            IsoTypeWriter.writeUInt8(out, URLLength);
            IsoTypeWriter.writeUtf8String(out, URLString);
        }
        if (oCRstreamFlag > 0) {
            IsoTypeWriter.writeUInt16(out, oCREsId);
        }

        ByteBuffer dec = decoderConfigDescriptor.serialize();
        ByteBuffer sl = slConfigDescriptor.serialize();
        out.put(dec.array());
        out.put(sl.array());

        // Doesn't handle other descriptors yet

        return out;
    
public intserializedSize()

        int out = 5;
        if (streamDependenceFlag > 0) {
            out += 2;
        }
        if (URLFlag > 0) {
            out += 1 + URLLength;
        }
        if (oCRstreamFlag > 0) {
            out += 2;
        }

        out += decoderConfigDescriptor.serializedSize();
        out += slConfigDescriptor.serializedSize();

        // Doesn't handle other descriptors yet

        return out;
    
public voidsetDecoderConfigDescriptor(DecoderConfigDescriptor decoderConfigDescriptor)

        this.decoderConfigDescriptor = decoderConfigDescriptor;
    
public voidsetDependsOnEsId(int dependsOnEsId)

        this.dependsOnEsId = dependsOnEsId;
    
public voidsetEsId(int esId)

        this.esId = esId;
    
public voidsetRemoteODFlag(int remoteODFlag)

        this.remoteODFlag = remoteODFlag;
    
public voidsetSlConfigDescriptor(SLConfigDescriptor slConfigDescriptor)

        this.slConfigDescriptor = slConfigDescriptor;
    
public voidsetStreamDependenceFlag(int streamDependenceFlag)

        this.streamDependenceFlag = streamDependenceFlag;
    
public voidsetStreamPriority(int streamPriority)

        this.streamPriority = streamPriority;
    
public voidsetURLFlag(int URLFlag)

        this.URLFlag = URLFlag;
    
public voidsetURLLength(int URLLength)

        this.URLLength = URLLength;
    
public voidsetURLString(java.lang.String URLString)

        this.URLString = URLString;
    
public voidsetoCREsId(int oCREsId)

        this.oCREsId = oCREsId;
    
public voidsetoCRstreamFlag(int oCRstreamFlag)

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

        final StringBuilder sb = new StringBuilder();
        sb.append("ESDescriptor");
        sb.append("{esId=").append(esId);
        sb.append(", streamDependenceFlag=").append(streamDependenceFlag);
        sb.append(", URLFlag=").append(URLFlag);
        sb.append(", oCRstreamFlag=").append(oCRstreamFlag);
        sb.append(", streamPriority=").append(streamPriority);
        sb.append(", URLLength=").append(URLLength);
        sb.append(", URLString='").append(URLString).append('\'");
        sb.append(", remoteODFlag=").append(remoteODFlag);
        sb.append(", dependsOnEsId=").append(dependsOnEsId);
        sb.append(", oCREsId=").append(oCREsId);
        sb.append(", decoderConfigDescriptor=").append(decoderConfigDescriptor);
        sb.append(", slConfigDescriptor=").append(slConfigDescriptor);
        sb.append('}");
        return sb.toString();