DrmEngineBase.h revision a2cd44cb5067b4fe98794860690394254d3ac73c
1818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com/*
2818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * Copyright (C) 2010 The Android Open Source Project
3818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com *
4818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * Licensed under the Apache License, Version 2.0 (the "License");
5818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * you may not use this file except in compliance with the License.
6818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * You may obtain a copy of the License at
7818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com *
8818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com *      http://www.apache.org/licenses/LICENSE-2.0
966089e4ec4f1702caf2154780471417872862148caryclark@google.com *
10818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * Unless required by applicable law or agreed to in writing, software
11818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * distributed under the License is distributed on an "AS IS" BASIS,
127eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * See the License for the specific language governing permissions and
14e02c5dabbbfefca3e086b3653d71a7a4a9713277skia.committer@gmail.com * limitations under the License.
15a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com */
16818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#ifndef __DRM_ENGINE_BASE_H__
18a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com#define __DRM_ENGINE_BASE_H__
19818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
20818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com#include <drm/drm_framework_common.h>
21818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com#include "IDrmEngine.h"
22818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
23818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.comnamespace android {
247eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com
257eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com/**
26818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * This class is an interface for plug-in developers
27818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com *
28818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * Responsibility of this class is control the sequence of actual plug-in.
29818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com * All each plug-in developer has to do is implement onXXX() type virtual interfaces.
30818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com */
31818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.comclass DrmEngineBase : public IDrmEngine {
32818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.compublic:
33818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    DrmEngineBase();
34818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual ~DrmEngineBase();
35818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
36818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.compublic:
37818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    DrmConstraints* getConstraints(int uniqueId, const String8* path, int action);
386dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com
39818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t initialize(int uniqueId);
40818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
41818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t setOnInfoListener(int uniqueId, const IDrmEngine::OnInfoListener* infoListener);
42818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
43818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t terminate(int uniqueId);
44818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
4566089e4ec4f1702caf2154780471417872862148caryclark@google.com    bool canHandle(int uniqueId, const String8& path);
46818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
47818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
48818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
49818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t saveRights(int uniqueId, const DrmRights& drmRights,
50818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            const String8& rightsPath, const String8& contentPath);
51818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
5207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
5307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
5407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    String8 getOriginalMimeType(int uniqueId, const String8& path);
5507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
5607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
5707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
5807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    int checkRightsStatus(int uniqueId, const String8& path, int action);
59fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
60fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
61fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
62fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t setPlaybackStatus(
63fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
64fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    bool validateAction(
66fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            int uniqueId, const String8& path, int action, const ActionDescription& description);
67fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
68fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t removeRights(int uniqueId, const String8& path);
69fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
70fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t removeAllRights(int uniqueId);
71fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
72fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t openConvertSession(int uniqueId, int convertId);
73fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
74fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData);
75fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
76fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
77fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
78fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    DrmSupportInfo* getSupportInfo(int uniqueId);
79fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
80fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t openDecryptSession(
81fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
82fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
83fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t openDecryptSession(
84fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, const char* uri);
85fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
86fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
8707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
88818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
89818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int decryptUnitId, const DrmBuffer* headerInfo);
90818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
91818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
92818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
93fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
94fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
95818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
96818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
97fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            void* buffer, ssize_t numBytes, off64_t offset);
98fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
99818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.comprotected:
100818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /////////////////////////////////////////////////////
101fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    // Interface for plug-in developers                //
102fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    // each plug-in has to implement following method  //
103818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /////////////////////////////////////////////////////
104818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
105fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * Get constraint information associated with input content
106fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     *
107818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
108818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] path Path of the protected content
10907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] action Actions defined such as,
110818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Action::DEFAULT, Action::PLAY, etc
111818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return DrmConstraints
112818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     key-value pairs of constraint are embedded in it
113818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @note
114818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     In case of error, return NULL
115818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
116818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual DrmConstraints* onGetConstraints(
117818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int uniqueId, const String8* path, int action) = 0;
11807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
11907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    /**
120818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Initialize plug-in
121818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
122818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
123818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
124818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
125818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
126818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onInitialize(int uniqueId) = 0;
127818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
128818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
129818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Register a callback to be invoked when the caller required to
130818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * receive necessary information
131818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
132818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
133818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] infoListener Listener
134818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
135818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
136818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
137818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onSetOnInfoListener(
1386dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com            int uniqueId, const IDrmEngine::OnInfoListener* infoListener) = 0;
1396dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com
14007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    /**
14107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * Terminate the plug-in
14207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * and release resource bound to plug-in
14307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     *
14407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
14507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @return status_t
146818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
147818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
148cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com    virtual status_t onTerminate(int uniqueId) = 0;
149cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com
15007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    /**
151818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Get whether the given content can be handled by this plugin or not
152818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
1534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] uniqueId Unique identifier for a session
154fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] path Path the protected object
155fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @return bool
156818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns true if this plugin can handle , false in case of not able to handle
157818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
158818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual bool onCanHandle(int uniqueId, const String8& path) = 0;
159dac1d17027dcaa5596885a9f333979418b35001ccaryclark
160dac1d17027dcaa5596885a9f333979418b35001ccaryclark    /**
161dac1d17027dcaa5596885a9f333979418b35001ccaryclark     * Executes given drm information based on its type
162dac1d17027dcaa5596885a9f333979418b35001ccaryclark     *
163dac1d17027dcaa5596885a9f333979418b35001ccaryclark     * @param[in] uniqueId Unique identifier for a session
164fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] drmInfo Information needs to be processed
165fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @return DrmInfoStatus
166818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     instance as a result of processing given input
167818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
16866089e4ec4f1702caf2154780471417872862148caryclark@google.com    virtual DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo) = 0;
16966089e4ec4f1702caf2154780471417872862148caryclark@google.com
170fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    /**
171fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * Save DRM rights to specified rights path
172818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * and make association with content path
173818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
174818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
17566089e4ec4f1702caf2154780471417872862148caryclark@google.com     * @param[in] drmRights DrmRights to be saved
176fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] rightsPath File path where rights to be saved
177fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] contentPath File path where content was saved
178818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
179818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
180818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
18166089e4ec4f1702caf2154780471417872862148caryclark@google.com    virtual status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
18266089e4ec4f1702caf2154780471417872862148caryclark@google.com            const String8& rightspath, const String8& contentPath) = 0;
183fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com
184fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    /**
185818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Retrieves necessary information for registration, unregistration or rights
186818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * acquisition information.
187fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     *
188fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] uniqueId Unique identifier for a session
189fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @param[in] drmInfoRequest Request information to retrieve drmInfo
190fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     * @return DrmInfo
191fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com     *     instance as a result of processing given input
192818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
193818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
194818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
195818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
196818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Retrieves the mime type embedded inside the original content
197818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
198dac1d17027dcaa5596885a9f333979418b35001ccaryclark     * @param[in] uniqueId Unique identifier for a session
199dac1d17027dcaa5596885a9f333979418b35001ccaryclark     * @param[in] path Path of the protected content
200dac1d17027dcaa5596885a9f333979418b35001ccaryclark     * @return String8
201dac1d17027dcaa5596885a9f333979418b35001ccaryclark     *     Returns mime-type of the original content, such as "video/mpeg"
202818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
203cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com    virtual String8 onGetOriginalMimeType(int uniqueId, const String8& path) = 0;
204818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
205818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
206818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Retrieves the type of the protected object (content, rights, etc..)
207818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * using specified path or mimetype. At least one parameter should be non null
208818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * to retrieve DRM object type
209818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
210818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
211818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] path Path of the content or null.
212818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] mimeType Mime type of the content or null.
213818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return type of the DRM content,
214818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     such as DrmObjectType::CONTENT, DrmObjectType::RIGHTS_OBJECT
215818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
216818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual int onGetDrmObjectType(
217818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int uniqueId, const String8& path, const String8& mimeType) = 0;
218818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
2196dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com    /**
2206dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com     * Check whether the given content has valid rights or not
2216dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com     *
222818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
223818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] path Path of the protected content
224818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] action Action to perform (Action::DEFAULT, Action::PLAY, etc)
225818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return the status of the rights for the protected content,
226818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     such as RightsStatus::RIGHTS_VALID, RightsStatus::RIGHTS_EXPIRED, etc.
22707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     */
22807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    virtual int onCheckRightsStatus(int uniqueId, const String8& path, int action) = 0;
22907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
2304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    /**
23107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * Consumes the rights for a content.
23207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * If the reserve parameter is true the rights is reserved until the same
233818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * application calls this api again with the reserve parameter set to false.
23407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     *
23507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
23607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] decryptHandle Handle for the decryption session
23707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
23807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @param[in] reserve True if the rights should be reserved.
23907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * @return status_t
24007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
24107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     */
24207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    virtual status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
24307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            int action, bool reserve) = 0;
24407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
2454431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    /**
24607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     * Informs the DRM Engine about the playback actions performed on the DRM files.
247818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
248cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
249818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptHandle Handle for the decryption session
2500361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
2510361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] position Position in the file (in milliseconds) where the start occurs.
2520361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     *     Only valid together with Playback::START.
2530361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @return status_t
2540361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
2550361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     */
2560361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com    virtual status_t onSetPlaybackStatus(
2570361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
2580361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com
2590361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com    /**
2600361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * Validates whether an action on the DRM content is allowed or not.
2610361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     *
2620361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
2630361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] path Path of the protected content
2640361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] action Action to validate (Action::PLAY, Action::TRANSFER, etc)
2650361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] description Detailed description of the action
2660361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @return true if the action is allowed.
2670361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     */
2680361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com    virtual bool onValidateAction(int uniqueId, const String8& path,
2690361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com            int action, const ActionDescription& description) = 0;
2700361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com
2710361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com    /**
2720361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * Removes the rights associated with the given protected content
2730361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     *
2740361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
2750361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @param[in] path Path of the protected content
2760361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     * @return status_t
2770361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
2780361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com     */
279818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onRemoveRights(int uniqueId, const String8& path) = 0;
280818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
281818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
282818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Removes all the rights information of each plug-in associated with
283818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * DRM framework. Will be used in master reset
284818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
285818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
286818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
287818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
288818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
289818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onRemoveAllRights(int uniqueId) = 0;
290818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
291818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
292818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * This API is for Forward Lock based DRM scheme.
293818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Each time the application tries to download a new DRM file
294818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * which needs to be converted, then the application has to
295818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * begin with calling this API.
296818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
297818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
298818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] convertId Handle for the convert session
299818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
300818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
301818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
302deee496cd30070e52556dcb538c2e5eb39b66b81mike@reedtribe.org    virtual status_t onOpenConvertSession(int uniqueId, int convertId) = 0;
303818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
304818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
305818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Accepts and converts the input data which is part of DRM file.
306818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * The resultant converted data and the status is returned in the DrmConvertedInfo
307818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * object. This method will be called each time there are new block
308818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * of data received by the application.
309818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
310818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
311818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] convertId Handle for the convert session
312818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] inputData Input Data which need to be converted
313818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return Return object contains the status of the data conversion,
314818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     the output converted data and offset. In this case the
315818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     application will ignore the offset information.
316818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
317818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual DrmConvertedStatus* onConvertData(
318818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int uniqueId, int convertId, const DrmBuffer* inputData) = 0;
319818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
320818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
321818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Informs the Drm Agent when there is no more data which need to be converted
322818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * or when an error occurs. Upon successful conversion of the complete data,
323818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * the agent will inform that where the header and body signature
324818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * should be added. This signature appending is needed to integrity
325818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * protect the converted file.
326818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
327818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
328818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] convertId Handle for the convert session
329818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return Return object contains the status of the data conversion,
330818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     the header and body signature data. It also informs
331818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     the application on which offset these signature data
332818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     should be appended.
333818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
334818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual DrmConvertedStatus* onCloseConvertSession(int uniqueId, int convertId) = 0;
335818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
336818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
337818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Returns the information about the Drm Engine capabilities which includes
338818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * supported MimeTypes and file suffixes.
339818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
340818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
341818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return DrmSupportInfo
342818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     instance which holds the capabilities of a plug-in
343818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
344818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual DrmSupportInfo* onGetSupportInfo(int uniqueId) = 0;
345818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
346818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
347818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Open the decrypt session to decrypt the given protected content
348818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
349818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
350818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptHandle Handle for the current decryption session
351818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] fd File descriptor of the protected content to be decrypted
352818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] offset Start position of the content
353818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] length The length of the protected content
354818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return
355818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
356e1ca705cac4b946993f6cbf798e2a0ba27e739f3reed@google.com     */
357818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onOpenDecryptSession(
358818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
359818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
360e1ca705cac4b946993f6cbf798e2a0ba27e739f3reed@google.com    /**
361818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Open the decrypt session to decrypt the given protected content
362818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
363818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
364deee496cd30070e52556dcb538c2e5eb39b66b81mike@reedtribe.org     * @param[in] decryptHandle Handle for the current decryption session
365818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uri Path of the protected content to be decrypted
366818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return
367818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
368818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
369818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onOpenDecryptSession(
370818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
371818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
372818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
373818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Close the decrypt session for the given handle
374818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
375818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
376818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptHandle Handle for the decryption session
377818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
378818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
379818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
380818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
381818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
382818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
383818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Initialize decryption for the given unit of the protected content
384818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
385818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
386818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptId Handle for the decryption session
387818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
388818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] headerInfo Information for initializing decryption of this decrypUnit
389818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @return status_t
390818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
391818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     */
392818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    virtual status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
3934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org            int decryptUnitId, const DrmBuffer* headerInfo) = 0;
3944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org
395818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com    /**
396818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * Decrypt the protected content buffers for the given unit
3974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * This method will be called any number of times, based on number of
398818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * encrypted streams received from application.
399818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
400818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] uniqueId Unique identifier for a session
401818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] decryptId Handle for the decryption session
4024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
403818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] encBuffer Encrypted data block
404818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[out] decBuffer Decrypted data block
405818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] IV Optional buffer
4064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @return status_t
4074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *     Returns the error code for this API
4084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *     DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
4094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *     DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
4104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *     DRM_ERROR_DECRYPT for failure.
4114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     */
4124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
413ad65a3e5fb1f94699f183551b828efbcc6a133cecaryclark@google.com            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
4144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org
4154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    /**
4164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * Finalize decryption for the given unit of the protected content
4174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *
4184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] uniqueId Unique identifier for a session
4194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] decryptHandle Handle for the decryption session
4204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
4214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @return status_t
422cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
42307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com     */
42407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    virtual status_t onFinalizeDecryptUnit(
4254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
426cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com
42791fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    /**
4284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * Reads the specified number of bytes from an open DRM file.
4294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     *
4304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] uniqueId Unique identifier for a session
4314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] decryptHandle Handle for the decryption session
4324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[out] buffer Reference to the buffer that should receive the read data.
4334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @param[in] numBytes Number of bytes to read.
434818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     * @param[in] offset Offset with which to update the file position.
435818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com     *
4364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     * @return Number of bytes read. Returns -1 for Failure.
4374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org     */
4384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    virtual ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
439818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com            void* buffer, ssize_t numBytes, off64_t offset) = 0;
4404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org};
441818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
4426dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com};
4434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org
4446dc7df69ae6b24c90d231e0d6a4516bf4f1aee2ecaryclark@google.com#endif /* __DRM_ENGINE_BASE_H__ */
445818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com
446818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300ecaryclark@google.com