1/*
2 * Copyright (C) 2010 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_PASSTHRU_PLUGIN_H__
18#define __DRM_PASSTHRU_PLUGIN_H__
19
20#include <DrmEngineBase.h>
21
22namespace android {
23
24class DrmPassthruPlugIn : public DrmEngineBase {
25
26public:
27    DrmPassthruPlugIn();
28    virtual ~DrmPassthruPlugIn();
29
30protected:
31    DrmConstraints* onGetConstraints(int uniqueId, const String8* path, int action);
32
33    DrmMetadata* onGetMetadata(int uniqueId, const String8* path);
34
35    status_t onInitialize(int uniqueId);
36
37    status_t onSetOnInfoListener(int uniqueId, const IDrmEngine::OnInfoListener* infoListener);
38
39    status_t onTerminate(int uniqueId);
40
41    bool onCanHandle(int uniqueId, const String8& path);
42
43    DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo);
44
45    status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
46            const String8& rightsPath, const String8& contentPath);
47
48    DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
49
50    String8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd);
51
52    int onGetDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
53
54    int onCheckRightsStatus(int uniqueId, const String8& path, int action);
55
56    status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
57
58    status_t onSetPlaybackStatus(
59            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
60
61    bool onValidateAction(
62            int uniqueId, const String8& path, int action, const ActionDescription& description);
63
64    status_t onRemoveRights(int uniqueId, const String8& path);
65
66    status_t onRemoveAllRights(int uniqueId);
67
68    status_t onOpenConvertSession(int uniqueId, int convertId);
69
70    DrmConvertedStatus* onConvertData(int uniqueId, int convertId, const DrmBuffer* inputData);
71
72    DrmConvertedStatus* onCloseConvertSession(int uniqueId, int convertId);
73
74    DrmSupportInfo* onGetSupportInfo(int uniqueId);
75
76    status_t onOpenDecryptSession(
77            int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
78
79    status_t onOpenDecryptSession(
80            int uniqueId, DecryptHandle* decryptHandle, const char* uri);
81
82    status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
83
84    status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
85            int decryptUnitId, const DrmBuffer* headerInfo);
86
87    status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
88            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
89
90    status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
91
92    ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
93            void* buffer, ssize_t numBytes, off64_t offset);
94
95private:
96    DecryptHandle* openDecryptSessionImpl();
97};
98
99};
100
101#endif /* __DRM_PASSTHRU_PLUGIN_H__ */
102
103