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
17package com.coremedia.iso.boxes;
18
19import com.googlecode.mp4parser.AbstractBox;
20
21import java.nio.ByteBuffer;
22
23/**
24 * The contents of a free-space box are irrelevant and may be ignored, or the object deleted, without affecting the
25 * presentation. Care should be excercized when deleting the object, as this may invalidate the offsets used in the
26 * sample table.
27 */
28public class FreeSpaceBox extends AbstractBox {
29    public static final String TYPE = "skip";
30
31    byte[] data;
32
33    protected long getContentSize() {
34        return data.length;
35    }
36
37    public FreeSpaceBox() {
38        super(TYPE);
39    }
40
41    public void setData(byte[] data) {
42        this.data = data;
43    }
44
45    public byte[] getData() {
46        return data;
47    }
48
49    @Override
50    public void _parseDetails(ByteBuffer content) {
51        data = new byte[content.remaining()];
52        content.get(data);
53    }
54
55    @Override
56    protected void getContent(ByteBuffer byteBuffer) {
57        byteBuffer.put(data);
58    }
59
60    public String toString() {
61        return "FreeSpaceBox[size=" + data.length + ";type=" + getType() + "]";
62    }
63}
64