WVMExtractor.h revision 50255a92dfb2ffd35955035ae9ac9d4b85f606b8
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/DataSource.h>
22#include <media/stagefright/MediaExtractor.h>
23#include <utils/Errors.h>
24
25namespace android {
26
27class DataSource;
28
29class WVMLoadableExtractor : public MediaExtractor {
30public:
31    WVMLoadableExtractor() {}
32    virtual ~WVMLoadableExtractor() {}
33
34    virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0;
35    virtual void setAdaptiveStreamingMode(bool adaptive) = 0;
36};
37
38class WVMExtractor : public MediaExtractor {
39public:
40    WVMExtractor(const sp<DataSource> &source);
41
42    virtual size_t countTracks();
43    virtual sp<MediaSource> getTrack(size_t index);
44    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
45    virtual sp<MetaData> getMetaData();
46
47    // Return the amount of data cached from the current
48    // playback positiion (in us).
49    // While more data is still being fetched *finalStatus == OK,
50    // Once fetching is completed (no more data available), *finalStatus != OK
51    // If fetching completed normally (i.e. reached EOS instead of IO error)
52    // *finalStatus == ERROR_END_OF_STREAM
53    int64_t getCachedDurationUs(status_t *finalStatus);
54
55    // Set to use adaptive streaming mode by the WV component.
56    // If adaptive == true, adaptive streaming mode will be used.
57    // Default mode is non-adaptive streaming mode.
58    // Should set to use adaptive streaming mode only if widevine:// protocol
59    // is used.
60    void setAdaptiveStreamingMode(bool adaptive);
61
62protected:
63    virtual ~WVMExtractor();
64
65private:
66    sp<DataSource> mDataSource;
67    sp<WVMLoadableExtractor> mImpl;
68
69    WVMExtractor(const WVMExtractor &);
70    WVMExtractor &operator=(const WVMExtractor &);
71
72    static Mutex sMutex;
73    static uint32_t sActiveExtractors;
74    static void *sVendorLibHandle;
75};
76
77}  // namespace android
78
79#endif  // DRM_EXTRACTOR_H_
80
81