android_media_MediaExtractor.h revision f2855b3df5994e165b29025c4c49d8e7d634c034
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>
21#include <media/stagefright/MediaSource.h>
22#include <utils/Errors.h>
23#include <utils/KeyedVector.h>
24#include <utils/RefBase.h>
25#include <utils/String8.h>
26
27#include "jni.h"
28
29namespace android {
30
31struct MetaData;
32struct NuMediaExtractor;
33
34struct JMediaExtractor : public RefBase {
35    JMediaExtractor(JNIEnv *env, jobject thiz);
36
37    status_t setDataSource(
38            const char *path,
39            const KeyedVector<String8, String8> *headers);
40
41    status_t setDataSource(int fd, off64_t offset, off64_t size);
42
43    size_t countTracks() const;
44    status_t getTrackFormat(size_t index, jobject *format) const;
45
46    status_t selectTrack(size_t index);
47    status_t unselectTrack(size_t index);
48
49    status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode);
50
51    status_t advance();
52    status_t readSampleData(jobject byteBuf, size_t offset, size_t *sampleSize);
53    status_t getSampleTrackIndex(size_t *trackIndex);
54    status_t getSampleTime(int64_t *sampleTimeUs);
55    status_t getSampleFlags(uint32_t *sampleFlags);
56    status_t getSampleMeta(sp<MetaData> *sampleMeta);
57
58    bool getCachedDuration(int64_t *durationUs, bool *eos) const;
59
60protected:
61    virtual ~JMediaExtractor();
62
63private:
64    jclass mClass;
65    jweak mObject;
66    sp<NuMediaExtractor> mImpl;
67
68    DISALLOW_EVIL_CONSTRUCTORS(JMediaExtractor);
69};
70
71}  // namespace android
72
73#endif  // _ANDROID_MEDIA_MEDIAEXTRACTOR_H_
74