NuMediaExtractor.h revision ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6
1/* 2 * Copyright 2012, 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 NU_MEDIA_EXTRACTOR_H_ 18#define NU_MEDIA_EXTRACTOR_H_ 19 20#include <media/stagefright/foundation/ABase.h> 21#include <utils/Errors.h> 22#include <utils/RefBase.h> 23#include <utils/Vector.h> 24 25namespace android { 26 27struct ABuffer; 28struct AMessage; 29struct MediaBuffer; 30struct MediaExtractor; 31struct MediaSource; 32 33struct NuMediaExtractor : public RefBase { 34 enum SampleFlags { 35 SAMPLE_FLAG_SYNC = 1, 36 SAMPLE_FLAG_ENCRYPTED = 2, 37 }; 38 39 NuMediaExtractor(); 40 41 status_t setDataSource(const char *path); 42 43 size_t countTracks() const; 44 status_t getTrackFormat(size_t index, sp<AMessage> *format) const; 45 46 status_t selectTrack(size_t index); 47 48 status_t seekTo(int64_t timeUs); 49 50 status_t advance(); 51 status_t readSampleData(const sp<ABuffer> &buffer); 52 status_t getSampleTrackIndex(size_t *trackIndex); 53 status_t getSampleTime(int64_t *sampleTimeUs); 54 status_t getSampleFlags(uint32_t *sampleFlags); 55 56protected: 57 virtual ~NuMediaExtractor(); 58 59private: 60 enum TrackFlags { 61 kIsVorbis = 1, 62 }; 63 64 struct TrackInfo { 65 sp<MediaSource> mSource; 66 size_t mTrackIndex; 67 status_t mFinalResult; 68 MediaBuffer *mSample; 69 int64_t mSampleTimeUs; 70 uint32_t mSampleFlags; 71 72 uint32_t mTrackFlags; // bitmask of "TrackFlags" 73 }; 74 75 sp<MediaExtractor> mImpl; 76 77 Vector<TrackInfo> mSelectedTracks; 78 79 ssize_t fetchTrackSamples(int64_t seekTimeUs = -1ll); 80 void releaseTrackSamples(); 81 82 DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor); 83}; 84 85} // namespace android 86 87#endif // NU_MEDIA_EXTRACTOR_H_ 88 89