MPEG4Extractor.h revision 693d271e62a3726689ff68f4505ba49228eb94b2
1/*
2 * Copyright (C) 2009 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 MPEG4_EXTRACTOR_H_
18
19#define MPEG4_EXTRACTOR_H_
20
21#include <media/stagefright/MediaExtractor.h>
22
23namespace android {
24
25class DataSource;
26class SampleTable;
27class String8;
28
29class MPEG4Extractor : public MediaExtractor {
30public:
31    // Extractor assumes ownership of "source".
32    MPEG4Extractor(const sp<DataSource> &source);
33
34    size_t countTracks();
35    sp<MediaSource> getTrack(size_t index);
36    sp<MetaData> getTrackMetaData(size_t index);
37
38protected:
39    virtual ~MPEG4Extractor();
40
41private:
42    struct Track {
43        Track *next;
44        sp<MetaData> meta;
45        uint32_t timescale;
46        sp<SampleTable> sampleTable;
47    };
48
49    sp<DataSource> mDataSource;
50    bool mHaveMetadata;
51
52    Track *mFirstTrack, *mLastTrack;
53
54    uint32_t mHandlerType;
55
56    status_t readMetaData();
57    status_t parseChunk(off_t *offset, int depth);
58
59    MPEG4Extractor(const MPEG4Extractor &);
60    MPEG4Extractor &operator=(const MPEG4Extractor &);
61};
62
63bool SniffMPEG4(
64        const sp<DataSource> &source, String8 *mimeType, float *confidence);
65
66}  // namespace android
67
68#endif  // MPEG4_EXTRACTOR_H_
69