blob: 4403a7141234e77f1b127e9b28747f1c2676070b [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=DRM
2@jd:body
3
4<!--
Heidi von Markham1e7b8b72015-03-09 10:13:48 -07005 Copyright 2015 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
Clay Murphy96bf3492014-03-10 16:59:34 -07007 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 Ly35f2fda2013-01-29 16:27:05 -080010
11 http://www.apache.org/licenses/LICENSE-2.0
12
Clay Murphy96bf3492014-03-10 16:59:34 -070013 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 Ly35f2fda2013-01-29 16:27:05 -080018-->
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
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070028<img style="float: right; margin: 0px 15px 15px 0px;" src="images/ape_fwk_hal_drm.png" alt="Android DRM HAL icon" width="175" />
29
Clay Murphy96bf3492014-03-10 16:59:34 -070030<p>This document provides an overview of the Android DRM framework, and
31introduces the interfaces a DRM plug-in must implement. This document does not
32describe robustness rules or compliance rules that may be defined by a DRM
33scheme.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080034
Clay Murphy96bf3492014-03-10 16:59:34 -070035<h2 id="introduction">Introduction</h2>
36
37<p>The Android platform provides an extensible DRM framework that lets
38applications manage rights-protected content according to the license
39constraints associated with the content. The DRM framework supports many DRM
40schemes; which DRM schemes a device supports is up to the device manufacturer.
41The DRM framework introduced in Android 3.0 provides a unified interface for
42application developers and hides the complexity of DRM operations. The DRM
43framework provides a consistent operation mode for protected and non-protected
44content. DRM schemes can define very complex usage models by license metadata.
45The DRM framework provides the association between DRM content and license, and
46handles the rights management. This enables the media player to be abstracted
47from DRM-protected or non-protected content. See <a
48href="https://developer.android.com/reference/android/media/MediaDrm.html">MediaDrm</a>
49for the class to obtain keys for decrypting protected media streams.</p>
50
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070051 <img src="images/ape_fwk_drm.png" alt="Android DRM HAL" />
Clay Murphy96bf3492014-03-10 16:59:34 -070052
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070053<p class="img-caption"><strong>Figure 1.</strong> DRM Hardware Abstraction
Clay Murphy96bf3492014-03-10 16:59:34 -070054Layer</p>
55
Robert Ly35f2fda2013-01-29 16:27:05 -080056<p>
Clay Murphy96bf3492014-03-10 16:59:34 -070057Availability of rich digital content is important to users on mobile devices. To
58make their content widely available, Android developers and digital content
59publishers need a consistent DRM implementation supported across the Android
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070060ecosystem. To make that digital content available on Android devices and to ensure at least one consistent DRM available across all
61devices, Google provides DRM without license fees on compatible Android devices.
Clay Murphy96bf3492014-03-10 16:59:34 -070062On Android 3.0 and higher platforms, the DRM plug-in is integrated with the
63Android DRM framework and can use hardware-backed protection to secure premium
64content and user credentials.
Robert Ly35f2fda2013-01-29 16:27:05 -080065</p>
66
67<p>
Clay Murphy96bf3492014-03-10 16:59:34 -070068The content protection provided by the DRM plug-in depends on the security and
69content protection capabilities of the underlying hardware platform. The
70hardware capabilities of the device include hardware secure boot to establish a
71chain of trust of security and protection of cryptographic keys. Content
72protection capabilities of the device include protection of decrypted frames in
73the device and content protection via a trusted output protection mechanism. Not
74all hardware platforms support all of the above security and content protection
75features. Security is never implemented in a single place in the
76stack, but instead relies on the integration of hardware, software, and
77services. The combination of hardware security functions, a trusted boot
78mechanism, and an isolated secure OS for handling security functions is critical
79to providing a secure device.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080080
81
Clay Murphy96bf3492014-03-10 16:59:34 -070082<h2 id="architecture">Architecture</h2>
83<p>The DRM framework is designed to be implementation agnostic and
84abstracts the details of the specific DRM scheme implementation in a
85scheme-specific DRM plug-in. The DRM framework includes simple APIs to handle
86complex DRM operations, register users and devices to online DRM services,
87extract constraint information from the license, associate DRM content and its
88license, and finally decrypt DRM content.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080089
Clay Murphy96bf3492014-03-10 16:59:34 -070090<p>The Android DRM framework is implemented in two architectural layers:</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080091<ul>
Clay Murphy96bf3492014-03-10 16:59:34 -070092<li>A DRM framework API, which is exposed to applications through the Android
93 application framework and runs through the Dalvik VM for standard
94 applications.</li>
95<li>A native code DRM manager, which implements the DRM framework and exposes an
96 interface for DRM plug-ins (agents) to handle rights management and decryption
97 for various DRM schemes.</li>
Robert Ly35f2fda2013-01-29 16:27:05 -080098</ul>
99
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700100 <img src="images/ape_fwk_drm_2.png" alt="Android DRM Framework" />
Clay Murphy96bf3492014-03-10 16:59:34 -0700101
102<p class="img-caption"><strong>Figure 2.</strong> DRM framework</p>
103
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700104<p>For details, refer to the <a
Clay Murphy96bf3492014-03-10 16:59:34 -0700105href="http://developer.android.com/reference/android/drm/package-summary.html">Android
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700106DRM package reference</a>.</p>
Clay Murphy96bf3492014-03-10 16:59:34 -0700107
108<h2 id="plug-ins">Plug-ins</h2>
109<p>As shown in the figure below, the DRM framework uses a plug-in architecture
110to support various DRM schemes. The DRM manager service runs in an independent
111process to ensure isolated execution of DRM plug-ins. Each API call from
112DrmManagerClient to DrmManagerService goes across process boundaries by using
113the binder IPC mechanism. The DrmManagerClient provides a Java programming
114language implementation as a common interface to runtime applications; it
115also provides a DrmManagerClient-native implementation as the interface to
116native modules. The caller of DRM framework accesses only the DrmManagerClient
117and does not have to be aware of each DRM scheme. </p>
118
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700119 <img src="images/ape_fwk_drm_plugins.png" alt="Android DRM Plug-in" />
Clay Murphy96bf3492014-03-10 16:59:34 -0700120
121<p class="img-caption"><strong>Figure 3.</strong> DRM framework with plug-ins</p>
122
123<p>Plug-ins are loaded automatically when DrmManagerService is launched. As
124shown in the figure below, the DRM plug-in manager loads/unloads all the
125available plug-ins. The DRM framework loads plug-ins automatically by finding
126them under:<br/>
127<code>/system/lib/drm/plugins/native/</code></p>
128
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700129<img src="images/ape_fwk_drm_plugins_life.png" alt="Android DRM Plug-in Lifecycle" />
Clay Murphy96bf3492014-03-10 16:59:34 -0700130
131<p class="img-caption"><strong>Figure 4.</strong> DRM plug-in lifecycle</p>
132
133<p>The plug-in developer should ensure the plug-in is located in the DRM
134framework plug-in discovery directory. See implementation instructions below for details.</p>
135
136<h2 id="implementation">Implementation</h2>
137
138<h3 id="IDrmEngine">IDrmEngine</h3>
139
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700140<p>IDrmEngine is an interface with a set of APIs for DRM use cases. Plug-in
Clay Murphy96bf3492014-03-10 16:59:34 -0700141developers must implement the interfaces specified in IDrmEngine and the
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700142listener interfaces specified below. The interface definition is available in
143the source tree at:<p/>
Clay Murphy96bf3492014-03-10 16:59:34 -0700144<code>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700145&lt;platform_root&gt;/frameworks/base/drm/libdrmframework/plugins/common/include
146</code>
Clay Murphy96bf3492014-03-10 16:59:34 -0700147
148<h3 id="DrmInfo">DRM Info</h3>
149<p>DrmInfo is a wrapper class that wraps the protocol for communicating with the
150DRM server. Server registration, deregistration, license acquisition, or any other
151server-related transaction can be achieved by processing an instance of DrmInfo.
152The protocol should be described by the plug-in in XML format. Each DRM plug-in
153would accomplish the transaction by interpreting the protocol. The DRM framework
154defines 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
158acquisition information. See <a
159href="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
163be 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
168of DRM content. Once the association has been made, the license will be handled in
169the DRM framework so the Media Player application is abstracted from the existence
170of license.</p>
171
172<code>int checkRightsStatus(int uniqueId, const String8&amp; path, int
173action);</code>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700174
Clay Murphy96bf3492014-03-10 16:59:34 -0700175<p>Save DRM rights to the specified rights path and make association with content path.
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700176The input parameters are the DrmRights to be saved, the rights file path where rights
177are to be saved, and the content file path where content was saved.</p>
Clay Murphy96bf3492014-03-10 16:59:34 -0700178
179<code>status_t saveRights(int uniqueId, const DrmRights&amp; drmRights,
180 const String8&amp; rightsPath, const String8&amp;
181contentPath);</code>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700182
Clay Murphy96bf3492014-03-10 16:59:34 -0700183<p>Save DRM rights to specified rights path and make association with content
184path.</p>
185
186<h3 id="metadata">License Metadata</h3>
187<p>License metadata such as license expiry time, repeatable count and etc., may be
188embedded inside the rights of the protected content. The Android DRM framework
189provides APIs to return constraints associated with input content. See <a
190href="http://developer.android.com/reference/android/drm/DrmManagerClient.html">DrmManagerClient</a>
191for more information.</p>
192
193<code>DrmConstraints* getConstraints(int uniqueId, const String path, int
194action);</code>
195<p>The getConstraint function call returns key-value pairs of constraints
196embedded in protected content. To retrieve the constraints, the uniqueIds (the
197Unique identifier for a session and path of the protected content) are required.
198The action, defined as Action::DEFAULT, Action::PLAY, etc., is also required.</p>
199
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700200 <img src="images/ape_fwk_drm_retrieve_license.png" alt="Android DRM License Metadata" />
Clay Murphy96bf3492014-03-10 16:59:34 -0700201
202<p class="img-caption"><strong>Figure 5.</strong> Retrieve license metadata</p>
203
204<code>DrmMetadata* getMetadata(int uniqueId, const String path);</code>
205<p>Get metadata information associated with input content for a given path of the
206protected content to return key-value pairs of metadata.</p>
207
208<h3 id="metadata">Decrypt session</h3>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700209<p>To maintain the decryption session, the caller of the DRM framework must
Clay Murphy96bf3492014-03-10 16:59:34 -0700210invoke openDecryptSession() at the beginning of the decryption sequence.
211openDecryptSession() asks each DRM plug-in if it can handle input DRM
212content.</p>
213<code>
214status_t openDecryptSession(
215 int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
216</code>
217
218<p>The above call allows you to save DRM rights to specified rights path and make
219association with content path. DrmRights parameter is the rights to be saved,
220file path where rights should be and content file path where content should be
221saved.</p>
222
223<h3 id="listeners">DRM plug-in Listeners</h3>
224
225<p>Some APIs in DRM framework behave asynchronously in a DRM transaction. An
226application can register three listener classes to DRM framework.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -0800227
228<ul>
Clay Murphy96bf3492014-03-10 16:59:34 -0700229<li>OnEventListener for results of asynchronous APIs</li>
230<li>OnErrorListener for recieving errors of asynchronous APIs</li>
231<li>OnInfoListener for any supplementary information during DRM
232transactions.</li>
Robert Ly35f2fda2013-01-29 16:27:05 -0800233</ul>
234
Clay Murphy96bf3492014-03-10 16:59:34 -0700235<h3 id="source">Source</h3>
Robert Ly35f2fda2013-01-29 16:27:05 -0800236
Clay Murphy96bf3492014-03-10 16:59:34 -0700237<p>The Android DRM framework includes a passthru plug-in as a sample plug-in.
238The implementation for passthru plug-in can be found in the Android source tree
239at:<br/>
240<code>
241&lt;platform_root&gt;/frameworks/base/drm/libdrmframework/plugins/passthru
242</code></p>
243
244<h3 id="build">Build and Integration</h3>
245
246<p>Add the following to the Android.mk of the plug-in implementation. The
247passthruplugin is used as a sample.</p>
248
249<code>
250PRODUCT_COPY_FILES +=
251$(TARGET_OUT_SHARED_LIBRARIES)/&lt;plugin_library&gt;:system/lib/drm/plugins/native/&lt;plugin_library&gt;
252e.g.,<br/>
253PRODUCT_COPY_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/
254libdrmpassthruplugin.so:system/lib/drm/plugins/native/libdrmpassthruplugin.so
255</code>
256<br/>
257<br/>
258<p>Plug-in developers must locate their respective plug-ins under this
259directory like so:<br/>
260<code>/system/lib/drm/plugins/native/libdrmpassthruplugin.so</code></p>