blob: baa779c24b0906f7c08ec328da0815e2fc96e165 [file] [log] [blame]
Andreas Huber88572f72012-02-21 11:47:18 -08001/*
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 Shetty08e77062018-08-07 19:46:17 +100021#include <media/stagefright/foundation/AudioPresentationInfo.h>
Dongwon Kang70d2ba32017-10-11 11:52:33 -070022#include <media/MediaSource.h>
23#include <media/DataSource.h>
Andreas Huber88572f72012-02-21 11:47:18 -080024#include <utils/Errors.h>
Andreas Huber07ea4262012-04-11 12:21:20 -070025#include <utils/KeyedVector.h>
Andreas Huber88572f72012-02-21 11:47:18 -080026#include <utils/RefBase.h>
Andreas Huber07ea4262012-04-11 12:21:20 -070027#include <utils/String8.h>
Andreas Huber88572f72012-02-21 11:47:18 -080028
29#include "jni.h"
30
31namespace android {
32
Andreas Huberd2506a52014-01-29 10:32:46 -080033struct IMediaHTTPService;
Bernhard Rosenkränzer99d61ed2014-11-17 21:15:30 +010034class MetaData;
Andreas Huber88572f72012-02-21 11:47:18 -080035struct NuMediaExtractor;
36
37struct JMediaExtractor : public RefBase {
38 JMediaExtractor(JNIEnv *env, jobject thiz);
39
Andreas Huber07ea4262012-04-11 12:21:20 -070040 status_t setDataSource(
Andreas Huberd2506a52014-01-29 10:32:46 -080041 const sp<IMediaHTTPService> &httpService,
Andreas Huber07ea4262012-04-11 12:21:20 -070042 const char *path,
43 const KeyedVector<String8, String8> *headers);
44
45 status_t setDataSource(int fd, off64_t offset, off64_t size);
Marco Nelissenc209a062012-08-24 09:55:44 -070046 status_t setDataSource(const sp<DataSource> &source);
Andreas Huber88572f72012-02-21 11:47:18 -080047
Chong Zhang2659c2f2017-04-27 13:18:20 -070048 status_t setMediaCas(JNIEnv *env, jobject casBinderObj);
Chong Zhangd5927ae2017-01-03 11:07:18 -080049
Andreas Huber88572f72012-02-21 11:47:18 -080050 size_t countTracks() const;
51 status_t getTrackFormat(size_t index, jobject *format) const;
52
Marco Nelissene20a6d52013-04-08 14:28:55 -070053 status_t getFileFormat(jobject *format) const;
54
Andreas Huber88572f72012-02-21 11:47:18 -080055 status_t selectTrack(size_t index);
Andreas Huberf2855b32012-04-25 15:57:43 -070056 status_t unselectTrack(size_t index);
Andreas Huber88572f72012-02-21 11:47:18 -080057
Andreas Huberf2855b32012-04-25 15:57:43 -070058 status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode);
Andreas Huber88572f72012-02-21 11:47:18 -080059
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 Shihd908f382018-01-23 15:31:37 -080064 status_t getSampleSize(size_t *sampleSize);
Andreas Huber9b8e4962012-03-26 11:13:27 -070065 status_t getSampleFlags(uint32_t *sampleFlags);
Andreas Huber91befdc2012-04-18 12:19:51 -070066 status_t getSampleMeta(sp<MetaData> *sampleMeta);
Ray Essickba5ce2c2017-02-07 09:50:47 -080067 status_t getMetrics(Parcel *reply) const;
Andreas Huber88572f72012-02-21 11:47:18 -080068
Andreas Huber74a78b02012-04-19 16:24:32 -070069 bool getCachedDuration(int64_t *durationUs, bool *eos) const;
Sampath Shetty08e77062018-08-07 19:46:17 +100070 status_t getAudioPresentations(size_t trackIdx,
71 AudioPresentationCollection *presentations) const;
Andreas Huber74a78b02012-04-19 16:24:32 -070072
Andreas Huber88572f72012-02-21 11:47:18 -080073protected:
74 virtual ~JMediaExtractor();
75
76private:
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_