• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2009 castLabs GmbH, Berlin
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.fragment;
18 
19 import com.coremedia.iso.IsoTypeReader;
20 import com.coremedia.iso.IsoTypeWriter;
21 import com.googlecode.mp4parser.AbstractFullBox;
22 
23 import java.nio.ByteBuffer;
24 
25 /**
26  * aligned(8) class MovieExtendsHeaderBox extends FullBox('mehd', version, 0) {
27  * if (version==1) {
28  * unsigned int(64) fragment_duration;
29  * } else { // version==0
30  * unsigned int(32) fragment_duration;
31  * }
32  * }
33  */
34 public class MovieExtendsHeaderBox extends AbstractFullBox {
35     public static final String TYPE = "mehd";
36     private long fragmentDuration;
37 
MovieExtendsHeaderBox()38     public MovieExtendsHeaderBox() {
39         super(TYPE);
40     }
41 
42     @Override
getContentSize()43     protected long getContentSize() {
44         return getVersion() == 1 ? 12 : 8;
45     }
46 
47     @Override
_parseDetails(ByteBuffer content)48     public void _parseDetails(ByteBuffer content) {
49         parseVersionAndFlags(content);
50         fragmentDuration = getVersion() == 1 ? IsoTypeReader.readUInt64(content) : IsoTypeReader.readUInt32(content);
51     }
52 
53 
54     @Override
getContent(ByteBuffer byteBuffer)55     protected void getContent(ByteBuffer byteBuffer) {
56         writeVersionAndFlags(byteBuffer);
57         if (getVersion() == 1) {
58             IsoTypeWriter.writeUInt64(byteBuffer, fragmentDuration);
59         } else {
60             IsoTypeWriter.writeUInt32(byteBuffer, fragmentDuration);
61         }
62     }
63 
getFragmentDuration()64     public long getFragmentDuration() {
65         return fragmentDuration;
66     }
67 
setFragmentDuration(long fragmentDuration)68     public void setFragmentDuration(long fragmentDuration) {
69         this.fragmentDuration = fragmentDuration;
70     }
71 }
72