summaryrefslogtreecommitdiff
path: root/isoparser/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptor.java_bak
blob: c5cb586f4ed471fc84c396b90fd2b6b98a692d89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright 2011 castLabs, Berlin
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.mp4parser.boxes.mp4.objectdescriptors;

import com.coremedia.iso.IsoTypeReader;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

/*
class ObjectDescriptor extends ObjectDescriptorBase : bit(8) tag=ObjectDescrTag {
bit(10) ObjectDescriptorID;
bit(1) URL_Flag;
const bit(5) reserved=0b1111.1;
if (URL_Flag) {
bit(8) URLlength;
bit(8) URLstring[URLlength];
} else {
ES_Descriptor esDescr[1 .. 255];
OCI_Descriptor ociDescr[0 .. 255];
IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255];
IPMP_Descriptor ipmpDescr [0 .. 255];
}
ExtensionDescriptor extDescr[0 .. 255];
}
*/
@Descriptor(tags = {0x01, 0x11})
public class ObjectDescriptor extends ObjectDescriptorBase {
    private int objectDescriptorId;
    int objectDescriptorUrlFlag;
    int objectDescriptorUrlLength;
    String objectDescriptorUrlString;


    private int streamCount;
    private int extensionFlag;
    private List<ESDescriptor> esDescriptors = new ArrayList<ESDescriptor>();

    private int descriptorLength;
    private List<ExtensionDescriptor> extensionDescriptors = new ArrayList<ExtensionDescriptor>();

    public static ObjectDescriptor createFrom(ByteBuffer in) throws IOException {
/*
    tmp = in.readUInt16();
    esDescriptor.objectDescriptorId = tmp & 0x3f;
    esDescriptor.objectDescriptorUrlFlag = (tmp >> 5) & 0x1;
    if (esDescriptor.objectDescriptorUrlFlag == 1) {
      esDescriptor.objectDescriptorUrlLength = in.readUInt8();
      esDescriptor.objectDescriptorUrlString = new String(in.read(esDescriptor.objectDescriptorUrlLength));
    }
     */

        ObjectDescriptor objectDescriptor = new ObjectDescriptor();

        int data = IsoTypeReader.readUInt16(in);

        objectDescriptor.objectDescriptorId = data & 0xFFC0;
        objectDescriptor.streamCount = data & 0x3E;
        objectDescriptor.extensionFlag = data & 0x1;

//    for (int i = 0; i < objectDescriptor.streamCount; i++) {
//      objectDescriptor.esDescriptors.add(ESDescriptor.createFrom(in));
//    }
//
//    if (objectDescriptor.extensionFlag == 1) {
//      objectDescriptor.descriptorLength = in.readUInt8();
//      for (int i = 0; i < objectDescriptor.descriptorLength;) {
//        ExtensionDescriptor extensionDescriptor = ExtensionDescriptor.createFrom(in);
//        objectDescriptor.extensionDescriptors.add(extensionDescriptor);
//        i = i + extensionDescriptor.descriptorDataLength + 1;
//      }
//    }

        return objectDescriptor;
    }

    @Override
    public String toString() {
        return "ObjectDescriptor{" +
                "objectDescriptorId=" + objectDescriptorId +
                ", streamCount=" + streamCount +
                ", extensionFlag=" + extensionFlag +
                ", esDescriptors=" + esDescriptors +
                ", descriptorLength=" + descriptorLength +
                ", extensionDescriptors=" + extensionDescriptors +
                '}';
    }
}