Loading include/media/drm/DrmClientAPI.h→include/media/drm/DrmAPI.h +205 −0 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2012 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -14,29 +14,69 @@ * limitations under the License. * limitations under the License. */ */ #ifndef DRM_CLIENT_API_H_ #ifndef DRM_API_H_ #define DRM_CLIENT_API_H_ #define DRM_API_H_ #include <utils/List.h> #include <utils/String8.h> #include <utils/String8.h> #include <utils/Vector.h> #include <utils/Vector.h> #include <utils/List.h> #include <utils/KeyedVector.h> #include <utils/RefBase.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/ABase.h> // Loadable DrmEngine shared libraries should define the entry points // createDrmFactory and createCryptoFactory as shown below: // // extern "C" { // extern android::DrmFactory *createDrmFactory(); // extern android::CryptoFactory *createCryptoFactory(); // } namespace android { namespace android { // A DrmMessageStatus object aggregates a sessionId, which uniquely struct DrmPlugin; // identifies a playback context with a status code and opaque message // data. // DRMs are implemented in DrmEngine plugins, which are dynamically struct DrmMessageStatus { // loadable shared libraries that implement the entry points Vector<uint8_t> mSessionId; // createDrmFactory and createCryptoFactory. createDrmFactory status_t mStatus; // constructs and returns an instance of a DrmFactory object. Similarly, Vector<uint8_t> mData; // createCryptoFactory creates an instance of a CryptoFactory object. // When a MediaCrypto or MediaDrm object needs to be constructed, all // available DrmEngines present in the plugins directory on the device // are scanned for a matching DrmEngine that can support the crypto // scheme. When a match is found, the DrmEngine's createCryptoPlugin and // createDrmPlugin methods are used to create CryptoPlugin or // DrmPlugin instances to support that DRM scheme. class DrmFactory { public: DrmFactory() {} virtual ~DrmFactory() {} // DrmFactory::isCryptoSchemeSupported can be called to determine // if the plugin factory is able to construct plugins that support a // given crypto scheme, which is specified by a UUID. virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0; // Construct a DrmPlugin for the crypto scheme specified by UUID. virtual status_t createDrmPlugin( const uint8_t uuid[16], DrmPlugin **plugin) = 0; private: DrmFactory(const DrmFactory &); DrmFactory &operator=(const DrmFactory &); }; }; class DrmClientPlugin { class DrmPlugin { public: public: enum EventType { kDrmPluginEventProvisionRequired, kDrmPluginEventLicenseNeeded, kDrmPluginEventLicenseExpired, kDrmPluginEventVendorDefined }; // A license can be for downloaded, offline content or for online streaming // A license can be for offline content or for online streaming. // Offline licenses are persisted on the device and may be used when the device // Offline licenses are persisted on the device and may be used when the device // is disconnected from the network. // is disconnected from the network. enum LicenseType { enum LicenseType { Loading @@ -44,8 +84,15 @@ namespace android { kLicenseType_Streaming kLicenseType_Streaming }; }; DrmClientPlugin() {} DrmPlugin() {} virtual ~DrmClientPlugin() {} virtual ~DrmPlugin() {} // Open a new session with the DrmPlugin object. A session ID is returned // in the sessionId parameter. virtual status_t openSession(Vector<uint8_t> &sessionId) = 0; // Close a session on the DrmPlugin object. virtual status_t closeSession(Vector<uint8_t> const &sessionId) = 0; // A license request/response exchange occurs between the app and a License // A license request/response exchange occurs between the app and a License // Server to obtain the keys required to decrypt the content. getLicenseRequest() // Server to obtain the keys required to decrypt the content. getLicenseRequest() Loading @@ -58,34 +105,49 @@ namespace android { // ID, key ID or other data obtained from the content metadata that is required // ID, key ID or other data obtained from the content metadata that is required // in generating the license request. // in generating the license request. // // // The DrmMessageStatus returned from getLicenseRequest contains a sessionId for // licenseType specifes if the license is for streaming or offline content // the new session, a status code indicating whether the operation was successful // // and if so, the request blob is placed into the mData field. // optionalParameters are included in the license server request message to virtual DrmMessageStatus getLicenseRequest(Vector<uint8_t> const &initData, // allow a client application to provide additional message parameters to the String8 const &mimeType, LicenseType licenseType) = 0; // server. // // If successful, the opaque license request blob is returned to the caller. virtual status_t getLicenseRequest(Vector<uint8_t> const &sessionId, Vector<uint8_t> const &initData, String8 const &mimeType, LicenseType licenseType, KeyedVector<String8, String8> const &optionalParameters, Vector<uint8_t> &request, String8 &defaultUrl) = 0; // After a license response is received by the app, it is provided to the // After a license response is received by the app, it is provided to the // DrmClient plugin using provideLicenseResponse. The response data is provided // Drm plugin using provideLicenseResponse. // in the mData field of the response parameter. virtual status_t provideLicenseResponse(Vector<uint8_t> const &sessionId, virtual status_t provideLicenseResponse(DrmMessageStatus const &response) = 0; Vector<uint8_t> const &response) = 0; // Remove the keys associated with a license and release the session // Remove the keys associated with a license. virtual status_t clearLicense(Vector<uint8_t> const &sessionId) = 0; virtual status_t removeLicense(Vector<uint8_t> const &sessionId) = 0; // Request an informative description of the license for the session. The status // is in the form of {name, value} pairs. Since DRM license policies vary by // vendor, the specific status field names are determined by each DRM vendor. // Refer to your DRM provider documentation for definitions of the field names // for a particular DrmEngine. virtual status_t queryLicenseStatus(Vector<uint8_t> const &sessionId, KeyedVector<String8, String8> &infoMap) const = 0; // A provision request/response exchange occurs between the app and a // A provision request/response exchange occurs between the app and a // provisioning server to retrieve a device certificate. getProvisionRequest // provisioning server to retrieve a device certificate. getProvisionRequest // is used to obtain an opaque license request blob that is delivered to the // is used to obtain an opaque license request blob that is delivered to the // provisioning server. // provisioning server. // // // The DrmMessageStatus returned from getLicenseRequest contains a status code // If successful, the opaque provision request blob is returned to the caller. // indicating whether the operation was successful and if so, the request blob virtual status_t getProvisionRequest(Vector<uint8_t> &request, // is placed into the mData field. String8 &defaultUrl) = 0; virtual DrmMessageStatus getProvisionRequest() = 0; // After a provision response is received by the app, it is provided to the // After a provision response is received by the app, it is provided to the // DrmClient plugin using provideProvisionResponse. The response data is // Drm plugin using provideProvisionResponse. // provided in the mData field of the response parameter. virtual status_t provideProvisionResponse(Vector<uint8_t> const &response) = 0; virtual status_t provideProvisionResponse(DrmMessageStatus const &response) = 0; // A means of enforcing the contractual requirement for a concurrent stream // A means of enforcing the contractual requirement for a concurrent stream // limit per subscriber across devices is provided via SecureStop. SecureStop // limit per subscriber across devices is provided via SecureStop. SecureStop Loading @@ -103,17 +165,41 @@ namespace android { // notifies the server side database that the session destruction has been // notifies the server side database that the session destruction has been // confirmed. The persisted record on the client is only removed after positive // confirmed. The persisted record on the client is only removed after positive // confirmation that the server received the message using releaseSecureStops(). // confirmation that the server received the message using releaseSecureStops(). virtual List<DrmMessageStatus> getSecureStops() = 0; virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0; virtual status_t releaseSecureStops(DrmMessageStatus const &ssRelease) = 0; virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0; // Retrieve the device unique identifier for this device. The device unique // Read a property value given the device property string. There are a few forms // identifier is established during device provisioning. // of property access methods, depending on the data type returned. virtual Vector<uint8_t> getDeviceUniqueId() const = 0; // Since DRM plugin properties may vary, additional field names may be defined // by each DRM vendor. Refer to your DRM provider documentation for definitions // of its additional field names. // // Standard values are: // "vendor" [string] identifies the maker of the plugin // "version" [string] identifies the version of the plugin // "description" [string] describes the plugin // 'deviceUniqueId' [byte array] The device unique identifier is established // during device provisioning and provides a means of uniquely identifying // each device. virtual status_t getPropertyString(String8 const &name, String8 &value ) const = 0; virtual status_t getPropertyByteArray(String8 const &name, Vector<uint8_t> &value ) const = 0; // Write a property value given the device property string. There are a few forms // of property setting methods, depending on the data type. // Since DRM plugin properties may vary, additional field names may be defined // by each DRM vendor. Refer to your DRM provider documentation for definitions // of its field names. virtual status_t setPropertyString(String8 const &name, String8 const &value ) = 0; virtual status_t setPropertyByteArray(String8 const &name, Vector<uint8_t> const &value ) = 0; // TODO: provide way to send an event private: private: DISALLOW_EVIL_CONSTRUCTORS(DrmClientPlugin); DISALLOW_EVIL_CONSTRUCTORS(DrmPlugin); }; }; } // namespace android } // namespace android #endif // DRM_CLIENT_API_H_ #endif // DRM_API_H_ include/media/drm/DrmEngineAPI.hdeleted 100644 → 0 +0 −75 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef DRM_ENGINE_API_H_ #define DRM_ENGINE_API_H_ #include <utils/Errors.h> #include <media/stagefright/foundation/ABase.h> namespace android { class CryptoPlugin; class DrmClientPlugin; // DRMs are implemented in DrmEngine plugins, which are dynamically // loadable shared libraries that implement the entry point // createDrmPluginFactory. createDrmPluginFactory constructs and returns // an instance of a DrmPluginFactory object. When a MediaCrypto or // DrmClient object needs to be constructed, all available // DrmEngines present in the plugins directory on the device are scanned // for a matching DrmEngine that can support the crypto scheme. When a // match is found, the DrmEngine’s createCryptoPlugin or // createDrmClientPlugin methods are used to create CryptoPlugin or // DrmClientPlugin instances to support that DRM scheme. class DrmPluginFactory { public: DrmPluginFactory() {} virtual ~DrmPluginFactory() {} // DrmPluginFactory::isCryptoSchemeSupported can be called to determine // if the plugin factory is able to construct plugins that support a // given crypto scheme, which is specified by a UUID. virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const = 0; // Construct a CryptoPlugin for the crypto scheme specified by UUID. // {data, size} provide scheme-specific initialization data. virtual status_t createCryptoPlugin( const uint8_t uuid[16], const void *data, size_t size, CryptoPlugin **plugin) = 0; // Construct a DrmClientPlugin for the crypto scheme specified by UUID. // {data, size} provide scheme-specific initialization data. virtual status_t createDrmClientPlugin( const uint8_t uuid[16], const void *data, size_t size, DrmClientPlugin **plugin) = 0; private: DISALLOW_EVIL_CONSTRUCTORS(DrmPluginFactory); }; } // namespace android // Loadable DrmEngine shared libraries should define the entry point // createDrmPluginFactory as shown below: // // extern "C" { // extern android::DrmPluginFactory *createDrmPluginFactory(); // } #endif // DRM_ENGINE_API_H_ Loading
include/media/drm/DrmClientAPI.h→include/media/drm/DrmAPI.h +205 −0 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2012 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -14,29 +14,69 @@ * limitations under the License. * limitations under the License. */ */ #ifndef DRM_CLIENT_API_H_ #ifndef DRM_API_H_ #define DRM_CLIENT_API_H_ #define DRM_API_H_ #include <utils/List.h> #include <utils/String8.h> #include <utils/String8.h> #include <utils/Vector.h> #include <utils/Vector.h> #include <utils/List.h> #include <utils/KeyedVector.h> #include <utils/RefBase.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/ABase.h> // Loadable DrmEngine shared libraries should define the entry points // createDrmFactory and createCryptoFactory as shown below: // // extern "C" { // extern android::DrmFactory *createDrmFactory(); // extern android::CryptoFactory *createCryptoFactory(); // } namespace android { namespace android { // A DrmMessageStatus object aggregates a sessionId, which uniquely struct DrmPlugin; // identifies a playback context with a status code and opaque message // data. // DRMs are implemented in DrmEngine plugins, which are dynamically struct DrmMessageStatus { // loadable shared libraries that implement the entry points Vector<uint8_t> mSessionId; // createDrmFactory and createCryptoFactory. createDrmFactory status_t mStatus; // constructs and returns an instance of a DrmFactory object. Similarly, Vector<uint8_t> mData; // createCryptoFactory creates an instance of a CryptoFactory object. // When a MediaCrypto or MediaDrm object needs to be constructed, all // available DrmEngines present in the plugins directory on the device // are scanned for a matching DrmEngine that can support the crypto // scheme. When a match is found, the DrmEngine's createCryptoPlugin and // createDrmPlugin methods are used to create CryptoPlugin or // DrmPlugin instances to support that DRM scheme. class DrmFactory { public: DrmFactory() {} virtual ~DrmFactory() {} // DrmFactory::isCryptoSchemeSupported can be called to determine // if the plugin factory is able to construct plugins that support a // given crypto scheme, which is specified by a UUID. virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0; // Construct a DrmPlugin for the crypto scheme specified by UUID. virtual status_t createDrmPlugin( const uint8_t uuid[16], DrmPlugin **plugin) = 0; private: DrmFactory(const DrmFactory &); DrmFactory &operator=(const DrmFactory &); }; }; class DrmClientPlugin { class DrmPlugin { public: public: enum EventType { kDrmPluginEventProvisionRequired, kDrmPluginEventLicenseNeeded, kDrmPluginEventLicenseExpired, kDrmPluginEventVendorDefined }; // A license can be for downloaded, offline content or for online streaming // A license can be for offline content or for online streaming. // Offline licenses are persisted on the device and may be used when the device // Offline licenses are persisted on the device and may be used when the device // is disconnected from the network. // is disconnected from the network. enum LicenseType { enum LicenseType { Loading @@ -44,8 +84,15 @@ namespace android { kLicenseType_Streaming kLicenseType_Streaming }; }; DrmClientPlugin() {} DrmPlugin() {} virtual ~DrmClientPlugin() {} virtual ~DrmPlugin() {} // Open a new session with the DrmPlugin object. A session ID is returned // in the sessionId parameter. virtual status_t openSession(Vector<uint8_t> &sessionId) = 0; // Close a session on the DrmPlugin object. virtual status_t closeSession(Vector<uint8_t> const &sessionId) = 0; // A license request/response exchange occurs between the app and a License // A license request/response exchange occurs between the app and a License // Server to obtain the keys required to decrypt the content. getLicenseRequest() // Server to obtain the keys required to decrypt the content. getLicenseRequest() Loading @@ -58,34 +105,49 @@ namespace android { // ID, key ID or other data obtained from the content metadata that is required // ID, key ID or other data obtained from the content metadata that is required // in generating the license request. // in generating the license request. // // // The DrmMessageStatus returned from getLicenseRequest contains a sessionId for // licenseType specifes if the license is for streaming or offline content // the new session, a status code indicating whether the operation was successful // // and if so, the request blob is placed into the mData field. // optionalParameters are included in the license server request message to virtual DrmMessageStatus getLicenseRequest(Vector<uint8_t> const &initData, // allow a client application to provide additional message parameters to the String8 const &mimeType, LicenseType licenseType) = 0; // server. // // If successful, the opaque license request blob is returned to the caller. virtual status_t getLicenseRequest(Vector<uint8_t> const &sessionId, Vector<uint8_t> const &initData, String8 const &mimeType, LicenseType licenseType, KeyedVector<String8, String8> const &optionalParameters, Vector<uint8_t> &request, String8 &defaultUrl) = 0; // After a license response is received by the app, it is provided to the // After a license response is received by the app, it is provided to the // DrmClient plugin using provideLicenseResponse. The response data is provided // Drm plugin using provideLicenseResponse. // in the mData field of the response parameter. virtual status_t provideLicenseResponse(Vector<uint8_t> const &sessionId, virtual status_t provideLicenseResponse(DrmMessageStatus const &response) = 0; Vector<uint8_t> const &response) = 0; // Remove the keys associated with a license and release the session // Remove the keys associated with a license. virtual status_t clearLicense(Vector<uint8_t> const &sessionId) = 0; virtual status_t removeLicense(Vector<uint8_t> const &sessionId) = 0; // Request an informative description of the license for the session. The status // is in the form of {name, value} pairs. Since DRM license policies vary by // vendor, the specific status field names are determined by each DRM vendor. // Refer to your DRM provider documentation for definitions of the field names // for a particular DrmEngine. virtual status_t queryLicenseStatus(Vector<uint8_t> const &sessionId, KeyedVector<String8, String8> &infoMap) const = 0; // A provision request/response exchange occurs between the app and a // A provision request/response exchange occurs between the app and a // provisioning server to retrieve a device certificate. getProvisionRequest // provisioning server to retrieve a device certificate. getProvisionRequest // is used to obtain an opaque license request blob that is delivered to the // is used to obtain an opaque license request blob that is delivered to the // provisioning server. // provisioning server. // // // The DrmMessageStatus returned from getLicenseRequest contains a status code // If successful, the opaque provision request blob is returned to the caller. // indicating whether the operation was successful and if so, the request blob virtual status_t getProvisionRequest(Vector<uint8_t> &request, // is placed into the mData field. String8 &defaultUrl) = 0; virtual DrmMessageStatus getProvisionRequest() = 0; // After a provision response is received by the app, it is provided to the // After a provision response is received by the app, it is provided to the // DrmClient plugin using provideProvisionResponse. The response data is // Drm plugin using provideProvisionResponse. // provided in the mData field of the response parameter. virtual status_t provideProvisionResponse(Vector<uint8_t> const &response) = 0; virtual status_t provideProvisionResponse(DrmMessageStatus const &response) = 0; // A means of enforcing the contractual requirement for a concurrent stream // A means of enforcing the contractual requirement for a concurrent stream // limit per subscriber across devices is provided via SecureStop. SecureStop // limit per subscriber across devices is provided via SecureStop. SecureStop Loading @@ -103,17 +165,41 @@ namespace android { // notifies the server side database that the session destruction has been // notifies the server side database that the session destruction has been // confirmed. The persisted record on the client is only removed after positive // confirmed. The persisted record on the client is only removed after positive // confirmation that the server received the message using releaseSecureStops(). // confirmation that the server received the message using releaseSecureStops(). virtual List<DrmMessageStatus> getSecureStops() = 0; virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0; virtual status_t releaseSecureStops(DrmMessageStatus const &ssRelease) = 0; virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0; // Retrieve the device unique identifier for this device. The device unique // Read a property value given the device property string. There are a few forms // identifier is established during device provisioning. // of property access methods, depending on the data type returned. virtual Vector<uint8_t> getDeviceUniqueId() const = 0; // Since DRM plugin properties may vary, additional field names may be defined // by each DRM vendor. Refer to your DRM provider documentation for definitions // of its additional field names. // // Standard values are: // "vendor" [string] identifies the maker of the plugin // "version" [string] identifies the version of the plugin // "description" [string] describes the plugin // 'deviceUniqueId' [byte array] The device unique identifier is established // during device provisioning and provides a means of uniquely identifying // each device. virtual status_t getPropertyString(String8 const &name, String8 &value ) const = 0; virtual status_t getPropertyByteArray(String8 const &name, Vector<uint8_t> &value ) const = 0; // Write a property value given the device property string. There are a few forms // of property setting methods, depending on the data type. // Since DRM plugin properties may vary, additional field names may be defined // by each DRM vendor. Refer to your DRM provider documentation for definitions // of its field names. virtual status_t setPropertyString(String8 const &name, String8 const &value ) = 0; virtual status_t setPropertyByteArray(String8 const &name, Vector<uint8_t> const &value ) = 0; // TODO: provide way to send an event private: private: DISALLOW_EVIL_CONSTRUCTORS(DrmClientPlugin); DISALLOW_EVIL_CONSTRUCTORS(DrmPlugin); }; }; } // namespace android } // namespace android #endif // DRM_CLIENT_API_H_ #endif // DRM_API_H_
include/media/drm/DrmEngineAPI.hdeleted 100644 → 0 +0 −75 Original line number Original line Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef DRM_ENGINE_API_H_ #define DRM_ENGINE_API_H_ #include <utils/Errors.h> #include <media/stagefright/foundation/ABase.h> namespace android { class CryptoPlugin; class DrmClientPlugin; // DRMs are implemented in DrmEngine plugins, which are dynamically // loadable shared libraries that implement the entry point // createDrmPluginFactory. createDrmPluginFactory constructs and returns // an instance of a DrmPluginFactory object. When a MediaCrypto or // DrmClient object needs to be constructed, all available // DrmEngines present in the plugins directory on the device are scanned // for a matching DrmEngine that can support the crypto scheme. When a // match is found, the DrmEngine’s createCryptoPlugin or // createDrmClientPlugin methods are used to create CryptoPlugin or // DrmClientPlugin instances to support that DRM scheme. class DrmPluginFactory { public: DrmPluginFactory() {} virtual ~DrmPluginFactory() {} // DrmPluginFactory::isCryptoSchemeSupported can be called to determine // if the plugin factory is able to construct plugins that support a // given crypto scheme, which is specified by a UUID. virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const = 0; // Construct a CryptoPlugin for the crypto scheme specified by UUID. // {data, size} provide scheme-specific initialization data. virtual status_t createCryptoPlugin( const uint8_t uuid[16], const void *data, size_t size, CryptoPlugin **plugin) = 0; // Construct a DrmClientPlugin for the crypto scheme specified by UUID. // {data, size} provide scheme-specific initialization data. virtual status_t createDrmClientPlugin( const uint8_t uuid[16], const void *data, size_t size, DrmClientPlugin **plugin) = 0; private: DISALLOW_EVIL_CONSTRUCTORS(DrmPluginFactory); }; } // namespace android // Loadable DrmEngine shared libraries should define the entry point // createDrmPluginFactory as shown below: // // extern "C" { // extern android::DrmPluginFactory *createDrmPluginFactory(); // } #endif // DRM_ENGINE_API_H_