blob: e5a0c16e3897af3024b2562ca18808780aa8c572 [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>
Andreas Huberf2855b32012-04-25 15:57:43 -070021#include <media/stagefright/MediaSource.h>
Marco Nelissenc209a062012-08-24 09:55:44 -070022#include <media/stagefright/DataSource.h>
Andreas Huber88572f72012-02-21 11:47:18 -080023#include <utils/Errors.h>
Andreas Huber07ea4262012-04-11 12:21:20 -070024#include <utils/KeyedVector.h>
Andreas Huber88572f72012-02-21 11:47:18 -080025#include <utils/RefBase.h>
Andreas Huber07ea4262012-04-11 12:21:20 -070026#include <utils/String8.h>
Andreas Huber88572f72012-02-21 11:47:18 -080027
28#include "jni.h"
29
30namespace android {
31
Andreas Huberd2506a52014-01-29 10:32:46 -080032struct IMediaHTTPService;
Andreas Huber91befdc2012-04-18 12:19:51 -070033struct MetaData;
Andreas Huber88572f72012-02-21 11:47:18 -080034struct NuMediaExtractor;
35
36struct JMediaExtractor : public RefBase {
37 JMediaExtractor(JNIEnv *env, jobject thiz);
38
Andreas Huber07ea4262012-04-11 12:21:20 -070039 status_t setDataSource(
Andreas Huberd2506a52014-01-29 10:32:46 -080040 const sp<IMediaHTTPService> &httpService,
Andreas Huber07ea4262012-04-11 12:21:20 -070041 const char *path,
42 const KeyedVector<String8, String8> *headers);
43
44 status_t setDataSource(int fd, off64_t offset, off64_t size);
Marco Nelissenc209a062012-08-24 09:55:44 -070045 status_t setDataSource(const sp<DataSource> &source);
Andreas Huber88572f72012-02-21 11:47:18 -080046
47 size_t countTracks() const;
48 status_t getTrackFormat(size_t index, jobject *format) const;
49
Marco Nelissene20a6d52013-04-08 14:28:55 -070050 status_t getFileFormat(jobject *format) const;
51
Andreas Huber88572f72012-02-21 11:47:18 -080052 status_t selectTrack(size_t index);
Andreas Huberf2855b32012-04-25 15:57:43 -070053 status_t unselectTrack(size_t index);
Andreas Huber88572f72012-02-21 11:47:18 -080054
Andreas Huberf2855b32012-04-25 15:57:43 -070055 status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode);
Andreas Huber88572f72012-02-21 11:47:18 -080056
57 status_t advance();
58 status_t readSampleData(jobject byteBuf, size_t offset, size_t *sampleSize);
59 status_t getSampleTrackIndex(size_t *trackIndex);
60 status_t getSampleTime(int64_t *sampleTimeUs);
Andreas Huber9b8e4962012-03-26 11:13:27 -070061 status_t getSampleFlags(uint32_t *sampleFlags);
Andreas Huber91befdc2012-04-18 12:19:51 -070062 status_t getSampleMeta(sp<MetaData> *sampleMeta);
Andreas Huber88572f72012-02-21 11:47:18 -080063
Andreas Huber74a78b02012-04-19 16:24:32 -070064 bool getCachedDuration(int64_t *durationUs, bool *eos) const;
65
Andreas Huber88572f72012-02-21 11:47:18 -080066protected:
67 virtual ~JMediaExtractor();
68
69private:
70 jclass mClass;
71 jweak mObject;
72 sp<NuMediaExtractor> mImpl;
73
74 DISALLOW_EVIL_CONSTRUCTORS(JMediaExtractor);
75};
76
77} // namespace android
78
79#endif // _ANDROID_MEDIA_MEDIAEXTRACTOR_H_