Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 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 | |
| 25 | namespace android { |
| 26 | |
| 27 | struct ABuffer; |
| 28 | struct AMessage; |
| 29 | struct MediaBuffer; |
| 30 | struct MediaExtractor; |
| 31 | struct MediaSource; |
| 32 | |
| 33 | struct NuMediaExtractor : public RefBase { |
| 34 | NuMediaExtractor(); |
| 35 | |
| 36 | status_t setDataSource(const char *path); |
| 37 | |
| 38 | size_t countTracks() const; |
| 39 | status_t getTrackFormat(size_t index, sp<AMessage> *format) const; |
| 40 | |
| 41 | status_t selectTrack(size_t index); |
| 42 | |
| 43 | status_t seekTo(int64_t timeUs); |
| 44 | |
| 45 | status_t advance(); |
| 46 | status_t readSampleData(const sp<ABuffer> &buffer); |
| 47 | status_t getSampleTrackIndex(size_t *trackIndex); |
| 48 | status_t getSampleTime(int64_t *sampleTimeUs); |
| 49 | |
| 50 | protected: |
| 51 | virtual ~NuMediaExtractor(); |
| 52 | |
| 53 | private: |
| 54 | enum TrackFlags { |
| 55 | kIsVorbis = 1, |
| 56 | }; |
| 57 | |
| 58 | struct TrackInfo { |
| 59 | sp<MediaSource> mSource; |
| 60 | size_t mTrackIndex; |
| 61 | status_t mFinalResult; |
| 62 | MediaBuffer *mSample; |
| 63 | int64_t mSampleTimeUs; |
| 64 | uint32_t mFlags; // bitmask of "TrackFlags" |
| 65 | }; |
| 66 | |
| 67 | sp<MediaExtractor> mImpl; |
| 68 | |
| 69 | Vector<TrackInfo> mSelectedTracks; |
| 70 | |
| 71 | ssize_t fetchTrackSamples(int64_t seekTimeUs = -1ll); |
| 72 | void releaseTrackSamples(); |
| 73 | |
| 74 | DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor); |
| 75 | }; |
| 76 | |
| 77 | } // namespace android |
| 78 | |
| 79 | #endif // NU_MEDIA_EXTRACTOR_H_ |
| 80 | |