1 /* 2 * Copyright 2011 castLabs, Berlin 3 * 4 * Licensed under the Apache License, Version 2.0 (the License); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an AS IS BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; 18 19 import com.coremedia.iso.IsoTypeReader; 20 import com.coremedia.iso.IsoTypeWriter; 21 22 import java.io.IOException; 23 import java.nio.ByteBuffer; 24 25 /** 26 * class SLConfigDescriptor extends BaseDescriptor : bit(8) tag=SLConfigDescrTag { 27 * bit(8) predefined; 28 * if (predefined==0) { 29 * bit(1) useAccessUnitStartFlag; 30 * bit(1) useAccessUnitEndFlag; 31 * bit(1) useRandomAccessPointFlag; 32 * bit(1) hasRandomAccessUnitsOnlyFlag; 33 * bit(1) usePaddingFlag; 34 * bit(1) useTimeStampsFlag; 35 * bit(1) useIdleFlag; 36 * bit(1) durationFlag; 37 * bit(32) timeStampResolution; 38 * bit(32) OCRResolution; 39 * bit(8) timeStampLength; // must be ≤ 64 40 * bit(8) OCRLength; // must be ≤ 64 41 * bit(8) AU_Length; // must be ≤ 32 42 * bit(8) instantBitrateLength; 43 * bit(4) degradationPriorityLength; 44 * bit(5) AU_seqNumLength; // must be ≤ 16 45 * bit(5) packetSeqNumLength; // must be ≤ 16 46 * bit(2) reserved=0b11; 47 * } 48 * if (durationFlag) { 49 * bit(32) timeScale; 50 * bit(16) accessUnitDuration; 51 * bit(16) compositionUnitDuration; 52 * } 53 * if (!useTimeStampsFlag) { 54 * bit(timeStampLength) startDecodingTimeStamp; 55 * bit(timeStampLength) startCompositionTimeStamp; 56 * } 57 * } 58 */ 59 @Descriptor(tags = {0x06}) 60 public class SLConfigDescriptor extends BaseDescriptor { 61 int predefined; 62 getPredefined()63 public int getPredefined() { 64 return predefined; 65 } 66 setPredefined(int predefined)67 public void setPredefined(int predefined) { 68 this.predefined = predefined; 69 } 70 71 @Override parseDetail(ByteBuffer bb)72 public void parseDetail(ByteBuffer bb) throws IOException { 73 predefined = IsoTypeReader.readUInt8(bb); 74 } 75 serializedSize()76 public int serializedSize() { 77 return 3; 78 } 79 serialize()80 public ByteBuffer serialize() { 81 ByteBuffer out = ByteBuffer.allocate(3); 82 IsoTypeWriter.writeUInt8(out, 6); 83 IsoTypeWriter.writeUInt8(out, 1); 84 IsoTypeWriter.writeUInt8(out, predefined); 85 return out; 86 } 87 88 @Override toString()89 public String toString() { 90 final StringBuilder sb = new StringBuilder(); 91 sb.append("SLConfigDescriptor"); 92 sb.append("{predefined=").append(predefined); 93 sb.append('}'); 94 return sb.toString(); 95 } 96 97 @Override equals(Object o)98 public boolean equals(Object o) { 99 if (this == o) { 100 return true; 101 } 102 if (o == null || getClass() != o.getClass()) { 103 return false; 104 } 105 106 SLConfigDescriptor that = (SLConfigDescriptor) o; 107 108 if (predefined != that.predefined) { 109 return false; 110 } 111 112 return true; 113 } 114 115 @Override hashCode()116 public int hashCode() { 117 return predefined; 118 } 119 } 120