• 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 
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  * Meta information in a 'udta' box about a track.
29  * Defined in 3GPP 26.244.
30  *
31  * @see com.coremedia.iso.boxes.UserDataBox
32  */
33 public class AuthorBox extends AbstractFullBox {
34     public static final String TYPE = "auth";
35 
36     private String language;
37     private String author;
38 
AuthorBox()39     public AuthorBox() {
40         super(TYPE);
41     }
42 
43     /**
44      * Declares the language code for the {@link #getAuthor()} return value. See ISO 639-2/T for the set of three
45      * character codes.Each character is packed as the difference between its ASCII value and 0x60. The code is
46      * confined to being three lower-case letters, so these values are strictly positive.
47      *
48      * @return the language code
49      */
getLanguage()50     public String getLanguage() {
51         return language;
52     }
53 
54     /**
55      * Author information.
56      *
57      * @return the author
58      */
getAuthor()59     public String getAuthor() {
60         return author;
61     }
62 
setLanguage(String language)63     public void setLanguage(String language) {
64         this.language = language;
65     }
66 
setAuthor(String author)67     public void setAuthor(String author) {
68         this.author = author;
69     }
70 
getContentSize()71     protected long getContentSize() {
72         return 7 + Utf8.utf8StringLengthInBytes(author);
73     }
74 
75     @Override
_parseDetails(ByteBuffer content)76     public void _parseDetails(ByteBuffer content) {
77         parseVersionAndFlags(content);
78         language = IsoTypeReader.readIso639(content);
79         author = IsoTypeReader.readString(content);
80     }
81 
82     @Override
getContent(ByteBuffer byteBuffer)83     protected void getContent(ByteBuffer byteBuffer) {
84         writeVersionAndFlags(byteBuffer);
85         IsoTypeWriter.writeIso639(byteBuffer, language);
86         byteBuffer.put(Utf8.convert(author));
87         byteBuffer.put((byte) 0);
88     }
89 
90 
toString()91     public String toString() {
92         return "AuthorBox[language=" + getLanguage() + ";author=" + getAuthor() + "]";
93     }
94 }
95