InitialObjectDescriptor.java revision dd9eb897ee7c7b507cbdcf80263bb4b5de6966bf
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 17package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; 18 19 20import com.coremedia.iso.IsoTypeReader; 21 22import java.io.IOException; 23import java.nio.ByteBuffer; 24import java.util.ArrayList; 25import java.util.List; 26 27/* 28class InitialObjectDescriptor extends ObjectDescriptorBase : bit(8) 29tag=InitialObjectDescrTag { 30bit(10) ObjectDescriptorID; 31bit(1) URL_Flag; 32bit(1) includeInlineProfileLevelFlag; 33const bit(4) reserved=0b1111; 34if (URL_Flag) { 35bit(8) URLlength; 36bit(8) URLstring[URLlength]; 37} else { 38bit(8) ODProfileLevelIndication; 39bit(8) sceneProfileLevelIndication; 40bit(8) audioProfileLevelIndication; 41bit(8) visualProfileLevelIndication; 42bit(8) graphicsProfileLevelIndication; 43ES_Descriptor esDescr[1 .. 255]; 44OCI_Descriptor ociDescr[0 .. 255]; 45IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255]; 46IPMP_Descriptor ipmpDescr [0 .. 255]; 47IPMP_ToolListDescriptor toolListDescr[0 .. 1]; 48} 49ExtensionDescriptor extDescr[0 .. 255]; 50} 51*/ 52//@Descriptor(tags = {0x02, 0x10}) 53public class InitialObjectDescriptor extends ObjectDescriptorBase { 54 private int objectDescriptorId; 55 int urlFlag; 56 int includeInlineProfileLevelFlag; 57 58 int urlLength; 59 String urlString; 60 61 int oDProfileLevelIndication; 62 int sceneProfileLevelIndication; 63 int audioProfileLevelIndication; 64 int visualProfileLevelIndication; 65 int graphicsProfileLevelIndication; 66 67 List<ESDescriptor> esDescriptors = new ArrayList<ESDescriptor>(); 68 69 List<ExtensionDescriptor> extensionDescriptors = new ArrayList<ExtensionDescriptor>(); 70 71 List<BaseDescriptor> unknownDescriptors = new ArrayList<BaseDescriptor>(); 72 73 @Override 74 public void parseDetail(ByteBuffer bb) throws IOException { 75 int data = IsoTypeReader.readUInt16(bb); 76 objectDescriptorId = (data & 0xFFC0) >> 6; 77 78 urlFlag = (data & 0x3F) >> 5; 79 includeInlineProfileLevelFlag = (data & 0x1F) >> 4; 80 81 int sizeLeft = getSize() - 2; 82 if (urlFlag == 1) { 83 urlLength = IsoTypeReader.readUInt8(bb); 84 urlString = IsoTypeReader.readString(bb, urlLength); 85 sizeLeft = sizeLeft - (1 + urlLength); 86 } else { 87 oDProfileLevelIndication = IsoTypeReader.readUInt8(bb); 88 sceneProfileLevelIndication = IsoTypeReader.readUInt8(bb); 89 audioProfileLevelIndication = IsoTypeReader.readUInt8(bb); 90 visualProfileLevelIndication = IsoTypeReader.readUInt8(bb); 91 graphicsProfileLevelIndication = IsoTypeReader.readUInt8(bb); 92 93 sizeLeft = sizeLeft - 5; 94 95 if (sizeLeft > 2) { 96 final BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); 97 sizeLeft = sizeLeft - descriptor.getSize(); 98 if (descriptor instanceof ESDescriptor) { 99 esDescriptors.add((ESDescriptor) descriptor); 100 } else { 101 unknownDescriptors.add(descriptor); 102 } 103 } 104 } 105 106 if (sizeLeft > 2) { 107 final BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); 108 if (descriptor instanceof ExtensionDescriptor) { 109 extensionDescriptors.add((ExtensionDescriptor) descriptor); 110 } else { 111 unknownDescriptors.add(descriptor); 112 } 113 } 114 } 115 116 @Override 117 public String toString() { 118 final StringBuilder sb = new StringBuilder(); 119 sb.append("InitialObjectDescriptor"); 120 sb.append("{objectDescriptorId=").append(objectDescriptorId); 121 sb.append(", urlFlag=").append(urlFlag); 122 sb.append(", includeInlineProfileLevelFlag=").append(includeInlineProfileLevelFlag); 123 sb.append(", urlLength=").append(urlLength); 124 sb.append(", urlString='").append(urlString).append('\''); 125 sb.append(", oDProfileLevelIndication=").append(oDProfileLevelIndication); 126 sb.append(", sceneProfileLevelIndication=").append(sceneProfileLevelIndication); 127 sb.append(", audioProfileLevelIndication=").append(audioProfileLevelIndication); 128 sb.append(", visualProfileLevelIndication=").append(visualProfileLevelIndication); 129 sb.append(", graphicsProfileLevelIndication=").append(graphicsProfileLevelIndication); 130 sb.append(", esDescriptors=").append(esDescriptors); 131 sb.append(", extensionDescriptors=").append(extensionDescriptors); 132 sb.append(", unknownDescriptors=").append(unknownDescriptors); 133 sb.append('}'); 134 return sb.toString(); 135 } 136} 137