1/*
2 * Copyright (C) 2009 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 IMEDIA_EXTRACTOR_BASE_H_
18
19#define IMEDIA_EXTRACTOR_BASE_H_
20
21#include <media/IMediaSource.h>
22#include <media/stagefright/DataSource.h>
23
24namespace android {
25
26class MetaData;
27namespace media {
28class ICas;
29};
30using namespace media;
31
32class IMediaExtractor : public IInterface {
33public:
34    DECLARE_META_INTERFACE(MediaExtractor);
35
36    virtual size_t countTracks() = 0;
37    // This function could return NULL IMediaSource even when index is within the
38    // track count returned by countTracks, since it's possible the track is malformed
39    // and it's not detected during countTracks call.
40    virtual sp<IMediaSource> getTrack(size_t index) = 0;
41
42    enum GetTrackMetaDataFlags {
43        kIncludeExtensiveMetaData = 1
44    };
45    virtual sp<MetaData> getTrackMetaData(
46            size_t index, uint32_t flags = 0) = 0;
47
48    // Return container specific meta-data. The default implementation
49    // returns an empty metadata object.
50    virtual sp<MetaData> getMetaData() = 0;
51
52    virtual status_t getMetrics(Parcel *reply) = 0;
53
54    enum Flags {
55        CAN_SEEK_BACKWARD  = 1,  // the "seek 10secs back button"
56        CAN_SEEK_FORWARD   = 2,  // the "seek 10secs forward button"
57        CAN_PAUSE          = 4,
58        CAN_SEEK           = 8,  // the "seek bar"
59    };
60
61    // If subclasses do _not_ override this, the default is
62    // CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
63    virtual uint32_t flags() const = 0;
64
65    // for DRM
66    virtual char* getDrmTrackInfo(size_t trackID, int *len)  = 0;
67
68    virtual status_t setMediaCas(const sp<ICas> &cas) = 0;
69
70    virtual void setUID(uid_t uid)  = 0;
71
72    virtual const char * name() = 0;
73};
74
75
76class BnMediaExtractor: public BnInterface<IMediaExtractor>
77{
78public:
79    virtual status_t    onTransact(uint32_t code, const Parcel& data, Parcel* reply,
80                                uint32_t flags = 0);
81};
82
83void registerMediaExtractor(
84        const sp<IMediaExtractor> &extractor,
85        const sp<DataSource> &source,
86        const char *mime);
87
88void registerMediaSource(
89        const sp<IMediaExtractor> &extractor,
90        const sp<IMediaSource> &source);
91
92status_t dumpExtractors(int fd, const Vector<String16>& args);
93
94
95}  // namespace android
96
97#endif  // IMEDIA_EXTRACTOR_BASE_H_
98