• 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  * The copyright box contains a copyright declaration which applies to the entire presentation, when contained
29  * within the MovieBox, or, when contained in a track, to that entire track. There may be multple boxes using
30  * different language codes.
31  *
32  * @see MovieBox
33  * @see TrackBox
34  */
35 public class CopyrightBox extends AbstractFullBox {
36     public static final String TYPE = "cprt";
37 
38     private String language;
39     private String copyright;
40 
CopyrightBox()41     public CopyrightBox() {
42         super(TYPE);
43     }
44 
getLanguage()45     public String getLanguage() {
46         return language;
47     }
48 
getCopyright()49     public String getCopyright() {
50         return copyright;
51     }
52 
setLanguage(String language)53     public void setLanguage(String language) {
54         this.language = language;
55     }
56 
setCopyright(String copyright)57     public void setCopyright(String copyright) {
58         this.copyright = copyright;
59     }
60 
getContentSize()61     protected long getContentSize() {
62         return 7 + Utf8.utf8StringLengthInBytes(copyright);
63     }
64 
65     @Override
_parseDetails(ByteBuffer content)66     public void _parseDetails(ByteBuffer content) {
67         parseVersionAndFlags(content);
68         language = IsoTypeReader.readIso639(content);
69         copyright = IsoTypeReader.readString(content);
70     }
71 
72     @Override
getContent(ByteBuffer byteBuffer)73     protected void getContent(ByteBuffer byteBuffer) {
74         writeVersionAndFlags(byteBuffer);
75         IsoTypeWriter.writeIso639(byteBuffer, language);
76         byteBuffer.put(Utf8.convert(copyright));
77         byteBuffer.put((byte) 0);
78     }
79 
toString()80     public String toString() {
81         return "CopyrightBox[language=" + getLanguage() + ";copyright=" + getCopyright() + "]";
82     }
83 
84 
85 
86 }
87