MPEG4Extractor.h revision 7e04dcf8d6784dd56f53aa90bf34431ab4f0710c
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, uint32_t flags);
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        bool includes_expensive_metadata;
48    };
49
50    sp<DataSource> mDataSource;
51    bool mHaveMetadata;
52
53    Track *mFirstTrack, *mLastTrack;
54
55    uint32_t mHandlerType;
56
57    status_t readMetaData();
58    status_t parseChunk(off_t *offset, int depth);
59
60    MPEG4Extractor(const MPEG4Extractor &);
61    MPEG4Extractor &operator=(const MPEG4Extractor &);
62};
63
64bool SniffMPEG4(
65        const sp<DataSource> &source, String8 *mimeType, float *confidence);
66
67}  // namespace android
68
69#endif  // MPEG4_EXTRACTOR_H_
70