• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2008 CoreMedia AG, Hamburg
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.coremedia.iso.boxes;
18 
19 import com.coremedia.iso.IsoFile;
20 import com.coremedia.iso.IsoTypeReader;
21 import com.coremedia.iso.IsoTypeWriter;
22 import com.coremedia.iso.Utf8;
23 import com.googlecode.mp4parser.AbstractFullBox;
24 
25 import java.nio.ByteBuffer;
26 
27 /**
28  * Classification of the media according to 3GPP 26.244.
29  */
30 public class ClassificationBox extends AbstractFullBox {
31     public static final String TYPE = "clsf";
32 
33 
34     private String classificationEntity;
35     private int classificationTableIndex;
36     private String language;
37     private String classificationInfo;
38 
ClassificationBox()39     public ClassificationBox() {
40         super(TYPE);
41     }
42 
getLanguage()43     public String getLanguage() {
44         return language;
45     }
46 
getClassificationEntity()47     public String getClassificationEntity() {
48         return classificationEntity;
49     }
50 
getClassificationTableIndex()51     public int getClassificationTableIndex() {
52         return classificationTableIndex;
53     }
54 
getClassificationInfo()55     public String getClassificationInfo() {
56         return classificationInfo;
57     }
58 
setClassificationEntity(String classificationEntity)59     public void setClassificationEntity(String classificationEntity) {
60         this.classificationEntity = classificationEntity;
61     }
62 
setClassificationTableIndex(int classificationTableIndex)63     public void setClassificationTableIndex(int classificationTableIndex) {
64         this.classificationTableIndex = classificationTableIndex;
65     }
66 
setLanguage(String language)67     public void setLanguage(String language) {
68         this.language = language;
69     }
70 
setClassificationInfo(String classificationInfo)71     public void setClassificationInfo(String classificationInfo) {
72         this.classificationInfo = classificationInfo;
73     }
74 
getContentSize()75     protected long getContentSize() {
76         return 4 + 2 + 2 + Utf8.utf8StringLengthInBytes(classificationInfo) + 1;
77     }
78 
79     @Override
_parseDetails(ByteBuffer content)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
getContent(ByteBuffer byteBuffer)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 
toString()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