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