1 /* 2 * Copyright (C) 2011 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_PS_EXTRACTOR_H_ 18 19 #define MPEG2_PS_EXTRACTOR_H_ 20 21 #include <mutex> 22 23 #include <media/stagefright/foundation/ABase.h> 24 #include <media/MediaExtractorPluginApi.h> 25 #include <media/MediaExtractorPluginHelper.h> 26 #include <media/stagefright/MetaDataBase.h> 27 #include <utils/KeyedVector.h> 28 29 namespace android { 30 31 struct ABuffer; 32 struct AMessage; 33 struct Track; 34 class String8; 35 36 struct MPEG2PSExtractor : public MediaExtractorPluginHelper { 37 explicit MPEG2PSExtractor(DataSourceHelper *source); 38 39 virtual size_t countTracks(); 40 virtual MediaTrackHelper *getTrack(size_t index); 41 virtual media_status_t getTrackMetaData(AMediaFormat *meta, size_t index, uint32_t flags); 42 43 virtual media_status_t getMetaData(AMediaFormat *meta); 44 45 virtual uint32_t flags() const; nameMPEG2PSExtractor46 virtual const char * name() { return "MPEG2PSExtractor"; } 47 48 protected: 49 virtual ~MPEG2PSExtractor(); 50 51 private: 52 struct Track; 53 struct WrappedTrack; 54 55 std::mutex mLock; 56 DataSourceHelper *mDataSource; 57 58 off64_t mOffset; 59 status_t mFinalResult; 60 sp<ABuffer> mBuffer; 61 KeyedVector<unsigned, Track* > mTracks; 62 bool mScanning; 63 64 bool mProgramStreamMapValid; 65 KeyedVector<unsigned, unsigned> mStreamTypeByESID; 66 67 status_t feedMore(); 68 69 status_t dequeueChunk(); 70 ssize_t dequeuePack(); 71 ssize_t dequeueSystemHeader(); 72 ssize_t dequeuePES(); 73 74 DISALLOW_EVIL_CONSTRUCTORS(MPEG2PSExtractor); 75 }; 76 77 bool SniffMPEG2PS(DataSourceHelper *source, float *confidence); 78 79 } // namespace android 80 81 #endif // MPEG2_PS_EXTRACTOR_H_ 82 83