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 "mkvparser/mkvparser.h" 22 23#include <media/stagefright/MediaExtractor.h> 24#include <utils/Vector.h> 25#include <utils/threads.h> 26 27namespace android { 28 29struct AMessage; 30class String8; 31 32class MetaData; 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<IMediaSource> getTrack(size_t index); 42 43 virtual sp<MetaData> getTrackMetaData( 44 size_t index, uint32_t flags); 45 46 virtual sp<MetaData> getMetaData(); 47 48 virtual uint32_t flags() const; 49 50 virtual const char * name() { return "MatroskaExtractor"; } 51 52protected: 53 virtual ~MatroskaExtractor(); 54 55private: 56 friend struct MatroskaSource; 57 friend struct BlockIterator; 58 59 struct TrackInfo { 60 unsigned long mTrackNum; 61 bool mEncrypted; 62 sp<MetaData> mMeta; 63 const MatroskaExtractor *mExtractor; 64 Vector<const mkvparser::CuePoint*> mCuePoints; 65 66 const mkvparser::Track* getTrack() const; 67 const mkvparser::CuePoint::TrackPosition *find(long long timeNs) const; 68 }; 69 70 Mutex mLock; 71 Vector<TrackInfo> mTracks; 72 73 sp<DataSource> mDataSource; 74 DataSourceReader *mReader; 75 mkvparser::Segment *mSegment; 76 bool mExtractedThumbnails; 77 bool mIsLiveStreaming; 78 bool mIsWebm; 79 int64_t mSeekPreRollNs; 80 81 status_t synthesizeAVCC(TrackInfo *trackInfo, size_t index); 82 void addTracks(); 83 void findThumbnails(); 84 void getColorInformation(const mkvparser::VideoTrack *vtrack, sp<MetaData> &meta); 85 bool isLiveStreaming() const; 86 87 MatroskaExtractor(const MatroskaExtractor &); 88 MatroskaExtractor &operator=(const MatroskaExtractor &); 89}; 90 91bool SniffMatroska( 92 const sp<DataSource> &source, String8 *mimeType, float *confidence, 93 sp<AMessage> *); 94 95} // namespace android 96 97#endif // MATROSKA_EXTRACTOR_H_ 98