1d22bd1421cdfa1900df5b76e6f862596bdd11074Michel Dänzer/* 2d22bd1421cdfa1900df5b76e6f862596bdd11074Michel Dänzer * Copyright 2008 CoreMedia AG, Hamburg 3d22bd1421cdfa1900df5b76e6f862596bdd11074Michel Dänzer * 4d22bd1421cdfa1900df5b76e6f862596bdd11074Michel Dänzer * Licensed under the Apache License, Version 2.0 (the License); 5d22bd1421cdfa1900df5b76e6f862596bdd11074Michel Dänzer * you may not use this file except in compliance with the License. 6601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * You may obtain a copy of the License at 7601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * 8601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * http://www.apache.org/licenses/LICENSE-2.0 9601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * 10601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * Unless required by applicable law or agreed to in writing, software 11601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * distributed under the License is distributed on an AS IS BASIS, 12235225ec935002b4669d14a48c9c20864a5496f8José Fonseca * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * See the License for the specific language governing permissions and 14235225ec935002b4669d14a48c9c20864a5496f8José Fonseca * limitations under the License. 15d49dfe66cfb0e13094e5918b9857c4eb474a53f6José Fonseca */ 16235225ec935002b4669d14a48c9c20864a5496f8José Fonseca 17d49dfe66cfb0e13094e5918b9857c4eb474a53f6José Fonsecapackage com.coremedia.iso.boxes; 18601498ae73e654c2de997ea75075613a694d604dJosé Fonseca 19601498ae73e654c2de997ea75075613a694d604dJosé Fonsecaimport com.coremedia.iso.IsoFile; 20601498ae73e654c2de997ea75075613a694d604dJosé Fonsecaimport com.coremedia.iso.IsoTypeReader; 21601498ae73e654c2de997ea75075613a694d604dJosé Fonsecaimport com.coremedia.iso.IsoTypeWriter; 22601498ae73e654c2de997ea75075613a694d604dJosé Fonsecaimport com.coremedia.iso.Utf8; 23601498ae73e654c2de997ea75075613a694d604dJosé Fonsecaimport com.googlecode.mp4parser.AbstractFullBox; 24601498ae73e654c2de997ea75075613a694d604dJosé Fonseca 25f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantzimport java.nio.ByteBuffer; 26f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz 27601498ae73e654c2de997ea75075613a694d604dJosé Fonseca/** 28601498ae73e654c2de997ea75075613a694d604dJosé Fonseca * Classification of the media according to 3GPP 26.244. 29601498ae73e654c2de997ea75075613a694d604dJosé Fonseca */ 30601498ae73e654c2de997ea75075613a694d604dJosé Fonsecapublic class ClassificationBox extends AbstractFullBox { 31601498ae73e654c2de997ea75075613a694d604dJosé Fonseca public static final String TYPE = "clsf"; 32601498ae73e654c2de997ea75075613a694d604dJosé Fonseca 33601498ae73e654c2de997ea75075613a694d604dJosé Fonseca 34601498ae73e654c2de997ea75075613a694d604dJosé Fonseca private String classificationEntity; 358f26b59f53d6d80bf7d3c39a4dd3c438a2c305a4Maarten Lankhorst private int classificationTableIndex; 36f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz private String language; 37f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz private String classificationInfo; 38f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz 39f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz public ClassificationBox() { 40f1600d3a9725803f0526fb3fd673787307539d27Jakob Bornecrantz super(TYPE); 41601498ae73e654c2de997ea75075613a694d604dJosé Fonseca } 42601498ae73e654c2de997ea75075613a694d604dJosé Fonseca 43 public String getLanguage() { 44 return language; 45 } 46 47 public String getClassificationEntity() { 48 return classificationEntity; 49 } 50 51 public int getClassificationTableIndex() { 52 return classificationTableIndex; 53 } 54 55 public String getClassificationInfo() { 56 return classificationInfo; 57 } 58 59 public void setClassificationEntity(String classificationEntity) { 60 this.classificationEntity = classificationEntity; 61 } 62 63 public void setClassificationTableIndex(int classificationTableIndex) { 64 this.classificationTableIndex = classificationTableIndex; 65 } 66 67 public void setLanguage(String language) { 68 this.language = language; 69 } 70 71 public void setClassificationInfo(String classificationInfo) { 72 this.classificationInfo = classificationInfo; 73 } 74 75 protected long getContentSize() { 76 return 4 + 2 + 2 + Utf8.utf8StringLengthInBytes(classificationInfo) + 1; 77 } 78 79 @Override 80 public void _parseDetails(ByteBuffer content) { 81 parseVersionAndFlags(content); 82 byte[] cE = new byte[4]; 83 content.get(cE); 84 classificationEntity = IsoFile.bytesToFourCC(cE); 85 classificationTableIndex = IsoTypeReader.readUInt16(content); 86 language = IsoTypeReader.readIso639(content); 87 classificationInfo = IsoTypeReader.readString(content); 88 } 89 90 @Override 91 protected void getContent(ByteBuffer byteBuffer) { 92 byteBuffer.put(IsoFile.fourCCtoBytes(classificationEntity)); 93 IsoTypeWriter.writeUInt16(byteBuffer, classificationTableIndex); 94 IsoTypeWriter.writeIso639(byteBuffer, language); 95 byteBuffer.put(Utf8.convert(classificationInfo)); 96 byteBuffer.put((byte) 0); 97 } 98 99 100 public String toString() { 101 StringBuilder buffer = new StringBuilder(); 102 buffer.append("ClassificationBox[language=").append(getLanguage()); 103 buffer.append("classificationEntity=").append(getClassificationEntity()); 104 buffer.append(";classificationTableIndex=").append(getClassificationTableIndex()); 105 buffer.append(";language=").append(getLanguage()); 106 buffer.append(";classificationInfo=").append(getClassificationInfo()); 107 buffer.append("]"); 108 return buffer.toString(); 109 } 110} 111