blob: db36bf898f1477f35c350e40b884d8f94fa9f1f6 [file] [log] [blame]
Andreas Huber093437c2010-05-20 14:56:53 -07001/*
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
Robert Shih2f46e812014-06-12 12:08:56 -070021#include "mkvparser.hpp"
22
Andreas Huber093437c2010-05-20 14:56:53 -070023#include <media/stagefright/MediaExtractor.h>
24#include <utils/Vector.h>
Andreas Huberd42573c2011-03-18 14:38:56 -070025#include <utils/threads.h>
Andreas Huber093437c2010-05-20 14:56:53 -070026
Andreas Huber093437c2010-05-20 14:56:53 -070027namespace android {
28
Andreas Huber5a1c3522010-08-25 11:09:41 -070029struct AMessage;
Andreas Huber093437c2010-05-20 14:56:53 -070030class String8;
31
32struct DataSourceReader;
33struct MatroskaSource;
34
35struct MatroskaExtractor : public MediaExtractor {
36 MatroskaExtractor(const sp<DataSource> &source);
37
38 virtual size_t countTracks();
39
40 virtual sp<MediaSource> getTrack(size_t index);
41
42 virtual sp<MetaData> getTrackMetaData(
43 size_t index, uint32_t flags);
44
45 virtual sp<MetaData> getMetaData();
46
Andreas Huberd42573c2011-03-18 14:38:56 -070047 virtual uint32_t flags() const;
48
Andreas Huber093437c2010-05-20 14:56:53 -070049protected:
50 virtual ~MatroskaExtractor();
51
52private:
53 friend struct MatroskaSource;
Andreas Huberd42573c2011-03-18 14:38:56 -070054 friend struct BlockIterator;
Andreas Huber093437c2010-05-20 14:56:53 -070055
56 struct TrackInfo {
57 unsigned long mTrackNum;
58 sp<MetaData> mMeta;
Robert Shih2f46e812014-06-12 12:08:56 -070059 const MatroskaExtractor *mExtractor;
60 Vector<const mkvparser::CuePoint*> mCuePoints;
61
62 const mkvparser::Track* getTrack() const;
63 const mkvparser::CuePoint::TrackPosition *find(long long timeNs) const;
Andreas Huber093437c2010-05-20 14:56:53 -070064 };
Andreas Huberd42573c2011-03-18 14:38:56 -070065
66 Mutex mLock;
Andreas Huber093437c2010-05-20 14:56:53 -070067 Vector<TrackInfo> mTracks;
68
69 sp<DataSource> mDataSource;
70 DataSourceReader *mReader;
71 mkvparser::Segment *mSegment;
Andreas Huber5279d1d2010-05-25 13:35:02 -070072 bool mExtractedThumbnails;
Andreas Huberd42573c2011-03-18 14:38:56 -070073 bool mIsLiveStreaming;
Andreas Huber8c32b162011-08-22 13:21:26 -070074 bool mIsWebm;
Vignesh Venkatasubramanianbf927f82014-01-29 09:00:46 -080075 int64_t mSeekPreRollNs;
Andreas Huber093437c2010-05-20 14:56:53 -070076
77 void addTracks();
Andreas Huber5279d1d2010-05-25 13:35:02 -070078 void findThumbnails();
Andreas Huber093437c2010-05-20 14:56:53 -070079
Andreas Huberd42573c2011-03-18 14:38:56 -070080 bool isLiveStreaming() const;
81
Andreas Huber093437c2010-05-20 14:56:53 -070082 MatroskaExtractor(const MatroskaExtractor &);
83 MatroskaExtractor &operator=(const MatroskaExtractor &);
84};
85
86bool SniffMatroska(
Andreas Huber5a1c3522010-08-25 11:09:41 -070087 const sp<DataSource> &source, String8 *mimeType, float *confidence,
88 sp<AMessage> *);
Andreas Huber093437c2010-05-20 14:56:53 -070089
90} // namespace android
91
92#endif // MATROSKA_EXTRACTOR_H_