Implement Widevine drm HIDL HAL service.

Modify Android mediadrm and mediacrypto glue layer to use
HIDL interface.

Test: Play Movies (streaming and offline playback)

Test: ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed
run gts -m GtsMediaTestCases

Test:
adb shell /system/bin/libwvdrmengine_hidl_test

Test:
adb shell /system/bin/libwvdrmmediacrypto_hidl_test

Test:
adb shell /system/bin/libwvdrmdrmplugin_hidl_test

bug: 34628973
Change-Id: Icd5f2dd556acb9874697963b4d7d62cb7c943e74
This commit is contained in:
Edwin Wong
2017-01-23 15:48:45 -08:00
committed by John W. Bruce
parent a4506542df
commit 2dc53442e7
33 changed files with 6853 additions and 684 deletions

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2017 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.
*/
#ifndef WVDRM_ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT
#define WVDRM_ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT
#include "utils/Errors.h"
#include <utils/Vector.h>
#include <android/hardware/drm/1.0/types.h>
#include <media/stagefright/MediaErrors.h>
namespace android {
namespace hardware {
namespace drm {
namespace V1_0 {
namespace widevine {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_vec;
template<typename T> const hidl_vec<T> toHidlVec(const Vector<T> &Vector) {
hidl_vec<T> vec;
vec.setToExternal(const_cast<T *>(Vector.array()), Vector.size());
return vec;
}
template<typename T> hidl_vec<T> toHidlVec(Vector<T> &Vector) {
hidl_vec<T> vec;
vec.setToExternal(Vector.editArray(), Vector.size());
return vec;
}
template<typename T> const Vector<T> toVector(const hidl_vec<T> &vec) {
Vector<T> vector;
vector.appendArray(vec.data(), vec.size());
return *const_cast<const Vector<T> *>(&vector);
}
template<typename T> Vector<T> toVector(hidl_vec<T> &vec) {
Vector<T> vector;
vector.appendArray(vec.data(), vec.size());
return vector;
}
template<typename T, size_t SIZE> const Vector<T> toVector(
const hidl_array<T, SIZE> &array) {
Vector<T> vector;
vector.appendArray(array.data(), array.size());
return vector;
}
template<typename T, size_t SIZE> Vector<T> toVector(
hidl_array<T, SIZE> &array) {
Vector<T> vector;
vector.appendArray(array.data(), array.size());
return vector;
}
Status toStatus(status_t mediaError);
} // namespace widevine
} // namespace V1_0
} // namespace drm
} // namespace hardware
} // namespace android
#endif // WVDRM_ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT

View File

@@ -0,0 +1,30 @@
//
// Copyright 2017 Google Inc. All Rights Reserved.
//
#ifndef WV_CREATE_PLUGIN_FACTORIES_H_
#define WV_CREATE_PLUGIN_FACTORIES_H_
#include <android/hardware/drm/1.0/ICryptoFactory.h>
#include <android/hardware/drm/1.0/IDrmFactory.h>
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_0 {
namespace widevine {
using ::android::hardware::drm::V1_0::ICryptoFactory;
using ::android::hardware::drm::V1_0::IDrmFactory;
extern "C" {
IDrmFactory* createDrmFactory();
ICryptoFactory* createCryptoFactory();
}
} // namespace widevine
} // namespace V1_0
} // namespace drm
} // namespace hardware
} // namespace wvdrm
#endif // WV_CREATE_PLUGIN_FACTORIES_H_

View File

@@ -0,0 +1,47 @@
//
// Copyright 2017 Google Inc. All Rights Reserved.
//
#ifndef WV_CRYPTO_FACTORY_H_
#define WV_CRYPTO_FACTORY_H_
#include <android/hardware/drm/1.0/ICryptoFactory.h>
#include "WVTypes.h"
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_0 {
namespace widevine {
using ::android::hardware::drm::V1_0::ICryptoFactory;
using ::android::hardware::drm::V1_0::ICryptoPlugin;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
struct WVCryptoFactory : public ICryptoFactory {
public:
WVCryptoFactory() {}
virtual ~WVCryptoFactory() {}
Return<bool> isCryptoSchemeSupported(const hidl_array<uint8_t, 16>& uuid)
override;
Return<void> createPlugin(
const hidl_array<uint8_t, 16>& uuid,
const hidl_vec<uint8_t>& initData,
createPlugin_cb _hidl_cb) override;
private:
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVCryptoFactory);
};
} // namespace widevine
} // namespace V1_0
} // namespace drm
} // namespace hardware
} // namespace wvdrm
#endif // WV_CRYPTO_FACTORY_H_

View File

@@ -0,0 +1,54 @@
//
// Copyright 2017 Google Inc. All Rights Reserved.
//
#ifndef WV_DRM_FACTORY_H_
#define WV_DRM_FACTORY_H_
#include <android/hardware/drm/1.0/IDrmFactory.h>
#include "WVGenericCryptoInterface.h"
#include "WVTypes.h"
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_0 {
namespace widevine {
using ::android::hardware::drm::V1_0::IDrmFactory;
using ::android::hardware::drm::V1_0::IDrmPlugin;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
struct WVDrmFactory : public IDrmFactory {
WVDrmFactory() {}
virtual ~WVDrmFactory() {}
Return<bool> isCryptoSchemeSupported(const hidl_array<uint8_t, 16>& uuid)
override;
Return<bool> isContentTypeSupported(const hidl_string &mimeType)
override;
Return<void> createPlugin(
const hidl_array<uint8_t, 16>& uuid,
const hidl_string& appPackageName,
createPlugin_cb _hidl_cb) override;
private:
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVDrmFactory);
static WVGenericCryptoInterface sOemCryptoInterface;
};
extern "C" IDrmFactory* HIDL_FETCH_IDrmFactory(const char* name);
} // namespace widevine
} // namespace V1_0
} // namespace drm
} // namespace hardware
} // namespace wvdrm
#endif // WV_DRM_FACTORY_H_

View File

@@ -0,0 +1,20 @@
//
// Copyright 2017 Google Inc. All Rights Reserved.
//
#ifndef WV_TYPES_H_
#define WV_TYPES_H_
namespace wvdrm {
#define WVDRM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
#define WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(TypeName) \
TypeName() = delete; \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
} // namespace wvdrm
#endif // WV_TYPES_H_