Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 1 | page.title=DRM |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 5 | Copyright 2014 The Android Open Source Project |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 6 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | you may not use this file except in compliance with the License. |
| 9 | You may obtain a copy of the License at |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 13 | Unless required by applicable law or agreed to in writing, software |
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | See the License for the specific language governing permissions and |
| 17 | limitations under the License. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 18 | --> |
| 19 | |
| 20 | <div id="qv-wrapper"> |
| 21 | <div id="qv"> |
| 22 | <h2>In this document</h2> |
| 23 | <ol id="auto-toc"> |
| 24 | </ol> |
| 25 | </div> |
| 26 | </div> |
| 27 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 28 | <p>This document provides an overview of the Android DRM framework, and |
| 29 | introduces the interfaces a DRM plug-in must implement. This document does not |
| 30 | describe robustness rules or compliance rules that may be defined by a DRM |
| 31 | scheme.</p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 32 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 33 | <h2 id="introduction">Introduction</h2> |
| 34 | |
| 35 | <p>The Android platform provides an extensible DRM framework that lets |
| 36 | applications manage rights-protected content according to the license |
| 37 | constraints associated with the content. The DRM framework supports many DRM |
| 38 | schemes; which DRM schemes a device supports is up to the device manufacturer. |
| 39 | The DRM framework introduced in Android 3.0 provides a unified interface for |
| 40 | application developers and hides the complexity of DRM operations. The DRM |
| 41 | framework provides a consistent operation mode for protected and non-protected |
| 42 | content. DRM schemes can define very complex usage models by license metadata. |
| 43 | The DRM framework provides the association between DRM content and license, and |
| 44 | handles the rights management. This enables the media player to be abstracted |
| 45 | from DRM-protected or non-protected content. See <a |
| 46 | href="https://developer.android.com/reference/android/media/MediaDrm.html">MediaDrm</a> |
| 47 | for the class to obtain keys for decrypting protected media streams.</p> |
| 48 | |
| 49 | <img src="images/drm_hal.png" alt="Android DRM HAL" /> |
| 50 | |
| 51 | <p class="img-caption"><strong>Figure 1.</strong> DRM Hardware Abastraction |
| 52 | Layer</p> |
| 53 | |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 54 | <p> |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 55 | Availability of rich digital content is important to users on mobile devices. To |
| 56 | make their content widely available, Android developers and digital content |
| 57 | publishers need a consistent DRM implementation supported across the Android |
| 58 | ecosystem. In order to make that digital content available on Android devices |
| 59 | and to ensure that there is at least one consistent DRM available across all |
| 60 | devices, Google provides DRM without any license fees on compatible Android devices. |
| 61 | On Android 3.0 and higher platforms, the DRM plug-in is integrated with the |
| 62 | Android DRM framework and can use hardware-backed protection to secure premium |
| 63 | content and user credentials. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 64 | </p> |
| 65 | |
| 66 | <p> |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 67 | The content protection provided by the DRM plug-in depends on the security and |
| 68 | content protection capabilities of the underlying hardware platform. The |
| 69 | hardware capabilities of the device include hardware secure boot to establish a |
| 70 | chain of trust of security and protection of cryptographic keys. Content |
| 71 | protection capabilities of the device include protection of decrypted frames in |
| 72 | the device and content protection via a trusted output protection mechanism. Not |
| 73 | all hardware platforms support all of the above security and content protection |
| 74 | features. Security is never implemented in a single place in the |
| 75 | stack, but instead relies on the integration of hardware, software, and |
| 76 | services. The combination of hardware security functions, a trusted boot |
| 77 | mechanism, and an isolated secure OS for handling security functions is critical |
| 78 | to providing a secure device.</p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 79 | |
| 80 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 81 | <h2 id="architecture">Architecture</h2> |
| 82 | <p>The DRM framework is designed to be implementation agnostic and |
| 83 | abstracts the details of the specific DRM scheme implementation in a |
| 84 | scheme-specific DRM plug-in. The DRM framework includes simple APIs to handle |
| 85 | complex DRM operations, register users and devices to online DRM services, |
| 86 | extract constraint information from the license, associate DRM content and its |
| 87 | license, and finally decrypt DRM content.</p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 88 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 89 | <p>The Android DRM framework is implemented in two architectural layers:</p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 90 | <ul> |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 91 | <li>A DRM framework API, which is exposed to applications through the Android |
| 92 | application framework and runs through the Dalvik VM for standard |
| 93 | applications.</li> |
| 94 | <li>A native code DRM manager, which implements the DRM framework and exposes an |
| 95 | interface for DRM plug-ins (agents) to handle rights management and decryption |
| 96 | for various DRM schemes.</li> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 97 | </ul> |
| 98 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 99 | <img src="images/drm_framework.png" alt="Android DRM Framework" /> |
| 100 | |
| 101 | <p class="img-caption"><strong>Figure 2.</strong> DRM framework</p> |
| 102 | |
| 103 | <p>See the <a |
| 104 | href="http://developer.android.com/reference/android/drm/package-summary.html">Android |
| 105 | DRM package reference</a> for additional details.</p> |
| 106 | |
| 107 | <h2 id="plug-ins">Plug-ins</h2> |
| 108 | <p>As shown in the figure below, the DRM framework uses a plug-in architecture |
| 109 | to support various DRM schemes. The DRM manager service runs in an independent |
| 110 | process to ensure isolated execution of DRM plug-ins. Each API call from |
| 111 | DrmManagerClient to DrmManagerService goes across process boundaries by using |
| 112 | the binder IPC mechanism. The DrmManagerClient provides a Java programming |
| 113 | language implementation as a common interface to runtime applications; it |
| 114 | also provides a DrmManagerClient-native implementation as the interface to |
| 115 | native modules. The caller of DRM framework accesses only the DrmManagerClient |
| 116 | and does not have to be aware of each DRM scheme. </p> |
| 117 | |
| 118 | <img src="images/drm_plugin.png" alt="Android DRM Plug-in" /> |
| 119 | |
| 120 | <p class="img-caption"><strong>Figure 3.</strong> DRM framework with plug-ins</p> |
| 121 | |
| 122 | <p>Plug-ins are loaded automatically when DrmManagerService is launched. As |
| 123 | shown in the figure below, the DRM plug-in manager loads/unloads all the |
| 124 | available plug-ins. The DRM framework loads plug-ins automatically by finding |
| 125 | them under:<br/> |
| 126 | <code>/system/lib/drm/plugins/native/</code></p> |
| 127 | |
| 128 | <img src="images/drm_plugin_lifecycle.png" alt="Android DRM Plug-in Lifecycle" /> |
| 129 | |
| 130 | <p class="img-caption"><strong>Figure 4.</strong> DRM plug-in lifecycle</p> |
| 131 | |
| 132 | <p>The plug-in developer should ensure the plug-in is located in the DRM |
| 133 | framework plug-in discovery directory. See implementation instructions below for details.</p> |
| 134 | |
| 135 | <h2 id="implementation">Implementation</h2> |
| 136 | |
| 137 | <h3 id="IDrmEngine">IDrmEngine</h3> |
| 138 | |
| 139 | <p>IDrmEngine is an interface with a set of APIs to suit DRM use cases. Plug-in |
| 140 | developers must implement the interfaces specified in IDrmEngine and the |
| 141 | listener interfaces specified below. This document assumes the plug-in developer |
| 142 | has access to the Android source tree. The interface definition is available in |
| 143 | the source tree at:<br/> |
| 144 | <code> |
| 145 | <<platform_root>/frameworks/base/drm/libdrmframework/plugins/common/include |
| 146 | </code></p> |
| 147 | |
| 148 | <h3 id="DrmInfo">DRM Info</h3> |
| 149 | <p>DrmInfo is a wrapper class that wraps the protocol for communicating with the |
| 150 | DRM server. Server registration, deregistration, license acquisition, or any other |
| 151 | server-related transaction can be achieved by processing an instance of DrmInfo. |
| 152 | The protocol should be described by the plug-in in XML format. Each DRM plug-in |
| 153 | would accomplish the transaction by interpreting the protocol. The DRM framework |
| 154 | defines an API to retrieve an instance of DrmInfo called acquireDrmInfo().</p> |
| 155 | |
| 156 | <code>DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);</code> |
| 157 | <p>Retrieves necessary information for registration, deregistration or rights |
| 158 | acquisition information. See <a |
| 159 | href="http://developer.android.com/reference/android/drm/DrmInfoRequest.html">DrmInfoRequest</a> for more information.</p> |
| 160 | |
| 161 | <code>DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);</code> |
| 162 | <p>processDrmInfo() behaves asynchronously and the results of the transaction can |
| 163 | be retrieved either from OnEventListener or OnErrorListener.</p> |
| 164 | |
| 165 | <h3 id="drm-rights">DRM rights</h3> |
| 166 | |
| 167 | <p>The association of DRM content and the license is required to allow playback |
| 168 | of DRM content. Once the association has been made, the license will be handled in |
| 169 | the DRM framework so the Media Player application is abstracted from the existence |
| 170 | of license.</p> |
| 171 | |
| 172 | <code>int checkRightsStatus(int uniqueId, const String8& path, int |
| 173 | action);</code> |
| 174 | <p>Save DRM rights to the specified rights path and make association with content path. |
| 175 | The input parameters are DrmRights to be saved, rights file path where rights |
| 176 | are to be saved and content file path where content was saved.</p> |
| 177 | |
| 178 | <code>status_t saveRights(int uniqueId, const DrmRights& drmRights, |
| 179 | const String8& rightsPath, const String8& |
| 180 | contentPath);</code> |
| 181 | <p>Save DRM rights to specified rights path and make association with content |
| 182 | path.</p> |
| 183 | |
| 184 | <h3 id="metadata">License Metadata</h3> |
| 185 | <p>License metadata such as license expiry time, repeatable count and etc., may be |
| 186 | embedded inside the rights of the protected content. The Android DRM framework |
| 187 | provides APIs to return constraints associated with input content. See <a |
| 188 | href="http://developer.android.com/reference/android/drm/DrmManagerClient.html">DrmManagerClient</a> |
| 189 | for more information.</p> |
| 190 | |
| 191 | <code>DrmConstraints* getConstraints(int uniqueId, const String path, int |
| 192 | action);</code> |
| 193 | <p>The getConstraint function call returns key-value pairs of constraints |
| 194 | embedded in protected content. To retrieve the constraints, the uniqueIds (the |
| 195 | Unique identifier for a session and path of the protected content) are required. |
| 196 | The action, defined as Action::DEFAULT, Action::PLAY, etc., is also required.</p> |
| 197 | |
| 198 | <img src="images/drm_license_metadata.png" alt="Android DRM License Metadata" /> |
| 199 | |
| 200 | <p class="img-caption"><strong>Figure 5.</strong> Retrieve license metadata</p> |
| 201 | |
| 202 | <code>DrmMetadata* getMetadata(int uniqueId, const String path);</code> |
| 203 | <p>Get metadata information associated with input content for a given path of the |
| 204 | protected content to return key-value pairs of metadata.</p> |
| 205 | |
| 206 | <h3 id="metadata">Decrypt session</h3> |
| 207 | <p>To maintain the decryption session, the caller of the DRM framework has to |
| 208 | invoke openDecryptSession() at the beginning of the decryption sequence. |
| 209 | openDecryptSession() asks each DRM plug-in if it can handle input DRM |
| 210 | content.</p> |
| 211 | <code> |
| 212 | status_t openDecryptSession( |
| 213 | int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length); |
| 214 | </code> |
| 215 | |
| 216 | <p>The above call allows you to save DRM rights to specified rights path and make |
| 217 | association with content path. DrmRights parameter is the rights to be saved, |
| 218 | file path where rights should be and content file path where content should be |
| 219 | saved.</p> |
| 220 | |
| 221 | <h3 id="listeners">DRM plug-in Listeners</h3> |
| 222 | |
| 223 | <p>Some APIs in DRM framework behave asynchronously in a DRM transaction. An |
| 224 | application can register three listener classes to DRM framework.</p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 225 | |
| 226 | <ul> |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 227 | <li>OnEventListener for results of asynchronous APIs</li> |
| 228 | <li>OnErrorListener for recieving errors of asynchronous APIs</li> |
| 229 | <li>OnInfoListener for any supplementary information during DRM |
| 230 | transactions.</li> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 231 | </ul> |
| 232 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 233 | <h3 id="source">Source</h3> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 234 | |
Clay Murphy | 177a60d | 2014-03-10 16:59:34 -0700 | [diff] [blame^] | 235 | <p>The Android DRM framework includes a passthru plug-in as a sample plug-in. |
| 236 | The implementation for passthru plug-in can be found in the Android source tree |
| 237 | at:<br/> |
| 238 | <code> |
| 239 | <platform_root>/frameworks/base/drm/libdrmframework/plugins/passthru |
| 240 | </code></p> |
| 241 | |
| 242 | <h3 id="build">Build and Integration</h3> |
| 243 | |
| 244 | <p>Add the following to the Android.mk of the plug-in implementation. The |
| 245 | passthruplugin is used as a sample.</p> |
| 246 | |
| 247 | <code> |
| 248 | PRODUCT_COPY_FILES += |
| 249 | $(TARGET_OUT_SHARED_LIBRARIES)/<plugin_library>:system/lib/drm/plugins/native/<plugin_library> |
| 250 | e.g.,<br/> |
| 251 | PRODUCT_COPY_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/ |
| 252 | libdrmpassthruplugin.so:system/lib/drm/plugins/native/libdrmpassthruplugin.so |
| 253 | </code> |
| 254 | <br/> |
| 255 | <br/> |
| 256 | <p>Plug-in developers must locate their respective plug-ins under this |
| 257 | directory like so:<br/> |
| 258 | <code>/system/lib/drm/plugins/native/libdrmpassthruplugin.so</code></p> |