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.IsoTypeReader; 20 import com.coremedia.iso.IsoTypeWriter; 21 import com.coremedia.iso.Utf8; 22 import com.googlecode.mp4parser.AbstractFullBox; 23 24 import java.nio.ByteBuffer; 25 26 /** 27 * Used to give information about the performer. Mostly used in confunction with music files. 28 * See 3GPP 26.234 for details. 29 */ 30 public class PerformerBox extends AbstractFullBox { 31 public static final String TYPE = "perf"; 32 33 private String language; 34 private String performer; 35 PerformerBox()36 public PerformerBox() { 37 super(TYPE); 38 } 39 getLanguage()40 public String getLanguage() { 41 return language; 42 } 43 getPerformer()44 public String getPerformer() { 45 return performer; 46 } 47 setLanguage(String language)48 public void setLanguage(String language) { 49 this.language = language; 50 } 51 setPerformer(String performer)52 public void setPerformer(String performer) { 53 this.performer = performer; 54 } 55 getContentSize()56 protected long getContentSize() { 57 return 6 + Utf8.utf8StringLengthInBytes(performer) + 1; 58 } 59 60 @Override getContent(ByteBuffer byteBuffer)61 protected void getContent(ByteBuffer byteBuffer) { 62 writeVersionAndFlags(byteBuffer); 63 IsoTypeWriter.writeIso639(byteBuffer, language); 64 byteBuffer.put(Utf8.convert(performer)); 65 byteBuffer.put((byte) 0); 66 } 67 68 @Override _parseDetails(ByteBuffer content)69 public void _parseDetails(ByteBuffer content) { 70 parseVersionAndFlags(content); 71 language = IsoTypeReader.readIso639(content); 72 performer = IsoTypeReader.readString(content); 73 } 74 toString()75 public String toString() { 76 return "PerformerBox[language=" + getLanguage() + ";performer=" + getPerformer() + "]"; 77 } 78 } 79