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 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     virtual void setUID(uid_t uid);
     53 
     54     // Return the amount of data cached from the current
     55     // playback positiion (in us).
     56     // While more data is still being fetched *finalStatus == OK,
     57     // Once fetching is completed (no more data available), *finalStatus != OK
     58     // If fetching completed normally (i.e. reached EOS instead of IO error)
     59     // *finalStatus == ERROR_END_OF_STREAM
     60     int64_t getCachedDurationUs(status_t *finalStatus);
     61 
     62     // Return the current estimated bandwidth
     63     status_t getEstimatedBandwidthKbps(int32_t *kbps);
     64 
     65     // Set to use adaptive streaming mode by the WV component.
     66     // If adaptive == true, adaptive streaming mode will be used.
     67     // Default mode is non-adaptive streaming mode.
     68     // Should set to use adaptive streaming mode only if widevine:// protocol
     69     // is used.
     70     void setAdaptiveStreamingMode(bool adaptive);
     71 
     72     // setCryptoPluginMode(true) to select crypto plugin mode.
     73     // In this mode, the extractor returns encrypted data for use
     74     // with the MediaCodec model, which handles the decryption in the
     75     // codec.
     76     void setCryptoPluginMode(bool cryptoPluginMode);
     77 
     78     static bool getVendorLibHandle();
     79 
     80     status_t getError();
     81 
     82     void setError(status_t err);
     83 
     84 protected:
     85     virtual ~WVMExtractor();
     86 
     87 private:
     88     sp<DataSource> mDataSource;
     89     sp<WVMLoadableExtractor> mImpl;
     90 
     91     WVMExtractor(const WVMExtractor &);
     92     WVMExtractor &operator=(const WVMExtractor &);
     93 };
     94 
     95 bool SniffWVM(
     96         const sp<DataSource> &source, String8 *mimeType, float *confidence,
     97         sp<AMessage> *);
     98 
     99 }  // namespace android
    100 
    101 #endif  // DRM_EXTRACTOR_H_
    102 
    103