1b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen/*
2b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * Copyright (C) 2009 The Android Open Source Project
3b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen *
4b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * Licensed under the Apache License, Version 2.0 (the "License");
5b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * you may not use this file except in compliance with the License.
6b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * You may obtain a copy of the License at
7b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen *
8b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen *      http://www.apache.org/licenses/LICENSE-2.0
9b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen *
10b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * Unless required by applicable law or agreed to in writing, software
11b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * distributed under the License is distributed on an "AS IS" BASIS,
12b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * See the License for the specific language governing permissions and
14b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen * limitations under the License.
15b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen */
16b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
17b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen#ifndef IMEDIA_EXTRACTOR_BASE_H_
18b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
19b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen#define IMEDIA_EXTRACTOR_BASE_H_
20b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
21b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen#include <media/IMediaSource.h>
22a321469104536544d1cf0c0098d14bbf14186e88Marco Nelissen#include <media/stagefright/DataSource.h>
23b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
24b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissennamespace android {
25b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
26b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissenclass MetaData;
27b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
28b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissenclass IMediaExtractor : public IInterface {
29b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissenpublic:
30b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    DECLARE_META_INTERFACE(MediaExtractor);
31b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
32b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual size_t countTracks() = 0;
33b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual sp<IMediaSource> getTrack(size_t index) = 0;
34b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
35b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    enum GetTrackMetaDataFlags {
36b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen        kIncludeExtensiveMetaData = 1
37b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    };
38b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual sp<MetaData> getTrackMetaData(
39b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen            size_t index, uint32_t flags = 0) = 0;
40b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
41b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    // Return container specific meta-data. The default implementation
42b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    // returns an empty metadata object.
43b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual sp<MetaData> getMetaData() = 0;
44b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
45b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    enum Flags {
46b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen        CAN_SEEK_BACKWARD  = 1,  // the "seek 10secs back button"
47b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen        CAN_SEEK_FORWARD   = 2,  // the "seek 10secs forward button"
48b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen        CAN_PAUSE          = 4,
49b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen        CAN_SEEK           = 8,  // the "seek bar"
50b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    };
51b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
52b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    // If subclasses do _not_ override this, the default is
53b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    // CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
54b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual uint32_t flags() const = 0;
55b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
56b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    // for DRM
57b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual void setDrmFlag(bool flag) = 0;
58b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual bool getDrmFlag() = 0;
59b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual char* getDrmTrackInfo(size_t trackID, int *len)  = 0;
60b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual void setUID(uid_t uid)  = 0;
61b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
62b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual const char * name() = 0;
63b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen};
64b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
65b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
66b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissenclass BnMediaExtractor: public BnInterface<IMediaExtractor>
67b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen{
68b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissenpublic:
69b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual status_t    onTransact(uint32_t code, const Parcel& data, Parcel* reply,
70b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen                                uint32_t flags = 0);
71b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen};
72b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
7369d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissenvoid registerMediaExtractor(
7469d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen        const sp<IMediaExtractor> &extractor,
75a321469104536544d1cf0c0098d14bbf14186e88Marco Nelissen        const sp<DataSource> &source,
7669d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen        const char *mime);
7769d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen
7869d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissenvoid registerMediaSource(
7969d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen        const sp<IMediaExtractor> &extractor,
8069d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen        const sp<IMediaSource> &source);
8169d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen
8269d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissenstatus_t dumpExtractors(int fd, const Vector<String16>& args);
8369d3d8a9540b0da787ea0beccad2517f057dd54dMarco Nelissen
84b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
85b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen}  // namespace android
86b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen
87b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen#endif  // IMEDIA_EXTRACTOR_BASE_H_
88