1/*
2 * Copyright 2011 castLabs, 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
17package com.googlecode.mp4parser.boxes.mp4.objectdescriptors;
18
19import com.coremedia.iso.Hex;
20
21import java.io.IOException;
22import java.nio.ByteBuffer;
23import java.util.logging.Logger;
24
25/**
26 * abstract class ExtensionDescriptor extends BaseDescriptor
27 * : bit(8) tag = ExtensionProfileLevelDescrTag, ExtDescrTagStartRange ..
28 * ExtDescrTagEndRange {
29 * // empty. To be filled by classes extending this class.
30 * }
31 */
32@Descriptor(tags = {0x13, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253})
33public class ExtensionDescriptor extends BaseDescriptor {
34    private static Logger log = Logger.getLogger(ExtensionDescriptor.class.getName());
35
36    byte[] bytes;
37
38
39    //todo: add this better to the tags list?
40    //14496-1:2010 p.20:
41    //0x6A-0xBF Reserved for ISO use
42    //0xC0-0xFE User private
43    //
44    //ExtDescrTagStartRange = 0x6A
45    //ExtDescrTagEndRange = 0xFE
46    static int[] allTags() {
47        int[] ints = new int[0xFE - 0x6A];
48
49        for (int i = 0x6A; i < 0xFE; i++) {
50            final int pos = i - 0x6A;
51            log.finest("pos:" + pos);
52            ints[pos] = i;
53        }
54        return ints;
55    }
56
57    @Override
58    public void parseDetail(ByteBuffer bb) throws IOException {
59        if (getSize() > 0) {
60            bytes = new byte[sizeOfInstance];
61            bb.get(bytes);
62        }
63    }
64
65    @Override
66    public String toString() {
67        final StringBuilder sb = new StringBuilder();
68        sb.append("ExtensionDescriptor");
69        sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes));
70        sb.append('}');
71        return sb.toString();
72    }
73}
74