• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
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 #include <utils/Vector.h>
18 
19 namespace android {
20 
21 class SampleTable;
22 
23 struct SampleIterator {
24     SampleIterator(SampleTable *table);
25 
26     status_t seekTo(uint32_t sampleIndex);
27 
getChunkIndexSampleIterator28     uint32_t getChunkIndex() const { return mCurrentChunkIndex; }
getDescIndexSampleIterator29     uint32_t getDescIndex() const { return mChunkDesc; }
getSampleOffsetSampleIterator30     off64_t getSampleOffset() const { return mCurrentSampleOffset; }
getSampleSizeSampleIterator31     size_t getSampleSize() const { return mCurrentSampleSize; }
getSampleTimeSampleIterator32     uint32_t getSampleTime() const { return mCurrentSampleTime; }
getSampleDurationSampleIterator33     uint32_t getSampleDuration() const { return mCurrentSampleDuration; }
34 
35     status_t getSampleSizeDirect(
36             uint32_t sampleIndex, size_t *size);
37 
38 private:
39     SampleTable *mTable;
40 
41     bool mInitialized;
42 
43     uint32_t mSampleToChunkIndex;
44     uint32_t mFirstChunk;
45     uint32_t mFirstChunkSampleIndex;
46     uint32_t mStopChunk;
47     uint32_t mStopChunkSampleIndex;
48     uint32_t mSamplesPerChunk;
49     uint32_t mChunkDesc;
50 
51     uint32_t mCurrentChunkIndex;
52     off64_t mCurrentChunkOffset;
53     Vector<size_t> mCurrentChunkSampleSizes;
54 
55     uint32_t mTimeToSampleIndex;
56     uint32_t mTTSSampleIndex;
57     uint32_t mTTSSampleTime;
58     uint32_t mTTSCount;
59     uint32_t mTTSDuration;
60 
61     uint32_t mCurrentSampleIndex;
62     off64_t mCurrentSampleOffset;
63     size_t mCurrentSampleSize;
64     uint32_t mCurrentSampleTime;
65     uint32_t mCurrentSampleDuration;
66 
67     void reset();
68     status_t findChunkRange(uint32_t sampleIndex);
69     status_t getChunkOffset(uint32_t chunk, off64_t *offset);
70     status_t findSampleTimeAndDuration(uint32_t sampleIndex, uint32_t *time, uint32_t *duration);
71 
72     SampleIterator(const SampleIterator &);
73     SampleIterator &operator=(const SampleIterator &);
74 };
75 
76 }  // namespace android
77 
78