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.coremedia.iso.BoxParser;
20import com.coremedia.iso.boxes.ContainerBox;
21
22import java.io.IOException;
23import java.nio.ByteBuffer;
24import java.nio.channels.ReadableByteChannel;
25import java.nio.channels.WritableByteChannel;
26
27/**
28 * Defines basic interaction possibilities for any ISO box. Each box has a parent box and a type.
29 */
30public interface Box {
31    ContainerBox getParent();
32
33    void setParent(ContainerBox parent);
34
35    long getSize();
36
37    /**
38     * The box's 4-cc type.
39     * @return the 4 character type of the box
40     */
41    String getType();
42
43    /**
44     * Writes the complete box - size | 4-cc | content - to the given <code>writableByteChannel</code>.
45     * @param writableByteChannel the box's sink
46     * @throws IOException in case of problems with the <code>Channel</code>
47     */
48    void getBox(WritableByteChannel writableByteChannel) throws IOException;
49
50    void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException;
51}
52