WVMExtractor.h revision f10f36d34812bae602ff018fb503ad07eaf550b1
1/*
2 * Copyright (C) 2010 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 WVM_EXTRACTOR_H_
18
19#define WVM_EXTRACTOR_H_
20
21#include <media/stagefright/MediaExtractor.h>
22#include <utils/Errors.h>
23
24namespace android {
25
26struct AMessage;
27class String8;
28class DataSource;
29
30class WVMLoadableExtractor : public MediaExtractor {
31public:
32    WVMLoadableExtractor() {}
33    virtual ~WVMLoadableExtractor() {}
34
35    virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0;
36    virtual status_t getEstimatedBandwidthKbps(int32_t *kbps) = 0;
37    virtual void setAdaptiveStreamingMode(bool adaptive) = 0;
38    virtual void setCryptoPluginMode(bool cryptoPluginMode) = 0;
39    virtual void setUID(uid_t uid) = 0;
40};
41
42class WVMExtractor : public MediaExtractor {
43public:
44    WVMExtractor(const sp<DataSource> &source);
45
46    virtual size_t countTracks();
47    virtual sp<MediaSource> getTrack(size_t index);
48    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
49    virtual sp<MetaData> getMetaData();
50
51    // Return the amount of data cached from the current
52    // playback positiion (in us).
53    // While more data is still being fetched *finalStatus == OK,
54    // Once fetching is completed (no more data available), *finalStatus != OK
55    // If fetching completed normally (i.e. reached EOS instead of IO error)
56    // *finalStatus == ERROR_END_OF_STREAM
57    int64_t getCachedDurationUs(status_t *finalStatus);
58
59    // Return the current estimated bandwidth
60    status_t getEstimatedBandwidthKbps(int32_t *kbps);
61
62    // Set to use adaptive streaming mode by the WV component.
63    // If adaptive == true, adaptive streaming mode will be used.
64    // Default mode is non-adaptive streaming mode.
65    // Should set to use adaptive streaming mode only if widevine:// protocol
66    // is used.
67    void setAdaptiveStreamingMode(bool adaptive);
68
69    // setCryptoPluginMode(true) to select crypto plugin mode.
70    // In this mode, the extractor returns encrypted data for use
71    // with the MediaCodec model, which handles the decryption in the
72    // codec.
73    void setCryptoPluginMode(bool cryptoPluginMode);
74
75    void setUID(uid_t uid);
76
77    static bool getVendorLibHandle();
78
79protected:
80    virtual ~WVMExtractor();
81
82private:
83    sp<DataSource> mDataSource;
84    sp<WVMLoadableExtractor> mImpl;
85
86    WVMExtractor(const WVMExtractor &);
87    WVMExtractor &operator=(const WVMExtractor &);
88};
89
90bool SniffWVM(
91        const sp<DataSource> &source, String8 *mimeType, float *confidence,
92        sp<AMessage> *);
93
94}  // namespace android
95
96#endif  // DRM_EXTRACTOR_H_
97
98