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 _ANDROID_MEDIA_MEDIAEXTRACTOR_H_ |
| 18 | #define _ANDROID_MEDIA_MEDIAEXTRACTOR_H_ |
| 19 | |
| 20 | #include <media/stagefright/foundation/ABase.h> |
Andreas Huber | f2855b3 | 2012-04-25 15:57:43 -0700 | [diff] [blame] | 21 | #include <media/stagefright/MediaSource.h> |
Marco Nelissen | c209a06 | 2012-08-24 09:55:44 -0700 | [diff] [blame] | 22 | #include <media/stagefright/DataSource.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 23 | #include <utils/Errors.h> |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 24 | #include <utils/KeyedVector.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 25 | #include <utils/RefBase.h> |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 26 | #include <utils/String8.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 27 | |
| 28 | #include "jni.h" |
| 29 | |
| 30 | namespace android { |
| 31 | |
Andreas Huber | 91befdc | 2012-04-18 12:19:51 -0700 | [diff] [blame] | 32 | struct MetaData; |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 33 | struct NuMediaExtractor; |
| 34 | |
| 35 | struct JMediaExtractor : public RefBase { |
| 36 | JMediaExtractor(JNIEnv *env, jobject thiz); |
| 37 | |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 38 | status_t setDataSource( |
| 39 | const char *path, |
| 40 | const KeyedVector<String8, String8> *headers); |
| 41 | |
| 42 | status_t setDataSource(int fd, off64_t offset, off64_t size); |
Marco Nelissen | c209a06 | 2012-08-24 09:55:44 -0700 | [diff] [blame] | 43 | status_t setDataSource(const sp<DataSource> &source); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 44 | |
| 45 | size_t countTracks() const; |
| 46 | status_t getTrackFormat(size_t index, jobject *format) const; |
| 47 | |
Marco Nelissen | e20a6d5 | 2013-04-08 14:28:55 -0700 | [diff] [blame] | 48 | status_t getFileFormat(jobject *format) const; |
| 49 | |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 50 | status_t selectTrack(size_t index); |
Andreas Huber | f2855b3 | 2012-04-25 15:57:43 -0700 | [diff] [blame] | 51 | status_t unselectTrack(size_t index); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 52 | |
Andreas Huber | f2855b3 | 2012-04-25 15:57:43 -0700 | [diff] [blame] | 53 | status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 54 | |
| 55 | status_t advance(); |
| 56 | status_t readSampleData(jobject byteBuf, size_t offset, size_t *sampleSize); |
| 57 | status_t getSampleTrackIndex(size_t *trackIndex); |
| 58 | status_t getSampleTime(int64_t *sampleTimeUs); |
Andreas Huber | 9b8e496 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 59 | status_t getSampleFlags(uint32_t *sampleFlags); |
Andreas Huber | 91befdc | 2012-04-18 12:19:51 -0700 | [diff] [blame] | 60 | status_t getSampleMeta(sp<MetaData> *sampleMeta); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 61 | |
Andreas Huber | 74a78b0 | 2012-04-19 16:24:32 -0700 | [diff] [blame] | 62 | bool getCachedDuration(int64_t *durationUs, bool *eos) const; |
| 63 | |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 64 | protected: |
| 65 | virtual ~JMediaExtractor(); |
| 66 | |
| 67 | private: |
| 68 | jclass mClass; |
| 69 | jweak mObject; |
| 70 | sp<NuMediaExtractor> mImpl; |
| 71 | |
| 72 | DISALLOW_EVIL_CONSTRUCTORS(JMediaExtractor); |
| 73 | }; |
| 74 | |
| 75 | } // namespace android |
| 76 | |
| 77 | #endif // _ANDROID_MEDIA_MEDIAEXTRACTOR_H_ |