2 * Copyright 2012, The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _ANDROID_MEDIA_MEDIAEXTRACTOR_H_
18 #define _ANDROID_MEDIA_MEDIAEXTRACTOR_H_
20 #include <media/stagefright/foundation/ABase.h>
21 #include <media/stagefright/MediaSource.h>
22 #include <media/stagefright/DataSource.h>
23 #include <utils/Errors.h>
24 #include <utils/KeyedVector.h>
25 #include <utils/RefBase.h>
26 #include <utils/String8.h>
32 struct IMediaHTTPService;
34 struct NuMediaExtractor;
36 struct JMediaExtractor : public RefBase {
37 JMediaExtractor(JNIEnv *env, jobject thiz);
39 status_t setDataSource(
40 const sp<IMediaHTTPService> &httpService,
42 const KeyedVector<String8, String8> *headers);
44 status_t setDataSource(int fd, off64_t offset, off64_t size);
45 status_t setDataSource(const sp<DataSource> &source);
47 size_t countTracks() const;
48 status_t getTrackFormat(size_t index, jobject *format) const;
50 status_t getFileFormat(jobject *format) const;
52 status_t selectTrack(size_t index);
53 status_t unselectTrack(size_t index);
55 status_t seekTo(int64_t timeUs, MediaSource::ReadOptions::SeekMode mode);
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);
61 status_t getSampleFlags(uint32_t *sampleFlags);
62 status_t getSampleMeta(sp<MetaData> *sampleMeta);
64 bool getCachedDuration(int64_t *durationUs, bool *eos) const;
67 virtual ~JMediaExtractor();
72 sp<NuMediaExtractor> mImpl;
74 DISALLOW_EVIL_CONSTRUCTORS(JMediaExtractor);
77 } // namespace android
79 #endif // _ANDROID_MEDIA_MEDIAEXTRACTOR_H_