Drm.h revision cc82dc6d500023eba6048616301a4b12682458db
1/* 2 * Copyright (C) 2013 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 DRM_H_ 18 19#define DRM_H_ 20 21#include "SharedLibrary.h" 22 23#include <media/IDrm.h> 24#include <utils/threads.h> 25 26namespace android { 27 28struct DrmFactory; 29struct DrmPlugin; 30 31struct Drm : public BnDrm { 32 Drm(); 33 virtual ~Drm(); 34 35 virtual status_t initCheck() const; 36 37 virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]); 38 39 virtual status_t createPlugin(const uint8_t uuid[16]); 40 41 virtual status_t destroyPlugin(); 42 43 virtual status_t openSession(Vector<uint8_t> &sessionId); 44 45 virtual status_t closeSession(Vector<uint8_t> const &sessionId); 46 47 virtual status_t 48 getLicenseRequest(Vector<uint8_t> const &sessionId, 49 Vector<uint8_t> const &initData, 50 String8 const &mimeType, DrmPlugin::LicenseType licenseType, 51 KeyedVector<String8, String8> const &optionalParameters, 52 Vector<uint8_t> &request, String8 &defaultUrl); 53 54 virtual status_t provideLicenseResponse(Vector<uint8_t> const &sessionId, 55 Vector<uint8_t> const &response); 56 57 virtual status_t removeLicense(Vector<uint8_t> const &sessionId); 58 59 virtual status_t queryLicenseStatus(Vector<uint8_t> const &sessionId, 60 KeyedVector<String8, String8> &infoMap) const; 61 62 virtual status_t getProvisionRequest(Vector<uint8_t> &request, 63 String8 &defaulUrl); 64 65 virtual status_t provideProvisionResponse(Vector<uint8_t> const &response); 66 67 virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops); 68 69 virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease); 70 71 virtual status_t getPropertyString(String8 const &name, String8 &value ) const; 72 virtual status_t getPropertyByteArray(String8 const &name, 73 Vector<uint8_t> &value ) const; 74 virtual status_t setPropertyString(String8 const &name, String8 const &value ) const; 75 virtual status_t setPropertyByteArray(String8 const &name, 76 Vector<uint8_t> const &value ) const; 77 78private: 79 mutable Mutex mLock; 80 81 status_t mInitCheck; 82 sp<SharedLibrary> mLibrary; 83 DrmFactory *mFactory; 84 DrmPlugin *mPlugin; 85 86 static KeyedVector<Vector<uint8_t>, String8> mUUIDToLibraryPathMap; 87 static KeyedVector<String8, wp<SharedLibrary> > mLibraryPathToOpenLibraryMap; 88 static Mutex mMapLock; 89 90 void findFactoryForScheme(const uint8_t uuid[16]); 91 bool loadLibraryForScheme(const String8 &path, const uint8_t uuid[16]); 92 void closeFactory(); 93 94 95 DISALLOW_EVIL_CONSTRUCTORS(Drm); 96}; 97 98} // namespace android 99 100#endif // CRYPTO_H_ 101