MPEG2TSExtractor.h revision b2487f03f12dcafdb801fc0007c8df8412397f44
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 <media/stagefright/MediaSource.h> 24#include <utils/threads.h> 25#include <utils/KeyedVector.h> 26#include <utils/Vector.h> 27 28namespace android { 29 30struct AMessage; 31struct AnotherPacketSource; 32struct ATSParser; 33class DataSource; 34struct MPEG2TSSource; 35class String8; 36 37struct MPEG2TSExtractor : public MediaExtractor { 38 MPEG2TSExtractor(const sp<DataSource> &source); 39 40 virtual size_t countTracks(); 41 virtual sp<IMediaSource> getTrack(size_t index); 42 virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags); 43 44 virtual sp<MetaData> getMetaData(); 45 46 virtual uint32_t flags() const; 47 48private: 49 friend struct MPEG2TSSource; 50 51 mutable Mutex mLock; 52 53 sp<DataSource> mDataSource; 54 55 sp<ATSParser> mParser; 56 57 Vector<sp<AnotherPacketSource> > mSourceImpls; 58 59 Vector<KeyedVector<int64_t, off64_t> > mSyncPoints; 60 // Sync points used for seeking --- normally one for video track is used. 61 // If no video track is present, audio track will be used instead. 62 KeyedVector<int64_t, off64_t> *mSeekSyncPoints; 63 64 off64_t mOffset; 65 66 void init(); 67 status_t feedMore(); 68 status_t seek(int64_t seekTimeUs, 69 const MediaSource::ReadOptions::SeekMode& seekMode); 70 status_t queueDiscontinuityForSeek(int64_t actualSeekTimeUs); 71 status_t seekBeyond(int64_t seekTimeUs); 72 73 status_t feedUntilBufferAvailable(const sp<AnotherPacketSource> &impl); 74 75 DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSExtractor); 76}; 77 78bool SniffMPEG2TS( 79 const sp<DataSource> &source, String8 *mimeType, float *confidence, 80 sp<AMessage> *); 81 82} // namespace android 83 84#endif // MPEG2_TS_EXTRACTOR_H_ 85