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 MATROSKA_EXTRACTOR_H_
18
19#define MATROSKA_EXTRACTOR_H_
20
21#include <media/stagefright/MediaExtractor.h>
22#include <utils/Vector.h>
23
24namespace mkvparser {
25struct Segment;
26};
27
28namespace android {
29
30struct AMessage;
31class String8;
32
33struct DataSourceReader;
34struct MatroskaSource;
35
36struct MatroskaExtractor : public MediaExtractor {
37    MatroskaExtractor(const sp<DataSource> &source);
38
39    virtual size_t countTracks();
40
41    virtual sp<MediaSource> getTrack(size_t index);
42
43    virtual sp<MetaData> getTrackMetaData(
44            size_t index, uint32_t flags);
45
46    virtual sp<MetaData> getMetaData();
47
48protected:
49    virtual ~MatroskaExtractor();
50
51private:
52    friend struct MatroskaSource;
53
54    struct TrackInfo {
55        unsigned long mTrackNum;
56        sp<MetaData> mMeta;
57    };
58    Vector<TrackInfo> mTracks;
59
60    sp<DataSource> mDataSource;
61    DataSourceReader *mReader;
62    mkvparser::Segment *mSegment;
63    bool mExtractedThumbnails;
64
65    void addTracks();
66    void findThumbnails();
67
68    MatroskaExtractor(const MatroskaExtractor &);
69    MatroskaExtractor &operator=(const MatroskaExtractor &);
70};
71
72bool SniffMatroska(
73        const sp<DataSource> &source, String8 *mimeType, float *confidence,
74        sp<AMessage> *);
75
76}  // namespace android
77
78#endif  // MATROSKA_EXTRACTOR_H_
79