MPEG2TSExtractor.h revision 86a58cabe322b746ab0eb17f0cade34ed68ba60e
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 MPEG2_TS_EXTRACTOR_H_
18
19#define MPEG2_TS_EXTRACTOR_H_
20
21#include <media/stagefright/foundation/ABase.h>
22#include <media/stagefright/MediaExtractor.h>
23#include <utils/threads.h>
24#include <utils/Vector.h>
25
26namespace android {
27
28struct AMessage;
29struct AnotherPacketSource;
30struct ATSParser;
31class DataSource;
32struct MPEG2TSSource;
33struct String8;
34
35struct MPEG2TSExtractor : public MediaExtractor {
36    MPEG2TSExtractor(const sp<DataSource> &source);
37
38    virtual size_t countTracks();
39    virtual sp<MediaSource> getTrack(size_t index);
40    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
41
42    virtual sp<MetaData> getMetaData();
43
44    virtual uint32_t flags() const;
45
46private:
47    friend struct MPEG2TSSource;
48
49    mutable Mutex mLock;
50
51    sp<DataSource> mDataSource;
52
53    sp<ATSParser> mParser;
54
55    Vector<sp<AnotherPacketSource> > mSourceImpls;
56
57    off64_t mOffset;
58
59    void init();
60    status_t feedMore();
61
62    DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSExtractor);
63};
64
65bool SniffMPEG2TS(
66        const sp<DataSource> &source, String8 *mimeType, float *confidence,
67        sp<AMessage> *);
68
69}  // namespace android
70
71#endif  // MPEG2_TS_EXTRACTOR_H_
72