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