Home | History | Annotate | Download | only in include
      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 <media/stagefright/foundation/ABase.h>
     22 #include <media/stagefright/MediaExtractor.h>
     23 #include <utils/threads.h>
     24 #include <utils/KeyedVector.h>
     25 
     26 namespace android {
     27 
     28 struct ABuffer;
     29 struct AMessage;
     30 struct Track;
     31 struct String8;
     32 
     33 struct MPEG2PSExtractor : public MediaExtractor {
     34     MPEG2PSExtractor(const sp<DataSource> &source);
     35 
     36     virtual size_t countTracks();
     37     virtual sp<MediaSource> getTrack(size_t index);
     38     virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
     39 
     40     virtual sp<MetaData> getMetaData();
     41 
     42     virtual uint32_t flags() const;
     43 
     44 protected:
     45     virtual ~MPEG2PSExtractor();
     46 
     47 private:
     48     struct Track;
     49     struct WrappedTrack;
     50 
     51     mutable Mutex mLock;
     52     sp<DataSource> mDataSource;
     53 
     54     off64_t mOffset;
     55     status_t mFinalResult;
     56     sp<ABuffer> mBuffer;
     57     KeyedVector<unsigned, sp<Track> > mTracks;
     58     bool mScanning;
     59 
     60     bool mProgramStreamMapValid;
     61     KeyedVector<unsigned, unsigned> mStreamTypeByESID;
     62 
     63     status_t feedMore();
     64 
     65     status_t dequeueChunk();
     66     ssize_t dequeuePack();
     67     ssize_t dequeueSystemHeader();
     68     ssize_t dequeuePES();
     69 
     70     DISALLOW_EVIL_CONSTRUCTORS(MPEG2PSExtractor);
     71 };
     72 
     73 bool SniffMPEG2PS(
     74         const sp<DataSource> &source, String8 *mimeType, float *confidence,
     75         sp<AMessage> *);
     76 
     77 }  // namespace android
     78 
     79 #endif  // MPEG2_PS_EXTRACTOR_H_
     80 
     81