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