IDrmEngine
IDrmEngine is an interface with a set of APIs to suit DRM use cases. Plug-in
developers must implement the interfaces specified in IDrmEngine and the
listener interfaces specified below. This document assumes the plug-in developer
has access to the Android source tree. The interface definition is available in
the source tree at:
<<platform_root>/frameworks/base/drm/libdrmframework/plugins/common/include
DRM Info
DrmInfo is a wrapper class that wraps the protocol for communicating with the
DRM server. Server registration, deregistration, license acquisition, or any other
server-related transaction can be achieved by processing an instance of DrmInfo.
The protocol should be described by the plug-in in XML format. Each DRM plug-in
would accomplish the transaction by interpreting the protocol. The DRM framework
defines an API to retrieve an instance of DrmInfo called acquireDrmInfo().
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
Retrieves necessary information for registration, deregistration or rights
acquisition information. See DrmInfoRequest for more information.
DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
processDrmInfo() behaves asynchronously and the results of the transaction can
be retrieved either from OnEventListener or OnErrorListener.
DRM rights
The association of DRM content and the license is required to allow playback
of DRM content. Once the association has been made, the license will be handled in
the DRM framework so the Media Player application is abstracted from the existence
of license.
int checkRightsStatus(int uniqueId, const String8& path, int
action);
Save DRM rights to the specified rights path and make association with content path.
The input parameters are DrmRights to be saved, rights file path where rights
are to be saved and content file path where content was saved.
status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8&
contentPath);
Save DRM rights to specified rights path and make association with content
path.
License Metadata
License metadata such as license expiry time, repeatable count and etc., may be
embedded inside the rights of the protected content. The Android DRM framework
provides APIs to return constraints associated with input content. See DrmManagerClient
for more information.
DrmConstraints* getConstraints(int uniqueId, const String path, int
action);
The getConstraint function call returns key-value pairs of constraints
embedded in protected content. To retrieve the constraints, the uniqueIds (the
Unique identifier for a session and path of the protected content) are required.
The action, defined as Action::DEFAULT, Action::PLAY, etc., is also required.
DrmMetadata* getMetadata(int uniqueId, const String path);
Get metadata information associated with input content for a given path of the
protected content to return key-value pairs of metadata.
Decrypt session
To maintain the decryption session, the caller of the DRM framework has to
invoke openDecryptSession() at the beginning of the decryption sequence.
openDecryptSession() asks each DRM plug-in if it can handle input DRM
content.
status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
The above call allows you to save DRM rights to specified rights path and make
association with content path. DrmRights parameter is the rights to be saved,
file path where rights should be and content file path where content should be
saved.
DRM plug-in Listeners
Some APIs in DRM framework behave asynchronously in a DRM transaction. An
application can register three listener classes to DRM framework.
- OnEventListener for results of asynchronous APIs
- OnErrorListener for recieving errors of asynchronous APIs
- OnInfoListener for any supplementary information during DRM transactions.
Source
The Android DRM framework includes a passthru plug-in as a sample plug-in.
The implementation for passthru plug-in can be found in the Android source tree
at:
<platform_root>/frameworks/base/drm/libdrmframework/plugins/passthru
Build and Integration
Add the following to the Android.mk of the plug-in implementation. The
passthruplugin is used as a sample.
PRODUCT_COPY_FILES +=
$(TARGET_OUT_SHARED_LIBRARIES)/<plugin_library>:system/lib/drm/plugins/native/<plugin_library>
e.g.,
PRODUCT_COPY_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/
libdrmpassthruplugin.so:system/lib/drm/plugins/native/libdrmpassthruplugin.so
Plug-in developers must locate their respective plug-ins under this
directory like so:
/system/lib/drm/plugins/native/libdrmpassthruplugin.so Read more...
Nice post,thank you for sharing this awesome article with us.
ReplyDeletekeep posting more articles.
android app development course