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.IsoTypeReader;
20import com.coremedia.iso.IsoTypeWriter;
21import com.googlecode.mp4parser.FullContainerBox;
22
23import java.nio.ByteBuffer;
24
25/**
26 * The Item Protection Box provides an array of item protection information, for use by the Item Information Box.
27 *
28 * @see com.coremedia.iso.boxes.ItemProtectionBox
29 */
30public class ItemProtectionBox extends FullContainerBox {
31
32    public static final String TYPE = "ipro";
33
34    public ItemProtectionBox() {
35        super(TYPE);
36    }
37
38    public SchemeInformationBox getItemProtectionScheme() {
39        if (!getBoxes(SchemeInformationBox.class).isEmpty()) {
40            return getBoxes(SchemeInformationBox.class).get(0);
41        } else {
42            return null;
43        }
44    }
45
46    @Override
47    public void _parseDetails(ByteBuffer content) {
48        parseVersionAndFlags(content);
49        IsoTypeReader.readUInt16(content);
50        parseChildBoxes(content);
51    }
52
53
54    @Override
55    protected void getContent(ByteBuffer byteBuffer) {
56        writeVersionAndFlags(byteBuffer);
57        IsoTypeWriter.writeUInt16(byteBuffer, getBoxes().size());
58        writeChildBoxes(byteBuffer);
59    }
60
61}
62