• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.coremedia.iso.boxes;
18 
19 import com.googlecode.mp4parser.AbstractContainerBox;
20 
21 /**
22  * The sample table contains all the time and data indexing of the media samples in a track. Using the tables
23  * here, it is possible to locate samples in time, determine their type (e.g. I-frame or not), and determine their
24  * size, container, and offset into that container.  <br>
25  * If the track that contains the Sample Table Box references no data, then the Sample Table Box does not need
26  * to contain any sub-boxes (this is not a very useful media track).                                          <br>
27  * If the track that the Sample Table Box is contained in does reference data, then the following sub-boxes are
28  * required: Sample Description, Sample Size, Sample To Chunk, and Chunk Offset. Further, the Sample
29  * Description Box shall contain at least one entry. A Sample Description Box is required because it contains the
30  * data reference index field which indicates which Data Reference Box to use to retrieve the media samples.
31  * Without the Sample Description, it is not possible to determine where the media samples are stored. The Sync
32  * Sample Box is optional. If the Sync Sample Box is not present, all samples are sync samples.<br>
33  * Annex A provides a narrative description of random access using the structures defined in the Sample Table
34  * Box.
35  */
36 public class SampleTableBox extends AbstractContainerBox {
37     public static final String TYPE = "stbl";
38 
SampleTableBox()39     public SampleTableBox() {
40         super(TYPE);
41     }
42 
getSampleDescriptionBox()43     public SampleDescriptionBox getSampleDescriptionBox() {
44         for (Box box : boxes) {
45             if (box instanceof SampleDescriptionBox) {
46                 return (SampleDescriptionBox) box;
47             }
48         }
49         return null;
50     }
51 
getSampleSizeBox()52     public SampleSizeBox getSampleSizeBox() {
53         for (Box box : boxes) {
54             if (box instanceof SampleSizeBox) {
55                 return (SampleSizeBox) box;
56             }
57         }
58         return null;
59     }
60 
getSampleToChunkBox()61     public SampleToChunkBox getSampleToChunkBox() {
62         for (Box box : boxes) {
63             if (box instanceof SampleToChunkBox) {
64                 return (SampleToChunkBox) box;
65             }
66         }
67         return null;
68     }
69 
getChunkOffsetBox()70     public ChunkOffsetBox getChunkOffsetBox() {
71         for (Box box : boxes) {
72             if (box instanceof ChunkOffsetBox) {
73                 return (ChunkOffsetBox) box;
74             }
75         }
76         return null;
77     }
78 
setChunkOffsetBox(ChunkOffsetBox b)79     public void setChunkOffsetBox(ChunkOffsetBox b) {
80         for (int i = 0; i < boxes.size(); i++) {
81             Box box = boxes.get(i);
82             if (box instanceof ChunkOffsetBox) {
83                 boxes.set(i, b);
84             }
85         }
86     }
87 
getTimeToSampleBox()88     public TimeToSampleBox getTimeToSampleBox() {
89         for (Box box : boxes) {
90             if (box instanceof TimeToSampleBox) {
91                 return (TimeToSampleBox) box;
92             }
93         }
94         return null;
95     }
96 
getSyncSampleBox()97     public SyncSampleBox getSyncSampleBox() {
98         for (Box box : boxes) {
99             if (box instanceof SyncSampleBox) {
100                 return (SyncSampleBox) box;
101             }
102         }
103         return null;
104     }
105 
getCompositionTimeToSample()106     public CompositionTimeToSample getCompositionTimeToSample() {
107         for (Box box : boxes) {
108             if (box instanceof CompositionTimeToSample) {
109                 return (CompositionTimeToSample) box;
110             }
111         }
112         return null;
113     }
114 
getSampleDependencyTypeBox()115     public SampleDependencyTypeBox getSampleDependencyTypeBox() {
116         for (Box box : boxes) {
117             if (box instanceof SampleDependencyTypeBox) {
118                 return (SampleDependencyTypeBox) box;
119             }
120         }
121         return null;
122     }
123 
124 }
125