Skip to content

Commit d074e30

Browse files
author
aimitakeshi
committed
Initial contribution from Sony Corporation.
Add DRM Framework to support DRM content playback together with StageFright. - DRM Framework code is added - include/drm - drm - api/current.xml is updated to include DRM Framework Java APIs - cmds/servicemanager/service_manager.c is modified to add drmManager and drmIOService. Change-Id: I6d7bc9c7067362b500e530988a9ce241761866fb
1 parent f470ed8 commit d074e30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+12648
-2
lines changed

api/current.xml

Lines changed: 1611 additions & 2 deletions
Large diffs are not rendered by default.

cmds/servicemanager/service_manager.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static struct {
3434
{ AID_MEDIA, "media.player" },
3535
{ AID_MEDIA, "media.camera" },
3636
{ AID_MEDIA, "media.audio_policy" },
37+
{ AID_DRMIO, "drm.drmIOService" },
38+
{ AID_DRM, "drm.drmManager" },
3739
{ AID_RADIO, "radio.phone" },
3840
{ AID_RADIO, "radio.sms" },
3941
{ AID_RADIO, "radio.phonesubinfo" },

drm/common/Android.mk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
LOCAL_PATH:= $(call my-dir)
17+
include $(CLEAR_VARS)
18+
19+
LOCAL_SRC_FILES:= \
20+
DrmConstraints.cpp \
21+
DrmConvertedStatus.cpp \
22+
DrmEngineBase.cpp \
23+
DrmInfo.cpp \
24+
DrmInfoRequest.cpp \
25+
DrmInfoStatus.cpp \
26+
DrmRights.cpp \
27+
DrmSupportInfo.cpp \
28+
IDrmIOService.cpp \
29+
IDrmManagerService.cpp \
30+
IDrmServiceListener.cpp \
31+
DrmInfoEvent.cpp \
32+
ReadWriteUtils.cpp
33+
34+
LOCAL_C_INCLUDES := \
35+
$(TOP)/frameworks/base/include \
36+
$(TOP)/frameworks/base/drm/libdrmframework/include \
37+
$(TOP)/frameworks/base/drm/libdrmframework/plugins/common/include
38+
39+
LOCAL_MODULE:= libdrmframeworkcommon
40+
41+
include $(BUILD_STATIC_LIBRARY)

drm/common/DrmConstraints.cpp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
#include <drm/DrmConstraints.h>
18+
19+
using namespace android;
20+
21+
const String8 DrmConstraints::MAX_REPEAT_COUNT("max_repeat_count");
22+
const String8 DrmConstraints::REMAINING_REPEAT_COUNT("remaining_repeat_count");
23+
const String8 DrmConstraints::LICENSE_START_TIME("license_start_time");
24+
const String8 DrmConstraints::LICENSE_EXPIRY_TIME("license_expiry_time");
25+
const String8 DrmConstraints::LICENSE_AVAILABLE_TIME("license_available_time");
26+
const String8 DrmConstraints::EXTENDED_METADATA("extended_metadata");
27+
28+
int DrmConstraints::getCount(void) const {
29+
return mConstraintMap.size();
30+
}
31+
32+
status_t DrmConstraints::put(const String8* key, const char* value) {
33+
int length = strlen(value);
34+
char* charValue = new char[length + 1];
35+
if (NULL != charValue) {
36+
strncpy(charValue, value, length);
37+
charValue[length] = '\0';
38+
mConstraintMap.add(*key, charValue);
39+
}
40+
return DRM_NO_ERROR;
41+
}
42+
43+
String8 DrmConstraints::get(const String8& key) const {
44+
if (NULL != getValue(&key)) {
45+
return String8(getValue(&key));
46+
}
47+
return String8("");
48+
}
49+
50+
const char* DrmConstraints::getValue(const String8* key) const {
51+
if (NAME_NOT_FOUND != mConstraintMap.indexOfKey(*key)) {
52+
return mConstraintMap.valueFor(*key);
53+
}
54+
return NULL;
55+
}
56+
57+
const char* DrmConstraints::getAsByteArray(const String8* key) const {
58+
return getValue(key);
59+
}
60+
61+
bool DrmConstraints::KeyIterator::hasNext() {
62+
return mIndex < mDrmConstraints->mConstraintMap.size();
63+
}
64+
65+
const String8& DrmConstraints::KeyIterator::next() {
66+
const String8& key = mDrmConstraints->mConstraintMap.keyAt(mIndex);
67+
mIndex++;
68+
return key;
69+
}
70+
71+
DrmConstraints::KeyIterator DrmConstraints::keyIterator() {
72+
return KeyIterator(this);
73+
}
74+
75+
DrmConstraints::KeyIterator::KeyIterator(const DrmConstraints::KeyIterator& keyIterator)
76+
: mDrmConstraints(keyIterator.mDrmConstraints),
77+
mIndex(keyIterator.mIndex) {
78+
LOGV("DrmConstraints::KeyIterator::KeyIterator");
79+
}
80+
81+
DrmConstraints::KeyIterator& DrmConstraints::KeyIterator::operator=(
82+
const DrmConstraints::KeyIterator& keyIterator) {
83+
LOGV("DrmConstraints::KeyIterator::operator=");
84+
mDrmConstraints = keyIterator.mDrmConstraints;
85+
mIndex = keyIterator.mIndex;
86+
return *this;
87+
}
88+
89+
90+
DrmConstraints::Iterator DrmConstraints::iterator() {
91+
return Iterator(this);
92+
}
93+
94+
DrmConstraints::Iterator::Iterator(const DrmConstraints::Iterator& iterator) :
95+
mDrmConstraints(iterator.mDrmConstraints),
96+
mIndex(iterator.mIndex) {
97+
LOGV("DrmConstraints::Iterator::Iterator");
98+
}
99+
100+
DrmConstraints::Iterator& DrmConstraints::Iterator::operator=(
101+
const DrmConstraints::Iterator& iterator) {
102+
LOGV("DrmConstraints::Iterator::operator=");
103+
mDrmConstraints = iterator.mDrmConstraints;
104+
mIndex = iterator.mIndex;
105+
return *this;
106+
}
107+
108+
bool DrmConstraints::Iterator::hasNext() {
109+
return mIndex < mDrmConstraints->mConstraintMap.size();
110+
}
111+
112+
String8 DrmConstraints::Iterator::next() {
113+
String8 value = String8(mDrmConstraints->mConstraintMap.editValueAt(mIndex));
114+
mIndex++;
115+
return value;
116+
}
117+

drm/common/DrmConvertedStatus.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
#include <drm/DrmConvertedStatus.h>
18+
19+
using namespace android;
20+
21+
DrmConvertedStatus::DrmConvertedStatus(
22+
int _statusCode, const DrmBuffer* _convertedData, int _offset) :
23+
statusCode(_statusCode),
24+
convertedData(_convertedData),
25+
offset(_offset) {
26+
27+
}
28+

drm/common/DrmEngineBase.cpp

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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+
#include "DrmEngineBase.h"
18+
19+
using namespace android;
20+
21+
DrmEngineBase::DrmEngineBase() {
22+
23+
}
24+
25+
DrmEngineBase::~DrmEngineBase() {
26+
27+
}
28+
29+
DrmConstraints* DrmEngineBase::getConstraints(
30+
int uniqueId, const String8* path, int action) {
31+
return onGetConstraints(uniqueId, path, action);
32+
}
33+
34+
status_t DrmEngineBase::initialize(int uniqueId) {
35+
return onInitialize(uniqueId);
36+
}
37+
38+
status_t DrmEngineBase::setOnInfoListener(
39+
int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
40+
return onSetOnInfoListener(uniqueId, infoListener);
41+
}
42+
43+
status_t DrmEngineBase::terminate(int uniqueId) {
44+
return onTerminate(uniqueId);
45+
}
46+
47+
bool DrmEngineBase::canHandle(int uniqueId, const String8& path) {
48+
return onCanHandle(uniqueId, path);
49+
}
50+
51+
DrmInfoStatus* DrmEngineBase::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
52+
return onProcessDrmInfo(uniqueId, drmInfo);
53+
}
54+
55+
void DrmEngineBase::saveRights(
56+
int uniqueId, const DrmRights& drmRights,
57+
const String8& rightsPath, const String8& contentPath) {
58+
return onSaveRights(uniqueId, drmRights, rightsPath, contentPath);
59+
}
60+
61+
DrmInfo* DrmEngineBase::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
62+
return onAcquireDrmInfo(uniqueId, drmInfoRequest);
63+
}
64+
65+
String8 DrmEngineBase::getOriginalMimeType(int uniqueId, const String8& path) {
66+
return onGetOriginalMimeType(uniqueId, path);
67+
}
68+
69+
int DrmEngineBase::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) {
70+
return onGetDrmObjectType(uniqueId, path, mimeType);
71+
}
72+
73+
int DrmEngineBase::checkRightsStatus(int uniqueId, const String8& path, int action) {
74+
return onCheckRightsStatus(uniqueId, path, action);
75+
}
76+
77+
void DrmEngineBase::consumeRights(
78+
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
79+
onConsumeRights(uniqueId, decryptHandle, action, reserve);
80+
}
81+
82+
void DrmEngineBase::setPlaybackStatus(
83+
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
84+
onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
85+
}
86+
87+
bool DrmEngineBase::validateAction(
88+
int uniqueId, const String8& path,
89+
int action, const ActionDescription& description) {
90+
return onValidateAction(uniqueId, path, action, description);
91+
}
92+
93+
void DrmEngineBase::removeRights(int uniqueId, const String8& path) {
94+
onRemoveRights(uniqueId, path);
95+
}
96+
97+
void DrmEngineBase::removeAllRights(int uniqueId) {
98+
onRemoveAllRights(uniqueId);
99+
}
100+
101+
void DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
102+
onOpenConvertSession(uniqueId, convertId);
103+
}
104+
105+
DrmConvertedStatus* DrmEngineBase::convertData(
106+
int uniqueId, int convertId, const DrmBuffer* inputData) {
107+
return onConvertData(uniqueId, convertId, inputData);
108+
}
109+
110+
DrmConvertedStatus* DrmEngineBase::closeConvertSession(int uniqueId, int convertId) {
111+
return onCloseConvertSession(uniqueId, convertId);
112+
}
113+
114+
DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
115+
return onGetSupportInfo(uniqueId);
116+
}
117+
118+
status_t DrmEngineBase::openDecryptSession(
119+
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) {
120+
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
121+
}
122+
123+
void DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
124+
onCloseDecryptSession(uniqueId, decryptHandle);
125+
}
126+
127+
void DrmEngineBase::initializeDecryptUnit(
128+
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
129+
onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
130+
}
131+
132+
status_t DrmEngineBase::decrypt(
133+
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
134+
const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
135+
return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
136+
}
137+
138+
void DrmEngineBase::finalizeDecryptUnit(
139+
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
140+
onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
141+
}
142+
143+
ssize_t DrmEngineBase::pread(
144+
int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
145+
return onPread(uniqueId, decryptHandle, buffer, numBytes, offset);
146+
}
147+

0 commit comments

Comments
 (0)