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