• 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.IsoTypeReader;
20 import com.coremedia.iso.IsoTypeWriter;
21 
22 import java.nio.ByteBuffer;
23 
24 /**
25  * The video media header contains general presentation information, independent of the coding, for video
26  * media. Note that the flags field has the value 1.
27  */
28 public class VideoMediaHeaderBox extends AbstractMediaHeaderBox {
29     private int graphicsmode = 0;
30     private int[] opcolor = new int[]{0, 0, 0};
31     public static final String TYPE = "vmhd";
32 
VideoMediaHeaderBox()33     public VideoMediaHeaderBox() {
34         super(TYPE);
35         setFlags(1); // 1 is default.
36     }
37 
getGraphicsmode()38     public int getGraphicsmode() {
39         return graphicsmode;
40     }
41 
getOpcolor()42     public int[] getOpcolor() {
43         return opcolor;
44     }
45 
getContentSize()46     protected long getContentSize() {
47         return 12;
48     }
49 
50 
51     @Override
_parseDetails(ByteBuffer content)52     public void _parseDetails(ByteBuffer content) {
53         parseVersionAndFlags(content);
54         graphicsmode = IsoTypeReader.readUInt16(content);
55         opcolor = new int[3];
56         for (int i = 0; i < 3; i++) {
57             opcolor[i] = IsoTypeReader.readUInt16(content);
58         }
59     }
60 
61     @Override
getContent(ByteBuffer byteBuffer)62     protected void getContent(ByteBuffer byteBuffer) {
63         writeVersionAndFlags(byteBuffer);
64         IsoTypeWriter.writeUInt16(byteBuffer, graphicsmode);
65         for (int anOpcolor : opcolor) {
66             IsoTypeWriter.writeUInt16(byteBuffer, anOpcolor);
67         }
68     }
69 
toString()70     public String toString() {
71         return "VideoMediaHeaderBox[graphicsmode=" + getGraphicsmode() + ";opcolor0=" + getOpcolor()[0] + ";opcolor1=" + getOpcolor()[1] + ";opcolor2=" + getOpcolor()[2] + "]";
72     }
73 
setOpcolor(int[] opcolor)74     public void setOpcolor(int[] opcolor) {
75         this.opcolor = opcolor;
76     }
77 
setGraphicsmode(int graphicsmode)78     public void setGraphicsmode(int graphicsmode) {
79         this.graphicsmode = graphicsmode;
80     }
81 }
82