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> |
Sampath Shetty | 08e7706 | 2018-08-07 19:46:17 +1000 | [diff] [blame] | 21 | #include <media/stagefright/foundation/AudioPresentationInfo.h> |
Marco Nelissen | c17cbfb | 2019-12-17 14:16:47 -0800 | [diff] [blame] | 22 | #include <media/stagefright/MediaSource.h> |
Dongwon Kang | 70d2ba3 | 2017-10-11 11:52:33 -0700 | [diff] [blame] | 23 | #include <media/DataSource.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 24 | #include <utils/Errors.h> |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 25 | #include <utils/KeyedVector.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 26 | #include <utils/RefBase.h> |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 27 | #include <utils/String8.h> |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 28 | |
| 29 | #include "jni.h" |
| 30 | |
| 31 | namespace android { |
| 32 | |
Andreas Huber | d2506a5 | 2014-01-29 10:32:46 -0800 | [diff] [blame] | 33 | struct IMediaHTTPService; |
Bernhard Rosenkränzer | 99d61ed | 2014-11-17 21:15:30 +0100 | [diff] [blame] | 34 | class MetaData; |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 35 | struct NuMediaExtractor; |
| 36 | |
| 37 | struct JMediaExtractor : public RefBase { |
| 38 | JMediaExtractor(JNIEnv *env, jobject thiz); |
| 39 | |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 40 | status_t setDataSource( |
Andreas Huber | d2506a5 | 2014-01-29 10:32:46 -0800 | [diff] [blame] | 41 | const sp<IMediaHTTPService> &httpService, |
Andreas Huber | 07ea426 | 2012-04-11 12:21:20 -0700 | [diff] [blame] | 42 | const char *path, |
| 43 | const KeyedVector<String8, String8> *headers); |
| 44 | |
| 45 | status_t setDataSource(int fd, off64_t offset, off64_t size); |
Marco Nelissen | c209a06 | 2012-08-24 09:55:44 -0700 | [diff] [blame] | 46 | status_t setDataSource(const sp<DataSource> &source); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 47 | |
Chong Zhang | 2659c2f | 2017-04-27 13:18:20 -0700 | [diff] [blame] | 48 | status_t setMediaCas(JNIEnv *env, jobject casBinderObj); |
Chong Zhang | d5927ae | 2017-01-03 11:07:18 -0800 | [diff] [blame] | 49 | |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 50 | size_t countTracks() const; |
| 51 | status_t getTrackFormat(size_t index, jobject *format) const; |
| 52 | |
Marco Nelissen | e20a6d5 | 2013-04-08 14:28:55 -0700 | [diff] [blame] | 53 | status_t getFileFormat(jobject *format) const; |
| 54 | |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 55 | status_t selectTrack(size_t index); |
Andreas Huber | f2855b3 | 2012-04-25 15:57:43 -0700 | [diff] [blame] | 56 | status_t unselectTrack(size_t index); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 57 | |
Andreas Huber | f2855b3 | 2012-04-25 15:57:43 -0700 | [diff] [blame] | 58 | status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode); |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 59 | |
| 60 | status_t advance(); |
| 61 | status_t readSampleData(jobject byteBuf, size_t offset, size_t *sampleSize); |
| 62 | status_t getSampleTrackIndex(size_t *trackIndex); |
| 63 | status_t getSampleTime(int64_t *sampleTimeUs); |
Robert Shih | d908f38 | 2018-01-23 15:31:37 -0800 | [diff] [blame] | 64 | status_t getSampleSize(size_t *sampleSize); |
Andreas Huber | 9b8e496 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 65 | status_t getSampleFlags(uint32_t *sampleFlags); |
Andreas Huber | 91befdc | 2012-04-18 12:19:51 -0700 | [diff] [blame] | 66 | status_t getSampleMeta(sp<MetaData> *sampleMeta); |
Ray Essick | ba5ce2c | 2017-02-07 09:50:47 -0800 | [diff] [blame] | 67 | status_t getMetrics(Parcel *reply) const; |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 68 | |
Andreas Huber | 74a78b0 | 2012-04-19 16:24:32 -0700 | [diff] [blame] | 69 | bool getCachedDuration(int64_t *durationUs, bool *eos) const; |
Sampath Shetty | 08e7706 | 2018-08-07 19:46:17 +1000 | [diff] [blame] | 70 | status_t getAudioPresentations(size_t trackIdx, |
| 71 | AudioPresentationCollection *presentations) const; |
Andreas Huber | 74a78b0 | 2012-04-19 16:24:32 -0700 | [diff] [blame] | 72 | |
Andreas Huber | 88572f7 | 2012-02-21 11:47:18 -0800 | [diff] [blame] | 73 | protected: |
| 74 | virtual ~JMediaExtractor(); |
| 75 | |
| 76 | private: |
| 77 | jclass mClass; |
| 78 | jweak mObject; |
| 79 | sp<NuMediaExtractor> mImpl; |
| 80 | |
| 81 | DISALLOW_EVIL_CONSTRUCTORS(JMediaExtractor); |
| 82 | }; |
| 83 | |
| 84 | } // namespace android |
| 85 | |
| 86 | #endif // _ANDROID_MEDIA_MEDIAEXTRACTOR_H_ |