Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27ed8ad2 authored by aimitakeshi's avatar aimitakeshi
Browse files

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
parent f1a97e53
Loading
Loading
Loading
Loading

drm/common/Android.mk

0 → 100644
+41 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
    DrmConstraints.cpp \
    DrmConvertedStatus.cpp \
    DrmEngineBase.cpp \
    DrmInfo.cpp \
    DrmInfoRequest.cpp \
    DrmInfoStatus.cpp \
    DrmRights.cpp \
    DrmSupportInfo.cpp \
    IDrmIOService.cpp \
    IDrmManagerService.cpp \
    IDrmServiceListener.cpp \
    DrmInfoEvent.cpp \
    ReadWriteUtils.cpp

LOCAL_C_INCLUDES := \
    $(TOP)/frameworks/base/include \
    $(TOP)/frameworks/base/drm/libdrmframework/include \
    $(TOP)/frameworks/base/drm/libdrmframework/plugins/common/include

LOCAL_MODULE:= libdrmframeworkcommon

include $(BUILD_STATIC_LIBRARY)
+117 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <drm/DrmConstraints.h>

using namespace android;

const String8 DrmConstraints::MAX_REPEAT_COUNT("max_repeat_count");
const String8 DrmConstraints::REMAINING_REPEAT_COUNT("remaining_repeat_count");
const String8 DrmConstraints::LICENSE_START_TIME("license_start_time");
const String8 DrmConstraints::LICENSE_EXPIRY_TIME("license_expiry_time");
const String8 DrmConstraints::LICENSE_AVAILABLE_TIME("license_available_time");
const String8 DrmConstraints::EXTENDED_METADATA("extended_metadata");

int DrmConstraints::getCount(void) const {
    return mConstraintMap.size();
}

status_t DrmConstraints::put(const String8* key, const char* value) {
    int length = strlen(value);
    char* charValue = new char[length + 1];
    if (NULL != charValue) {
        strncpy(charValue, value, length);
        charValue[length] = '\0';
        mConstraintMap.add(*key, charValue);
    }
    return DRM_NO_ERROR;
}

String8 DrmConstraints::get(const String8& key) const {
    if (NULL != getValue(&key)) {
        return String8(getValue(&key));
    }
    return String8("");
}

const char* DrmConstraints::getValue(const String8* key) const {
    if (NAME_NOT_FOUND != mConstraintMap.indexOfKey(*key)) {
        return mConstraintMap.valueFor(*key);
    }
    return NULL;
}

const char* DrmConstraints::getAsByteArray(const String8* key) const {
    return getValue(key);
}

bool DrmConstraints::KeyIterator::hasNext() {
    return mIndex < mDrmConstraints->mConstraintMap.size();
}

const String8& DrmConstraints::KeyIterator::next() {
    const String8& key = mDrmConstraints->mConstraintMap.keyAt(mIndex);
    mIndex++;
    return key;
}

DrmConstraints::KeyIterator DrmConstraints::keyIterator() {
    return KeyIterator(this);
}

DrmConstraints::KeyIterator::KeyIterator(const DrmConstraints::KeyIterator& keyIterator)
    : mDrmConstraints(keyIterator.mDrmConstraints),
      mIndex(keyIterator.mIndex) {
    LOGV("DrmConstraints::KeyIterator::KeyIterator");
}

DrmConstraints::KeyIterator& DrmConstraints::KeyIterator::operator=(
    const DrmConstraints::KeyIterator& keyIterator) {
    LOGV("DrmConstraints::KeyIterator::operator=");
    mDrmConstraints = keyIterator.mDrmConstraints;
    mIndex = keyIterator.mIndex;
    return *this;
}


DrmConstraints::Iterator DrmConstraints::iterator() {
    return Iterator(this);
}

DrmConstraints::Iterator::Iterator(const DrmConstraints::Iterator& iterator) :
    mDrmConstraints(iterator.mDrmConstraints),
    mIndex(iterator.mIndex) {
    LOGV("DrmConstraints::Iterator::Iterator");
}

DrmConstraints::Iterator& DrmConstraints::Iterator::operator=(
    const DrmConstraints::Iterator& iterator) {
    LOGV("DrmConstraints::Iterator::operator=");
    mDrmConstraints = iterator.mDrmConstraints;
    mIndex = iterator.mIndex;
    return *this;
}

bool DrmConstraints::Iterator::hasNext() {
    return mIndex < mDrmConstraints->mConstraintMap.size();
}

String8 DrmConstraints::Iterator::next() {
    String8 value = String8(mDrmConstraints->mConstraintMap.editValueAt(mIndex));
    mIndex++;
    return value;
}
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <drm/DrmConvertedStatus.h>

using namespace android;

DrmConvertedStatus::DrmConvertedStatus(
    int _statusCode, const DrmBuffer* _convertedData, int _offset) :
    statusCode(_statusCode),
    convertedData(_convertedData),
    offset(_offset) {

}
+147 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "DrmEngineBase.h"

using namespace android;

DrmEngineBase::DrmEngineBase() {

}

DrmEngineBase::~DrmEngineBase() {

}

DrmConstraints* DrmEngineBase::getConstraints(
    int uniqueId, const String8* path, int action) {
    return onGetConstraints(uniqueId, path, action);
}

status_t DrmEngineBase::initialize(int uniqueId) {
    return onInitialize(uniqueId);
}

status_t DrmEngineBase::setOnInfoListener(
    int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
    return onSetOnInfoListener(uniqueId, infoListener);
}

status_t DrmEngineBase::terminate(int uniqueId) {
    return onTerminate(uniqueId);
}

bool DrmEngineBase::canHandle(int uniqueId, const String8& path) {
    return onCanHandle(uniqueId, path);
}

DrmInfoStatus* DrmEngineBase::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
    return onProcessDrmInfo(uniqueId, drmInfo);
}

void DrmEngineBase::saveRights(
            int uniqueId, const DrmRights& drmRights,
            const String8& rightsPath, const String8& contentPath) {
    return onSaveRights(uniqueId, drmRights, rightsPath, contentPath);
}

DrmInfo* DrmEngineBase::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
    return onAcquireDrmInfo(uniqueId, drmInfoRequest);
}

String8 DrmEngineBase::getOriginalMimeType(int uniqueId, const String8& path) {
    return onGetOriginalMimeType(uniqueId, path);
}

int DrmEngineBase::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) {
    return onGetDrmObjectType(uniqueId, path, mimeType);
}

int DrmEngineBase::checkRightsStatus(int uniqueId, const String8& path, int action) {
    return onCheckRightsStatus(uniqueId, path, action);
}

void DrmEngineBase::consumeRights(
    int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
    onConsumeRights(uniqueId, decryptHandle, action, reserve);
}

void DrmEngineBase::setPlaybackStatus(
    int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
    onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}

bool DrmEngineBase::validateAction(
    int uniqueId, const String8& path,
    int action, const ActionDescription& description) {
    return onValidateAction(uniqueId, path, action, description);
}

void DrmEngineBase::removeRights(int uniqueId, const String8& path) {
    onRemoveRights(uniqueId, path);
}

void DrmEngineBase::removeAllRights(int uniqueId) {
    onRemoveAllRights(uniqueId);
}

void DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
    onOpenConvertSession(uniqueId, convertId);
}

DrmConvertedStatus* DrmEngineBase::convertData(
    int uniqueId, int convertId, const DrmBuffer* inputData) {
    return onConvertData(uniqueId, convertId, inputData);
}

DrmConvertedStatus* DrmEngineBase::closeConvertSession(int uniqueId, int convertId) {
    return onCloseConvertSession(uniqueId, convertId);
}

DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
    return onGetSupportInfo(uniqueId);
}

status_t DrmEngineBase::openDecryptSession(
    int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) {
    return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
}

void DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    onCloseDecryptSession(uniqueId, decryptHandle);
}

void DrmEngineBase::initializeDecryptUnit(
    int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
    onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
}

status_t DrmEngineBase::decrypt(
    int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
    const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
    return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
}

void DrmEngineBase::finalizeDecryptUnit(
    int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
    onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}

ssize_t DrmEngineBase::pread(
    int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
    return onPread(uniqueId, decryptHandle, buffer, numBytes, offset);
}

drm/common/DrmInfo.cpp

0 → 100644
+111 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <drm/DrmInfo.h>

using namespace android;

DrmInfo::DrmInfo(int infoType, const DrmBuffer& drmBuffer, const String8& mimeType) :
    mInfoType(infoType),
    mData(drmBuffer),
    mMimeType(mimeType) {

}

int DrmInfo::getInfoType(void) const {
    return mInfoType;
}

String8 DrmInfo::getMimeType(void) const {
    return mMimeType;
}

const DrmBuffer& DrmInfo::getData(void) const {
    return mData;
}

int DrmInfo::getCount(void) const {
    return mAttributes.size();
}

status_t DrmInfo::put(const String8& key, const String8& value) {
    mAttributes.add(key, value);
    return DRM_NO_ERROR;
}

String8 DrmInfo::get(const String8& key) const {
    if (NAME_NOT_FOUND != mAttributes.indexOfKey(key)) {
        return mAttributes.valueFor(key);
    }
    return String8("");
}

int DrmInfo::indexOfKey(const String8& key) const {
    return mAttributes.indexOfKey(key);
}

DrmInfo::KeyIterator DrmInfo::keyIterator() const {
    return KeyIterator(this);
}

DrmInfo::Iterator DrmInfo::iterator() const {
    return Iterator(this);
}

// KeyIterator implementation
DrmInfo::KeyIterator::KeyIterator(const DrmInfo::KeyIterator& keyIterator) :
    mDrmInfo(keyIterator.mDrmInfo), mIndex(keyIterator.mIndex) {

}

bool DrmInfo::KeyIterator::hasNext() {
    return (mIndex < mDrmInfo->mAttributes.size());
}

const String8& DrmInfo::KeyIterator::next() {
    const String8& key = mDrmInfo->mAttributes.keyAt(mIndex);
    mIndex++;
    return key;
}

DrmInfo::KeyIterator& DrmInfo::KeyIterator::operator=(const DrmInfo::KeyIterator& keyIterator) {
    mDrmInfo = keyIterator.mDrmInfo;
    mIndex = keyIterator.mIndex;
    return *this;
}

// Iterator implementation
DrmInfo::Iterator::Iterator(const DrmInfo::Iterator& iterator)
    : mDrmInfo(iterator.mDrmInfo), mIndex(iterator.mIndex) {

}

DrmInfo::Iterator& DrmInfo::Iterator::operator=(const DrmInfo::Iterator& iterator) {
    mDrmInfo = iterator.mDrmInfo;
    mIndex = iterator.mIndex;
    return *this;
}

bool DrmInfo::Iterator::hasNext() {
    return mIndex < mDrmInfo->mAttributes.size();
}

String8& DrmInfo::Iterator::next() {
    String8& value = mDrmInfo->mAttributes.editValueAt(mIndex);
    mIndex++;
    return value;
}
Loading