Line data Source code
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 : #ifndef SAMPLE_ITERATOR_H_
18 : #define SAMPLE_ITERATOR_H_
19 :
20 : #include <utils/Vector.h>
21 :
22 : namespace stagefright {
23 :
24 : class SampleTable;
25 :
26 0 : struct SampleIterator {
27 : SampleIterator(SampleTable *table);
28 :
29 : status_t seekTo(uint32_t sampleIndex);
30 :
31 : uint32_t getChunkIndex() const { return mCurrentChunkIndex; }
32 : uint32_t getDescIndex() const { return mChunkDesc; }
33 0 : off64_t getSampleOffset() const { return mCurrentSampleOffset; }
34 0 : size_t getSampleSize() const { return mCurrentSampleSize; }
35 0 : uint32_t getSampleTime() const { return mCurrentSampleTime; }
36 0 : uint32_t getSampleDecodeTime() const { return mCurrentSampleDecodeTime; }
37 0 : uint32_t getSampleDuration() const { return mCurrentSampleDuration; }
38 :
39 : status_t getSampleSizeDirect(
40 : uint32_t sampleIndex, size_t *size);
41 :
42 : private:
43 : SampleTable *mTable;
44 :
45 : bool mInitialized;
46 :
47 : uint32_t mSampleToChunkIndex;
48 : uint32_t mFirstChunk;
49 : uint32_t mFirstChunkSampleIndex;
50 : uint32_t mStopChunk;
51 : uint32_t mStopChunkSampleIndex;
52 : uint32_t mSamplesPerChunk;
53 : uint32_t mChunkDesc;
54 :
55 : uint32_t mCurrentChunkIndex;
56 : off64_t mCurrentChunkOffset;
57 : Vector<size_t> mCurrentChunkSampleSizes;
58 :
59 : uint32_t mTimeToSampleIndex;
60 : uint32_t mTTSSampleIndex;
61 : uint32_t mTTSSampleTime;
62 : uint32_t mTTSCount;
63 : uint32_t mTTSDuration;
64 :
65 : uint32_t mCurrentSampleIndex;
66 : off64_t mCurrentSampleOffset;
67 : size_t mCurrentSampleSize;
68 : uint32_t mCurrentSampleTime;
69 : uint32_t mCurrentSampleDecodeTime;
70 : uint32_t mCurrentSampleDuration;
71 :
72 : void reset();
73 : status_t findChunkRange(uint32_t sampleIndex);
74 : status_t getChunkOffset(uint32_t chunk, off64_t *offset);
75 : status_t findSampleTime(uint32_t sampleIndex, uint32_t *time);
76 :
77 : SampleIterator(const SampleIterator &);
78 : SampleIterator &operator=(const SampleIterator &);
79 : };
80 :
81 : } // namespace stagefright
82 :
83 : #endif
|