blob: 6a089334ac92466a16484f82f77bd37270355076 [file] [log] [blame]
Jeff Tinker8ab80a22012-11-29 07:37:08 -08001/*
2 * Copyright (C) 2012 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_CLIENT_API_H_
18#define DRM_CLIENT_API_H_
19
20#include <utils/String8.h>
21#include <utils/Vector.h>
22#include <utils/List.h>
23#include <media/stagefright/foundation/ABase.h>
24
25namespace android {
26
27 // A DrmMessageStatus object aggregates a sessionId, which uniquely
28 // identifies a playback context with a status code and opaque message
29 // data.
30 struct DrmMessageStatus {
31 Vector<uint8_t> mSessionId;
32 status_t mStatus;
33 Vector<uint8_t> mData;
34 };
35
36 class DrmClientPlugin {
37 public:
38
39 // A license can be for downloaded, offline content or for online streaming
40 // Offline licenses are persisted on the device and may be used when the device
41 // is disconnected from the network.
42 enum LicenseType {
43 kLicenseType_Offline,
44 kLicenseType_Streaming
45 };
46
47 DrmClientPlugin() {}
48 virtual ~DrmClientPlugin() {}
49
50 // A license request/response exchange occurs between the app and a License
51 // Server to obtain the keys required to decrypt the content. getLicenseRequest()
52 // is used to obtain an opaque license request blob that is delivered to the
53 // license server.
54 //
55 // The init data passed to getLicenseRequest is container-specific and its
56 // meaning is interpreted based on the mime type provided in the mimeType
57 // parameter to getLicenseRequest. It could contain, for example, the content
58 // ID, key ID or other data obtained from the content metadata that is required
59 // in generating the license request.
60 //
61 // The DrmMessageStatus returned from getLicenseRequest contains a sessionId for
62 // the new session, a status code indicating whether the operation was successful
63 // and if so, the request blob is placed into the mData field.
64 virtual DrmMessageStatus getLicenseRequest(Vector<uint8_t> const &initData,
65 String8 const &mimeType, LicenseType licenseType) = 0;
66
67 // After a license response is received by the app, it is provided to the
68 // DrmClient plugin using provideLicenseResponse. The response data is provided
69 // in the mData field of the response parameter.
70 virtual status_t provideLicenseResponse(DrmMessageStatus const &response) = 0;
71
72 // Remove the keys associated with a license and release the session
73 virtual status_t clearLicense(Vector<uint8_t> const &sessionId) = 0;
74
75 // A provision request/response exchange occurs between the app and a
76 // provisioning server to retrieve a device certificate. getProvisionRequest
77 // is used to obtain an opaque license request blob that is delivered to the
78 // provisioning server.
79 //
80 // The DrmMessageStatus returned from getLicenseRequest contains a status code
81 // indicating whether the operation was successful and if so, the request blob
82 // is placed into the mData field.
83 virtual DrmMessageStatus getProvisionRequest() = 0;
84
85 // After a provision response is received by the app, it is provided to the
86 // DrmClient plugin using provideProvisionResponse. The response data is
87 // provided in the mData field of the response parameter.
88 virtual status_t provideProvisionResponse(DrmMessageStatus const &response) = 0;
89
90 // A means of enforcing the contractual requirement for a concurrent stream
91 // limit per subscriber across devices is provided via SecureStop. SecureStop
92 // is a means of securely monitoring the lifetime of sessions. Since playback
93 // on a device can be interrupted due to reboot, power failure, etc. a means
94 // of persisting the lifetime information on the device is needed.
95 //
96 // A signed version of the sessionID is written to persistent storage on the
97 // device when each MediaCrypto object is created. The sessionID is signed by
98 // the device private key to prevent tampering.
99 //
100 // In the normal case, playback will be completed, the session destroyed and
101 // the Secure Stops will be queried. The App queries secure stops and forwards
102 // the secure stop message to the server which verifies the signature and
103 // notifies the server side database that the session destruction has been
104 // confirmed. The persisted record on the client is only removed after positive
105 // confirmation that the server received the message using releaseSecureStops().
106 virtual List<DrmMessageStatus> getSecureStops() = 0;
107 virtual status_t releaseSecureStops(DrmMessageStatus const &ssRelease) = 0;
108
109 // Retrieve the device unique identifier for this device. The device unique
110 // identifier is established during device provisioning.
111 virtual Vector<uint8_t> getDeviceUniqueId() const = 0;
112
113 private:
114 DISALLOW_EVIL_CONSTRUCTORS(DrmClientPlugin);
115 };
116
117} // namespace android
118
119#endif // DRM_CLIENT_API_H_